Skip to content

Creating Your ROS 2 Package

Your ROS 2 package is the last thing required for a Waypoint submission! It is the source code that will run on the Raspberry Pi in your kit.

ROS 2 lets separate programs communicate using named interfaces. It is not a desktop operating system. A node is one running program with a focused job, a topic is a named stream of messages, and a message type defines the fields and units on that topic.

By the time you finish this guide, your repository should contain a package that:

  • builds with colcon
  • is discoverable through ROS 2 tools
  • installs its launch and configuration files correctly
  • accepts standard Twist movement commands on /cmd_vel
  • turns those commands into bounded motor-driver output for your robot hardware
  • stops on startup, timeout, exception, and shutdown
  • publishes command-based /odom, /path, and TF from odom to base_link
  • publishes real MPU6050 acceleration and gyro data on /imu/data_raw
  • provides a documented base_link -> imu_link relationship
  • works with standard ROS keyboard teleop
  • includes a small autonomous routine you wrote

Make your own code. The pin assignments, package name, motor settings, IMU orientation, and autonomous behavior should come from your own design.

Standard ROS interfaces let teleop, inspection tools, your motor node, and your autonomous node work together without every tool knowing your motor wiring.

Node Input Output Job
Motor driver /cmd_vel (Twist) your motor driver’s real control signals move the chassis safely
IMU physical I2C readings /imu/data_raw (Imu) report acceleration and turn rate
Open-loop odometry /cmd_vel /odom, /path, and odom -> base_link estimate commanded motion
Autonomous routine timing or state /cmd_vel (Twist) make the robot follow your short routine

Teleop and autonomy both publish the same Twist message. Do not run them at the same time unless you deliberately add code to cleanly switch between them.

Phase A: Learn ROS 2 on the computer

Install ROS 2 Jazzy, source it, run official examples, inspect nodes and topics, and read your first message definition.

Phase B: Write your package

Create the package structure, run a persistent first node, learn the message/YAML/launch syntax, write movement and IMU nodes, add teleop compatibility, add an autonomous routine, and build the package.

Use examples to answer a specific question, then write the version that fits your robot:

  • Open the official ROS 2 Python package guide when you need to check package structure, package.xml, setup.py, and Python executables.
  • Open the official Python publisher/subscriber tutorial to identify the Node class, publisher, subscription, callback, timer, rclpy.spin, and main function.
  • Use OrphBot’s example package as the example Waypoint robot package. setup.py for data_files and console_scripts, motor_driver.py for watchdog cleanup structure, odom_publisher.py for nested message assignments, mpu6050_node.py for signed register reads, and simple_auton.py for timer-driven segments. OrphBot’s GPIO pins and tuning values are OrphBot-specific.
  • Terralift is a larger real robot. Its drivetrain, IMU, and open-loop odometry nodes show how the same ideas grow in a more complex project. (This is the real robot I used for my research project!)

Do not rename an example package and submit it. Your submission must be your own! (I will check this…)

Work through these pages in order.

  1. Learn the ROS 2 basics on your computer.
  2. Create your workspace and run a first inspectable node.
  3. Understand messages, parameters, and launch files before writing robot nodes.
  4. Build movement nodes for cmd_vel, motors, odometry, TF, and path.
  5. Publish IMU data from the required sensor.
  6. Add teleop and autonomy through the same movement topic.
  7. Polish your package before submitting it.
  8. Put your package on a robot after the kit is assembled.

For installation commands, use Set Up Ubuntu for ROS 2. Windows users do that in WSL Ubuntu 24.04; Linux users can use their terminal; macOS users should use an Ubuntu 24.04 VM or remote Ubuntu computer.

Start with Learn the ROS 2 basics.