Question about odometry and radians unit
hi ,
i have a question about odometry , here is the code i'm using to get odometry from wheel encoder
i don't understand something , why vth unit is m/s ? if ' th' is an angle it should be in radians but since vth unit is m/s then 'th' is not in radian , i don't understant why it's working , because when i transform 'vth' to rd/s so that 'th' be in radian the odometry is not working so i'm really confuse
dt=(current_time - last_time).toSec();
tick_Left = tick_l - _PreviousLeftEncoderCounts;
tick_Right = tick_f - _PreviousRightEncoderCounts;
speed_left = (tick_Left * DistancePerCount) / dt; //speed left wheel in m/s
speed_right = (tick_Right * DistancePerCount) / dt; // speed right wheel in m/s
vx = (speed_right + speed_left) / 2; // vx in m/s
vy = 0;
vth = (speed_right - speed_left)/lengthBetweenWheels;
//position of the robot
double delta_x = (vx * cos(th)) * dt;
double delta_y = (vx * sin(th)) * dt;
double delta_th = vth * dt; // what is the unit of delta_teta ?
x += delta_x;
y += delta_y;
th += delta_th; // teta should be in radian ?
geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th);
geometry_msgs::TransformStamped odom_trans;
odom_trans.header.stamp = current_time;
odom_trans.header.frame_id = "odom";
odom_trans.child_frame_id = "base_link";
odom_trans.transform.translation.x = x;
odom_trans.transform.translation.y = y;
odom_trans.transform.translation.z = 0.0;
odom_trans.transform.rotation = odom_quat;
//send the transform
odom_broadcaster.sendTransform(odom_trans);
//Odometry message
nav_msgs::Odometry odom;
odom.header.stamp = current_time;
odom.header.frame_id = "odom";
//set the position
odom.pose.pose.position.x = x;
odom.pose.pose.position.y = y;
odom.pose.pose.position.z = 0.0;
odom.pose.pose.orientation = odom_quat;
//set the velocity
odom.child_frame_id = "base_link";
odom.twist.twist.linear.x = vx;
odom.twist.twist.linear.y = vy;
odom.twist.twist.angular.z = vth;
//publish the message
odom_pub.publish(odom);
_PreviousLeftEncoderCounts = tick_x;
_PreviousRightEncoderCounts = tick_y;
last_time = current_time;