Rosanswers logo


I'm trying to get a differential drive robot running with ros_control and the diff_drive_controller. I have a working setup except for knowing exactly what the commands written to the command variable in the diff_drive_controller actually means (the ones I'm supposed to convert to motor commands in my RobotHW-instance). I've gone through the code for the diff_drive_controller to actually understand what's happening and I've tried to trace down how a vel_cmd is being translated to something else in the controller.

This is the move robot code from the diff_drive_controller:

// Compute wheels velocities:
const double vel_left  = (curr_cmd.lin - curr_cmd.ang * ws / 2.0)/wr;
const double vel_right = (curr_cmd.lin + curr_cmd.ang * ws / 2.0)/wr;

My configuration file for the controller specifies the wheel separation to 0.341 meters and the wheel radius to 0.05 meters. When I'm sending a cmd_vel with a linear velocity of 0.5m/s and no angular velocity (hence, the robot should move straight ahead..) the calculations will translate to:

vel_left = (0.5 - 0.0 * 0.341 / 2.0) / 0.05; // Equals 10
vel_right = (0.5 + 0.0 * 0.341 / 2.0) 0.05; // Equals 10

So what unit is the value 10 in? S.I m/s? Can't be! I want to go with 0.5m/s straight ahead.

Trying to wrap my head around this but right now I'm just feeling stupid.. x-(


Originally posted by ErikHells on ROS Answers with karma: 13 on 2016-08-30

Post score: 1

Original comments

Comment by hc on 2018-03-30:
Could you please tell me how you interfaced diff_drive_controller with ros_control? What is the output of diff_drive_controller that is used by the ros_control?


1 Answer 1


Rosanswers logo

It's linear speed (m/s) divided by radius (m), so final units are 1/s.


I think this is best interpreted as radians per second.

Originally posted by ahendrix with karma: 47576 on 2016-08-30

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by ErikHells on 2016-08-31:
Tnks! So in my case with a return value of 10, the wheels should turn 10 times per second? That's 3.14 m/s (0.1pi10). Far from the 0.5 m/s I had as an input. It works by just multiplying with the wheel radius on the RobotHW-side again but the division by wheel radius in diff control is unnecessary

Comment by ErikHells on 2016-09-01:
Now, that makes perfectly sense. Of course! Thank you! :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.