Hardware

ROS

What is ROS?

ROS (Robot Operating System) is a flexible framework for writing robot software. It provides tools, libraries, and conventions that simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms.


When to use ROS?

  • Actuator
  • Controller
  • Sensor

Installation

ROS 2 VersionOperating System
ROS 2 Jazzy JaliscoUbuntu Linux 24.04, Windows 10
ROS 2 Humble HawksbillUbuntu Linux 22.04, Windows 10

Set Locale

$ locale  # check for UTF-8

$ sudo apt update && sudo apt install locales
$ sudo locale-gen en_US en_US.UTF-8
$ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
$ export LANG=en_US.UTF-8

$ locale  # verify settings

Setup Sources

You will need to add the ROS 2 apt repository to your system.

First ensure that the Ubuntu Universe repository is enabled.

$ sudo apt install software-properties-common
$ sudo add-apt-repository universe

Now add the ROS 2 GPG key with apt.

$ sudo apt update && sudo apt install curl -y
$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key \
-o /usr/share/keyrings/ros-archive-keyring.gpg

Then add the repository to your sources list.

$ echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \
http://packages.ros.org/ros2/ubuntu $(. \
/etc/os-release && echo $UBUNTU_CODENAME) main" \
| sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

Install development tools (optional)

If you are going to build ROS packages or otherwise do development, you can also install the development tools:

$ sudo apt update && sudo apt install ros-dev-tools

Install ROS 2

First of all, no matter which ROS 2 version you need, run this command first:

$ sudo apt upgrade

ROS 2 Jazzy for Ubuntu 24.04

$ sudo apt install ros-jazzy-ros-base
$ sudo apt install ros-jazzy-desktop
# or
$ sudo apt install ros-jazzy-desktop-full

ROS 2 Humble for Ubuntu 22.04

$ sudo apt install ros-humble-ros-base
$ sudo apt install ros-humble-desktop
# or
$ sudo apt install ros-humble-desktop-full

Uninstall

$ sudo apt remove ~nros-* && sudo apt autoremove

Environment Setup

Sourcing the Setup Script

Set up your environment by sourcing the following file:

$ source /opt/ros/humble/setup.bash

CLI Commands

If you need get a specific command help, for example:

$ ros2 pkg create -h

ROS 2 has a comprehensive set of command-line tools accessible through the ros2 command. Here's a list of the main ROS 2 commands:

Core Commands:

  • ros2 pkg: Package management commands
  • ros2 node: Commands for ROS 2 nodes
  • ros2 topic: Commands for ROS 2 topics
  • ros2 service: Commands for ROS 2 services
  • ros2 action: Commands for ROS 2 actions
  • ros2 interface: Commands for ROS 2 interfaces
  • ros2 param: Commands for ROS 2 parameters
  • ros2 launch: Launch ROS 2 nodes from launch files
  • ros2 run: Run ROS 2 executables
  • ros2 daemon: ROS 2 daemon commands
  • ros2 component: Commands for ROS 2 components
  • ros2 lifecycle: Commands for lifecycle nodes

Development Commands:

  • ros2 doctor: Check ROS 2 setup and identify issues
  • ros2 wtf: Alternative name for doctor command
  • ros2 msg: Commands for ROS 2 message definitions
  • ros2 srv: Commands for ROS 2 service definitions
  • ros2 test: Run ROS 2 tests
  • ros2 bag: Commands for ROS 2 bags (data recording/playback)

Build System:

  • ros2 pkg create: Create a new ROS 2 package
  • ros2 pkg executables: List package executables
  • ros2 pkg list: List installed packages
  • ros2 pkg prefix: Output the prefix path of a package
  • ros2 pkg xml: Output the XML of a package

$
Previous
Raspberry Pi