Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do X,Y, and Z mean in geometry_msgs Twist message in ROS

Tags:

ros

I'm trying to convert Twist to the left and right wheels' speed with the formula:

float speed_wish_right = (cmd_vel.angle*WHEEL_DIST)/2 + cmd_vel.speed;
float speed_wish_left = cmd_vel.speed*2-speed_wish_right;

Twist.angular is a vector [x, y, z] and so is Twist.linear. What do x, y, z mean in the vector and how can I get angles and speed out of the two vectors?

This is my callback function in Arduino

const int WHEEL_DIST = 16;
void velCallback(geometry_msgs::Twist vel) {
  float linear = vel.linear.x;
  float angle = vel.angular.z;

  float speed_wish_right = (angle * WHEEL_DIST) / 2 + linear;
  float speed_wish_left = linear * 2 - speed_wish_right;
  motors.setSpeeds(speed_wish_left, speed_wish_right);
}
like image 759
desperatecoder Avatar asked Jun 21 '18 19:06

desperatecoder


People also ask

What is Twist message?

Twist is an async messaging app that makes collaboration easy from anywhere by using threads to organize your conversations.

What is Cmd_vel in Ros?

cmd_vel - The main user interface topic (priority: 90). nav_vel - This topic is used is used by the move_base to send navigation commands (priority: 80). The output topic is mobile_base_controller/cmd_vel, it's not recommended to publish Twist messages directly to this topic.


1 Answers

Consider that you are in some space, then there are 3 axes - x, y and z which are mutually perpendicular to each other and their point of intersection is called the origin (x = 0, y = 0, z = 0). This can be a frame of reference i.e. you can define various points and directions w.r.t. them.

The x, y, and z in Twist.linear are the linear velocities in x, y and z directions w.r.t. that frame of reference.

Similarly, the x, y, and z in Twist.angular are the angular velocities about the x, y and z directions respectively w.r.t. the same frame of reference.

Since you have a ground robot, most probably your angular velocity will be in z i.e. robot's turning speed. And your linear velocity will be mostly in x i.e. robot's moving straight speed. This is the case for the Turtlebot 2 at least.

like image 196
akshayk07 Avatar answered Oct 03 '22 04:10

akshayk07