Copter: build return path in run() rather than init()

This avoids attempting to build a return path if we don't currently have
a home or origin
This commit is contained in:
Peter Barker 2018-10-26 12:28:03 +11:00 committed by Randy Mackay
parent 7ad4d95426
commit d34c4b01f4
2 changed files with 9 additions and 2 deletions

View File

@ -1027,7 +1027,9 @@ private:
} rtl_path;
// Loiter timer - Records how long we have been in loiter
uint32_t _loiter_start_time = 0;
uint32_t _loiter_start_time;
bool path_built;
};

View File

@ -19,7 +19,7 @@ bool Copter::ModeRTL::init(bool ignore_checks)
}
// initialise waypoint and spline controller
wp_nav->wp_and_spline_init();
build_path(!copter.failsafe.terrain);
path_built = false;
climb_start();
return true;
}
@ -39,6 +39,11 @@ void Copter::ModeRTL::restart_without_terrain()
// should be called at 100hz or more
void Copter::ModeRTL::run(bool disarm_on_land)
{
if (!path_built) {
path_built = true;
build_path(!copter.failsafe.terrain);
}
// check if we need to move to next state
if (_state_complete) {
switch (_state) {