# Compute velocities from wheel-encoders for odometry model I am working with the navigation of a two wheeled robot, I am looking at the odometry tutorial www.ros.org/wiki/navigation/Tutorials/RobotSetup/Odom, in this part:

//compute odometry in a typical way given the velocities of the robot
double dt = (current_time - last_time).toSec();
double delta_x = (vx * cos(th) - vy * sin(th)) * dt;
double delta_y = (vx * sin(th) + vy * cos(th)) * dt;
double delta_th = vth * dt;

x += delta_x;
y += delta_y;


it says "A real odometry system would, of course, integrate computed velocities instead"

so, if I have the velocity readings from the wheel encoders, how can I compute this velocities for the odometry model?

Originally posted by salime on ROS Answers with karma: 21 on 2013-07-11

Post score: 1

Comment by Hemu on 2013-07-11:
Can you clearly state the meaning of 'velocity readings from the wheel encoders'? Does it refer to the rpm of each motor or the distance traversed by each wheel per unit time?

Comment by salime on 2013-07-12:
I have the encoder count per second in each wheel, the wheel radius and the distance between these two wheels. I am wondering how can I get the velocity in meters per second with this information.

Comment by hamidoudi on 2014-01-12:
Hello usually computing an odemetry is dependent on the type steering on the robot there are different type of methods for computing velocities from encoder counts first thing I would advice you to do is to read this article and you will then have better starting point.

http://rossum.sourceforge.net/papers/DiffSteer/

thanks In some robots you can't measure velocity directly. Instead, you measure movement (of the motors, for example) and calculate both the new position and velocity from that movement. As an example, the ros_arduino_bridge package does exactly that from the encoder measurements of a differential-drive system.
You can see an example of writing an Odometry message with updated position and velocity based on encoder deltas and publishing the updated transform in lines 146–185 of the base_controller.py file in ros_arduino_bridge: https://github.com/hbrobotics/ros_arduino_bridge/blob/indigo-devel/ros_arduino_python/src/ros_arduino_python/base_controller.py