ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

The twist message uses m/s for linear velocity units and radians/s for the angular velocity units.

You'll need to do a bit of trial and error to find out the ratio between these units and the values you need to pass to the motor controllers to make the robot move at approximately the right speed.

The linear movement is the easiest simply multiply the x linear velocity by the linear ratio (which you'll need to find through experimentation) and set each wheel to this speed. There's a good chance you'll need to negate one since one wheel motor will be a 180 degree rotation of the other, so depending on the controller one may need to be backwards for the robot to move forwards in a straight line.

The angular movement is almost exactly the same except you need to find a different ratio, between rads/sec and control output and make sure the wheels turn in opposite directions.

Simply add the angular and linear speeds for each wheel together to get the final speed.

Finally, there is obviously a maximum speed that the robots wheels can turn and twist messages can easily exceed this. If you scale both wheel velocities down by the same ratio so that they are within the range the motors are capable of then the robot will follow the same trajectory as commanded to by the twist message but at a lower speed.

It's actually fairly simple (no trig required) although you'll need to find the ratios for your particular robot to get the control outputs to accurately reflect the twist commands.