Skip to content

Commit f614919

Browse files
committed
FW L1 controller: when loitering, set the yaw setpoint to be tangentially to loiter circle
Signed-off-by: Silvan Fuhrer <[email protected]>
1 parent 4f708d7 commit f614919

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/l1/ECL_L1_Pos_Controller.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ ECL_L1_Pos_Controller::navigate_loiter(const Vector2d &vector_A, const Vector2d
306306
_lateral_accel = lateral_accel_sp_circle;
307307
_circle_mode = true;
308308
_bearing_error = 0.0f;
309-
/* bearing from current position to L1 point */
310-
_nav_bearing = atan2f(-vector_A_to_airplane_unit(1), -vector_A_to_airplane_unit(0));
309+
// once loitering, the bearing is tangentially to the loiter,
310+
// so subtract PI/2 from the bearing from current position to loiter center
311+
_nav_bearing = atan2f(-vector_A_to_airplane_unit(1), -vector_A_to_airplane_unit(0)) - M_PI_2_F;
311312
}
312313

313314
update_roll_setpoint();

0 commit comments

Comments
 (0)