Plane: ensure xy controller is initialised

This commit is contained in:
Andrew Tridgell 2021-05-14 18:08:34 +10:00
parent 9d52333afc
commit a6ec7d9f23
2 changed files with 16 additions and 3 deletions

View File

@ -2440,6 +2440,17 @@ bool QuadPlane::in_vtol_posvel_mode(void) const
in_vtol_auto());
}
/*
run (and possibly init) xy controller
*/
void QuadPlane::run_xy_controller(void)
{
if (!pos_control->is_active_xy()) {
pos_control->init_xy_controller();
}
pos_control->update_xy_controller();
}
/*
main landing controller. Used for landing and RTL.
*/
@ -2512,7 +2523,7 @@ void QuadPlane::vtol_position_controller(void)
pos_control->set_accel_desired_xy_cmss(0.0f, 0.0f);
// run horizontal velocity controller
pos_control->update_xy_controller();
run_xy_controller();
// nav roll and pitch are controller by position controller
plane.nav_roll_cd = pos_control->get_roll_cd();
@ -2579,7 +2590,7 @@ void QuadPlane::vtol_position_controller(void)
} else {
pos_control->set_pos_target_xy_cm(poscontrol.target.x, poscontrol.target.y);
}
pos_control->update_xy_controller();
run_xy_controller();
// nav roll and pitch are controller by position controller
plane.nav_roll_cd = pos_control->get_roll_cd();
@ -2714,7 +2725,8 @@ void QuadPlane::takeoff_controller(void)
// set position control target and update
pos_control->set_pos_target_xy_cm(poscontrol.target.x, poscontrol.target.y);
pos_control->update_xy_controller();
run_xy_controller();
// nav roll and pitch are controller by position controller
plane.nav_roll_cd = pos_control->get_roll_cd();

View File

@ -292,6 +292,7 @@ private:
void update_throttle_suppression(void);
void run_z_controller(void);
void run_xy_controller(void);
void setup_defaults(void);