Skip to content

Commit 3e9b083

Browse files
committed
Add acc limit consideration to avoid overshoot in RotationShimController
Signed-off-by: RBT22 <[email protected]>
1 parent a33e8d2 commit 3e9b083

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

nav2_rotation_shim_controller/src/nav2_rotation_shim_controller.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ RotationShimController::computeRotateToHeadingCommand(
300300
cmd_vel.twist.angular.z =
301301
std::clamp(angular_vel, min_feasible_angular_speed, max_feasible_angular_speed);
302302

303+
// Check if we need to slow down to avoid overshooting
304+
double max_vel_to_stop = std::sqrt(2 * max_angular_accel_ * fabs(angular_distance_to_heading));
305+
if (fabs(cmd_vel.twist.angular.z) > max_vel_to_stop) {
306+
cmd_vel.twist.angular.z = sign * max_vel_to_stop;
307+
}
308+
303309
isCollisionFree(cmd_vel, angular_distance_to_heading, pose);
304310
return cmd_vel;
305311
}

0 commit comments

Comments
 (0)