ROS2 Based Tasks – USE ROS2 HUMBLE
Task 1: Odometry Publisher from Simulated Wheel Encoder Ticks
Objective:
Simulate realistic robot behavior by implementing differential drive odometry computation
using encoder tick values — similar to real hardware scenarios.
Background:
You are provided with a ROS2 Python node that simulates a differential drive robot by
publishing cumulative wheel encoder ticks on the following topics:
• /left_wheel_ticks (std_msgs/Int32)
• /right_wheel_ticks (std_msgs/Int32)
These ticks increase as if the robot is moving forward. In actual robots, these ticks come
from encoders attached to the wheels. The purpose of this task is to help you simulate and
understand the motion model of a robot using basic odometry.
Instructions:
• Create a ROS2 package (Python/C++) named odom_computation.
• Write a Python node:
• Subscribes to:
o /left_wheel_ticks
o /right_wheel_ticks
• Publishes to:
o /odom using nav_msgs/msg/Odometry
• Calculates the robot's pose (x, y, theta) and velocity using differential drive logic.
• Use the following robot parameters:
o wheel_radius = 0.065 meters
o wheel_base = 0.21 meters
o ticks_per_revolution = 512
• Convert heading (theta) into quaternion for the orientation field in the
Odometry message.
• Update the Odometry message at 10 Hz.
Expected Behavior:
• The /odom topic should begin publishing once the node starts running.
• The published odometry message should reflect forward motion (i.e., increasing x
over time, y ≈ 0, and constant theta ≈ 0).
• Orientation must be published in quaternion format (converted from heading
theta).
• Both pose and twist fields in the message should contain valid data.
• To verify correctness, use the following command:
ros2 topic echo /odom --once
or:
ros2 topic echo /odom
to monitor continuous updates.
1
Optional (Bonus Task):
• Implement an additional ROS2 node named imu_publisher.py that simulates
basic IMU data and publishes to /imu/data using sensor_msgs/msg/Imu.
o Populate fields like linear acceleration and angular velocity with realistic or
synthetic values.
o Use zero/noise-free data or simulated movement patterns.
o This can help test IMU integration for future localization pipelines.
References:
1. Odometry Message Structure
nav_msgs/Odometry documentation
2. IMU Message Format
sensor_msgs/Imu documentation
3. Quaternion Conversion
tf_transformations in Python
4. ROS2 Python Publisher/Subscriber Example
Writing a Simple ROS2 Python Publisher and Subscriber