ROS2 Control - Velocity Controller

Medium Motion Control 78% pass rate
#control#velocity#differential-drive#cmd-vel

Practice the ROS2 Control - Velocity Controller coding problem in Motion Control. Browser-based execution with automated grading — no local ROS install required. 78% of engineers pass this challenge.

Problem Statement

Implement a velocity controller node that drives a robot along a parameterized motion pattern and publishes velocity commands to /cmd_vel.

Requirements

Your node must:

  • Declare parameters: max_linear_speed (default 0.5 m/s) and max_angular_speed (default 1.0 rad/s)
  • Create a publisher for geometry_msgs/Twist on /cmd_vel
  • Create a create_timer(0.1, ...) (10 Hz) control loop
  • In each control loop iteration:
    • Build a Twist message with non-zero linear.x or angular.z (or both)
    • Clamp linear.x to [-max_linear_speed, max_linear_speed]
    • Clamp angular.z to [-max_angular_speed, max_angular_speed]
    • Publish the Twist message
  • Publish at least 5 messages during the test window
  • Log "Velocity Controller Ready" on startup

Input / Output

Output: geometry_msgs/Twist on /cmd_vel at 10 Hz

🤖 Why This Matters in Real Robots

This is the interface contract for every differential drive robot: differential drive controllers, omni-wheel controllers, and skid-steer controllers all listen on /cmd_vel and convert Twist into individual wheel velocities. Understanding this interface — and its limits — is prerequisite knowledge for working with ros2_control, Nav2, or writing any teleoperation interface.

⚠️ Common Pitfalls

  • Publishing zero Twist: A default-constructed Twist() has all zeros. The robot won't move. Your control loop must set at least one non-zero field.
  • Speed limits not from parameters: Hard-coding 0.5 instead of reading self.get_parameter('max_linear_speed').value defeats the purpose of parameterisation.

Frequently asked questions

What is the ROS2 Control - Velocity Controller practice problem?

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

How do I practice ROS2 Control - Velocity Controller 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 Control - Velocity Controller test?

This Medium problem focuses on control, velocity, differential-drive skills used in robotics interviews and production systems.