|
|
|
@ -24,13 +24,13 @@ void ModeLoiter::update()
@@ -24,13 +24,13 @@ void ModeLoiter::update()
|
|
|
|
|
_distance_to_destination = get_distance(rover.current_loc, _destination); |
|
|
|
|
|
|
|
|
|
// if within waypoint radius slew desired speed towards zero and use existing desired heading
|
|
|
|
|
if (_distance_to_destination <= g.waypoint_radius) { |
|
|
|
|
if (_distance_to_destination <= g2.loit_radius) { |
|
|
|
|
_desired_speed = attitude_control.get_desired_speed_accel_limited(0.0f, rover.G_Dt); |
|
|
|
|
_yaw_error_cd = 0.0f; |
|
|
|
|
} else { |
|
|
|
|
// P controller with hard-coded gain to convert distance to desired speed
|
|
|
|
|
// To-Do: make gain configurable or calculate from attitude controller's maximum accelearation
|
|
|
|
|
_desired_speed = MIN((_distance_to_destination - g.waypoint_radius) * 0.5f, g.speed_cruise); |
|
|
|
|
_desired_speed = MIN((_distance_to_destination - g2.loit_radius) * 0.5f, g.speed_cruise); |
|
|
|
|
|
|
|
|
|
// calculate bearing to destination
|
|
|
|
|
_desired_yaw_cd = get_bearing_cd(rover.current_loc, _destination); |
|
|
|
|