Writing our Odometry
- Boon Pin
- Jan 21, 2017
- 3 min read
Hey readers, welcome back to another progress update of our project! This week we will be talking about writing our own Odometry.
An Odometry is the use of data from motion sensors to estimate change in position over time. It is used in robotics by some legged or wheeled robots to estimate their position relative to a starting location.
There are 3 steps to calculate the position of the robot.

1. Converting encoder data to motor speed
Firstly, the Arduino must read the data from the encoders on the Roboclaw Motor Driver. These data are in units of ticks per seconds. The Arduino must convert these data into speed in metre per seconds. The circumference of the wheel, in this case 0.622metres, will be required in the calculation.
1 revolution = 176128 ticks
Speed = circumference of wheel * revolutions moved per second
= circumference of wheel * (ticks moved per second /
176128)
= 0.622 * (ticks moved per second / 176128)
With the formula derived from the calculation above, the team is able to calculate out the speed. The ticks moved per second is the data read from the Roboclaw Motor Driver. For example, if the Arduino reads 300000 ticks moved per second from the Roboclaw,
Speed = circumference of wheel * (ticks moved per second /
176128)
= 0.622 * (300000 / 176128)
1.06 metres per seconds
Based on the example above, if the Arduino were to read 300000 ticks moved per second, the robot would have moved 1.06 metres per second.
2. Convert motor speed to robot speed
Motor speed doesn’t represent the robot speed. The speed and direction of individual motor affects the speed of the robot. The calculation below shows the formula for converting motor speed to robot speed.
Vx is the linear x velocity of the robot in m/s
Vz is the angular velocity of the robot in rad/s
right_speed is the speed of the right motor in m/s
left_speed is the speed of the left motor in m/s
Wheel distance is the distance between your 2 wheel in metres
X-axis is the position of the robot on the X-axis m/s
Y-axis is the position of the robot on the Y-axis in m/s
THETA is the heading of the robot in radian

Vx = (left_speed + right_speed) / 2
Vz = [ (right_speed - left_speed) / Wheel distance ] *π180
3. Calculate position of the robot
time changed = current time - previous time
THETA = (Vz * time changed) + THETA
X-axis = (Vx * cos (THETA) * time changed) + X-axis
Y-axis = (Vx * sin (THETA) * time changed) + X-axis
previous time = current time
For example, if the left wheel were to move at 0.5m/s, right wheel at 0.1m/s, the wheel distance is 0.31m, robot moving for 2 seconds and the robot is starting at its origin (0,0), by substituting into the formula above:
Vx = (0.5 + 0.1) / 2
= 0.3 m/s
Vz = [ (right_speed - left_speed) / Wheel distance ] *π180
= [ (0.5 - 0.1) / 0.31 ] *π180
= 0.023 rad/s
Time changed = 2 - 0
= 2 sec
THETA = (Vz * time changed) + THETA
= 0.023 * 2 + 0
= 0.046 rad
X-axis = (Vx * cos (THETA) * time changed) + X-axis
= ( 0.3 * cos (0.046) * 2 ) + 0
= 0.166 m
Y-axis = (Vx * sin (THETA) * time changed) + X-axis
= 0.577 m
Therefore, in this example, the robot position is (0.166, 0.577) and THETA is 0.046 rad.
And that is how we calculate the position of the robot. All these maths must have hurt your brain. Alright, lets give your brain a break and we will see you next week. :)
Comments