Plane: mode_qrtl: combine enter and init

This commit is contained in:
Iampete1 2021-09-04 20:21:11 +01:00 committed by Andrew Tridgell
parent fa908b0a1d
commit 63be15e018
1 changed files with 2 additions and 10 deletions

View File

@ -2,15 +2,6 @@
#include "Plane.h" #include "Plane.h"
bool ModeQRTL::_enter() bool ModeQRTL::_enter()
{
return plane.mode_qstabilize._enter();
}
/*
handle QRTL mode
*/
void ModeQRTL::init()
{ {
// use do_RTL() to setup next_WP_loc // use do_RTL() to setup next_WP_loc
plane.do_RTL(plane.home.alt + quadplane.qrtl_alt*100UL); plane.do_RTL(plane.home.alt + quadplane.qrtl_alt*100UL);
@ -30,10 +21,11 @@ void ModeQRTL::init()
int32_t to_alt; int32_t to_alt;
if (plane.current_loc.get_alt_cm(Location::AltFrame::ABSOLUTE,from_alt) && plane.next_WP_loc.get_alt_cm(Location::AltFrame::ABSOLUTE,to_alt)) { if (plane.current_loc.get_alt_cm(Location::AltFrame::ABSOLUTE,from_alt) && plane.next_WP_loc.get_alt_cm(Location::AltFrame::ABSOLUTE,to_alt)) {
poscontrol.slow_descent = from_alt > to_alt; poscontrol.slow_descent = from_alt > to_alt;
return; return true;
} }
// defualt back to old method // defualt back to old method
poscontrol.slow_descent = (plane.current_loc.alt > plane.next_WP_loc.alt); poscontrol.slow_descent = (plane.current_loc.alt > plane.next_WP_loc.alt);
return true;
} }
void ModeQRTL::update() void ModeQRTL::update()