Plane: reset yaw controller on entry to POSITION1

this fixes a yaw change when we finish landing approach in
QRTL. Thanks to Henry for noticing this
This commit is contained in:
Andrew Tridgell 2021-06-13 12:18:39 +10:00
parent ce4ca0ac08
commit 0c8e81964e

View File

@ -2590,14 +2590,15 @@ void QuadPlane::poscontrol_init_approach(void)
void QuadPlane::PosControlState::set_state(enum position_control_state s) void QuadPlane::PosControlState::set_state(enum position_control_state s)
{ {
if (state != s) { if (state != s) {
auto &qp = plane.quadplane;
pilot_correction_done = false; pilot_correction_done = false;
// handle resets needed for when the state changes // handle resets needed for when the state changes
if (s == QPOS_POSITION1) { if (s == QPOS_POSITION1) {
reached_wp_speed = false; reached_wp_speed = false;
qp.attitude_control->reset_yaw_target_and_rate();
} else if (s == QPOS_POSITION2) { } else if (s == QPOS_POSITION2) {
// POSITION2 changes target speed, so we need to change it // POSITION2 changes target speed, so we need to change it
// back to normal // back to normal
auto &qp = plane.quadplane;
qp.pos_control->set_max_speed_accel_xy(qp.wp_nav->get_default_speed_xy(), qp.pos_control->set_max_speed_accel_xy(qp.wp_nav->get_default_speed_xy(),
qp.wp_nav->get_wp_acceleration()); qp.wp_nav->get_wp_acceleration());
} }