# How to compute angular velocity from linear velocity?

Hi, I get linear velocity (linear.x and linear.y) in geometry_msgs/Twist message. But the robot is controlled by linear.x and angular.z. So I want to ask how to calculate angular.z from linear.x and linear.y.

edit retag close merge delete

Please edit your question and explain why you want to do this. Are you using move_base? In a properly configured move_base, this calculation should not be necessary because the Local Planner is expected to comply with the robot's physical motion restrictions.

My problem is in pedsim. I want to control the robot there. In pedsim, controllable by rqt_robot_steering. However, there is an algorithm to calculate robot control parameters in this environment . Its results are in topic /pedsim_simulator/robot_position. I want to use this result for control. In this topic, there are 2 parameters: linear.x and linear.y. But controlling the robot in pedsim will use linear.x and angular.z. So I want to find a way to convert this.

Sort by » oldest newest most voted

Mathematically, there is no direct conversion from (linear.x, linear.y) to (linear.x_, angular.z). However, if what you need to do is have the robot follow the same path, you can fake it by a rotate operation, followed by a drive_forward operation.

Treat the two input x,y values as vectors, and find the vector sum. In step 1, rotate the robot in place to point in the same direction as this new vector. In step 2, move forward using a linear.x_ value based on the length of the vector. (I call it x_ to emphasize that in most cases it is not the same value as the input linear.x.)

more