Complete the code to set the maximum linear velocity limit in the ROS node.
max_linear_velocity = [1] # meters per second
The maximum linear velocity is set to 0.5 m/s to ensure safe robot movement.
Complete the code to limit the angular velocity in the ROS velocity command message.
cmd_vel.angular.z = [1] # radians per second
Angular velocity is limited to 1 radian per second for safe turning speed.
Fix the error in the velocity limiting function to clamp the linear velocity correctly.
def limit_velocity(velocity, max_velocity): return min(velocity, [1])
The function should return the smaller of the current velocity and the maximum allowed velocity.
Fill both blanks to create a dictionary comprehension that maps each velocity component to its limited value.
limited_velocities = {axis: min(value, [1]) for axis, value in velocities.items() if value [2] 0}The comprehension limits each velocity to max_velocity only if the velocity is positive.
Fill all three blanks to create a ROS subscriber callback that limits and publishes safe velocities.
def velocity_callback(msg): safe_linear = min(msg.linear.x, [1]) safe_angular = min(msg.angular.z, [2]) safe_msg = Twist() safe_msg.linear.x = safe_linear safe_msg.angular.z = safe_angular [3].publish(safe_msg)
The callback limits linear and angular velocities using max limits and publishes the safe message.
