ROS2 Velocity Profiling for Smooth Stops

Medium Control 0% pass rate

Practice the ROS2 Velocity Profiling for Smooth Stops coding problem in Control. Browser-based execution with automated grading — no local ROS install required. 0% of engineers pass this challenge.

Problem Statement

Implement generate_velocity_profile(distance, max_vel, accel, dt) that returns a list of velocity setpoints for moving a robot a given distance.

Function Signature

def generate_velocity_profile(distance: float, max_vel: float, accel: float, dt: float) -> list[float]:

Requirements

Generate a trapezoidal velocity profile:

  1. Ramp up: increase velocity by accel * dt each step until max_vel is reached
  2. Cruise: maintain max_vel until deceleration must begin
  3. Ramp down: decrease velocity by accel * dt each step until velocity reaches 0
  4. The profile must not overshoot the target distance (total distance ≤ target + 0.01m tolerance)
  5. The last velocity value must be 0 (robot stops at target)
  6. All velocities must be ≥ 0

Deceleration distance

The robot needs d_decel = v² / (2 * accel) metres to decelerate from velocity v to 0. Start decelerating when remaining distance ≤ d_decel.

🤖 Why This Matters in Real Robots

Trapezoidal profiles are built into every industrial servo drive (Beckhoff, Siemens, Fanuc). In ROS2, the joint_trajectory_controller and follow_joint_trajectory action server both interpolate between waypoints using exactly this profile. Understanding it from scratch is prerequisite to working with ros2_control's trajectory execution.

Frequently asked questions

What is the ROS2 Velocity Profiling for Smooth Stops practice problem?

It is a hands-on Control challenge on SimuCode where you implement and run ROS2 code in the browser with runtime-verified tests.

How do I practice ROS2 Velocity Profiling for Smooth Stops online?

Open this page, sign in, and solve the problem in the built-in IDE. Your solution is graded against real ROS2 execution checks.

What skills does ROS2 Velocity Profiling for Smooth Stops test?

This Medium problem focuses on Control skills used in robotics interviews and production systems.