Actual wheels RPM velocities from ticks, target velocity and robot velocity

asked 2018-10-18 05:15:41 -0500

dottant gravatar image

updated 2018-10-18 05:16:59 -0500

Hi all
I'm working on a differential drive robot and I'm a little bit confused about three main things, they seems to work, but i wanna be sure that they re the correct ones.
How to transform the ticks coming from the encoders to the RPM from the single wheels? I have all the parameters like ticks count per rev, wheel radius, wheel distance.
At the moment I'm performing it like this

ticks_current_time = ros::Time::now(); 
ticks_dt = (ticks_current_time - ticks_then).toSec();
ticks_dtm = ticks_dt / 60;
right_ticks_delta_ticks = right_ticks_enc - right_ticks_prev_encoder;
left_ticks_delta_ticks = left_ticks_enc - left_ticks_prev_encoder;
right_ticks_vel_rpm = (right_ticks_delta_ticks / Ticks_per_rev ) / ticks_dtm;
left_ticks_vel_rpm = (left_ticks_delta_ticks / Ticks_per_rev) / ticks_dtm;

How to transform the target velocities linear.x and angular.z coming from /cmd_vel to RPM for the single wheel??
At the moment I'm performing it like this

vel_target_right_rad_sec = ((2*required_linear_x_vel)+(required_angular_vel*Base_width))/(2*(Wheel_diameter/2));
vel_target_left_rad_sec = ((2*required_linear_x_vel)+(-1.0*required_angular_vel*Base_width))/(2*(Wheel_diameter/2));
vel_target_right_rad_minute = (vel_target_right * 60);
vel_target_left_rad_minute = (vel_target_left * 60);
vel_target_right_rpm =  vel_target_right_minute / (pi * 2);
vel_target_left_rpm =  vel_target_left_minute / (pi * 2);

How to transform the ticks reading from the encoders into the actual linear (m/s) and angular (rad/s) velocities of the robot (to compare to the ones coming from /cmd_vel)?
At the moment I'm performing something like this

average_rpm_x = (left_ticks_vel + right_ticks_vel) / 2;
average_rps_x = average_rpm_x / 60;
linear_velocity = (average_rps_x * (Wheel_diameter * pi)); 
average_rpm_a = (right_ticks_vel - left_ticks_vel) / 2;
average_rps_a = average_rpm_a / 60;
angular_velocity = (average_rps_a * (Wheel_diameter * pi)) / Base_width;

Thank you so much in advance!!!

edit retag flag offensive close merge delete


I think you found the solution after all this time. This package named "differential_drive" (link below) does the calculation of individual motor velocities as well as calculating odometry from encoder ticks. Regards

Werewolf_86 gravatar image Werewolf_86  ( 2021-07-26 06:38:15 -0500 )edit