3. Odometry

[DEPRECATED] Updated Version here.

Odometry information is used to estimate the robot’s position relative to its origin. In order to achieve a robust odometry, Linorobot uses two sources of odometry.

The primary source is the encoders mounted on the motors. Robot’s linear velocity is calculated by counting the change in number of ticks over time and published to /raw_vel topic.

However, the same approach in calculating the robot’s angular velocity could be prone to errors due to noise and wheel slippage. Alternatively, an IMU is used to calculate the robot’s angular velocity by measuring the gyroscope’s rotational speed.

A node subscribed to /raw_imu topic filters out the noise from the IMU using AHRS algorithm through imu_filter_madgwick package . The filtered output is published to /imu/data to provide lino_base_node the robot’s angular speed and reliable IMU data for future nodes that require accelerometer, magnetometer, and gyroscope measurements.

Take note how the data from /raw_imu  is filtered and published as /imu/data.


To know more about publishing odometry information:


3.1 Checking the Odometry Information

3.1.1 Run the launch files and rviz

On the robot’s computer, run bringup.launch:

roslaunch linorobot bringup.launch

On your development computer, open 3 new terminal windows.

Run teleop_twist_keyboard:

rosrun teleop_twist_keyboard teleop_twist_keyboard.py

Subscribe to /odom topic:

rostopic echo odom

Open rviz:

rosrun rviz rviz

Once rviz is open, import odometry.rviz by clicking File > Config and choose ~/catkin_ws/src/lino_visualize/rviz/odometry.rviz.

3.1.2 Check odometry using rostopic

Drive the robot forward and check /odom if the linear velocity in the x axis is approximately equal to the speed defined at teleop_twist_keyboard (ie. 0.5 m/s) as seen below. The linear velocity must be positive as you drive forward and negative as you reverse the robot.


For mecanum drive robot, you’ll need to check the linear velocity in the y axis as well. First you need to strafe the robot by pressing SHIFT + j to strafe leftwards and SHIFT + l to strafe rightwards . This time, check the linear velocity in the y axis. Speed must be approximately equal to the speed defined at teleop_twist_keyboard. Strafing leftwards should return a positive linear velocity and negative when strafing rightwards.

Next, rotate the robot counter clockwise (press ‘j’ from teleop_twist_keyboard) and check /odom if the angular velocity is almost equal to the speed defined at teleop_twist_keyboard (ie. 1 rad/s).

odometry angular

The angular velocity must be positive as you rotate the robot counter clockwise and negative as you rotate the robot clockwise.

3.1.3 Check odometry using rviz

Close all terminals and repeat step 3.1.1 .

Rotate the robot 360 degrees by pressing ‘j’ from teleop_twist_keyboard. Check on rviz if the robot is back to its initial angle.

For Ackermann steering robots – since it can’t rotate in-place, carry the robot and rotate it 360 degrees. Check on rviz if the robot is back to its initial angle. 


Next, drive the robot forward approximately 1m. Check on rviz if the robot’s displacement is ~1m. Each square in rviz is 1 square meter.


Lastly, drive the robot in a square-shaped pattern. Check on rviz if the robot’s location is approximately near its origin. It’s fine it the loop didn’t close as AMCL will correct the robot’s pose eventually.


3.2 Troubleshooting

If linear velocity’s sign is wrong, try swapping the encoder pins as mentioned at 2.3.3 .

If angular velocity’s sign is wrong, check if the IMU is mounted in the correct orientation( X – towards the front, Y- towards left).

If the angular velocity has no reading at all, check IMU’s wiring.

If the displacement of the robot on rviz does not match the actual displacement of the robot, check your robot’s config (linorobot /arduino /firmware/lib /config/lino_base_config.h)

COUNTS_PER_REV = no of ticks per wheel revolution
MAX_RPM = max motor’s RPM
WHEEL_DIAMETER = wheel’s diameter
TRACK_WIDTH = mounting plate’s width

4. Laser Sensor

The robot’s almost ready for autonomy. Time to check your laser sensor. Please proceed to laser sensor page.