2019-01-15 13:46:13 -04:00
|
|
|
#include "mode.h"
|
|
|
|
#include "Plane.h"
|
|
|
|
|
|
|
|
bool ModeGuided::_enter()
|
|
|
|
{
|
|
|
|
plane.throttle_allows_nudging = true;
|
|
|
|
plane.auto_throttle_mode = true;
|
|
|
|
plane.auto_navigation_mode = true;
|
|
|
|
plane.guided_throttle_passthru = false;
|
|
|
|
/*
|
|
|
|
when entering guided mode we set the target as the current
|
|
|
|
location. This matches the behaviour of the copter code
|
|
|
|
*/
|
|
|
|
plane.guided_WP_loc = plane.current_loc;
|
|
|
|
plane.set_guided_WP();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModeGuided::update()
|
|
|
|
{
|
|
|
|
if (plane.auto_state.vtol_loiter && plane.quadplane.available()) {
|
|
|
|
plane.quadplane.guided_update();
|
|
|
|
} else {
|
|
|
|
plane.calc_nav_roll();
|
|
|
|
plane.calc_nav_pitch();
|
|
|
|
plane.calc_throttle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-19 04:51:00 -03:00
|
|
|
void ModeGuided::navigate()
|
2020-07-29 12:01:34 -03:00
|
|
|
{
|
2020-08-11 07:54:28 -03:00
|
|
|
// Zero indicates to use WP_LOITER_RAD
|
|
|
|
plane.update_loiter(0);
|
2020-07-29 12:01:34 -03:00
|
|
|
}
|
|
|
|
|