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);
}
Twist is an async messaging app that makes collaboration easy from anywhere by using threads to organize your conversations.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With