Skip to content

installing_ros2

Dan Zimmerman edited this page Dec 7, 2024 · 15 revisions

Managing ROS 2 Jazzy Installed From Source

Base Installation

mkdir -p ~/.local/opt/ros/jazzy_ws/src
cd ~/.local/opt/ros/jazzy_ws

Then follow source instructions in that workspace:

https://docs.ros.org/en/jazzy/Installation/Alternatives/Ubuntu-Development-Setup.html#

Obtaining and Building Further Dependencies

The lack of binary packages makes rosdep dependency management more complex. Key packages like ros2_control, ros2_controllers, moveit and so on won't be available, so they also need to be built from source.

Both ros2_control and ros2_controllers host many packages.

We can get the names of required package dependencies with:

rosdep keys --from-paths src --ignore-src -r -y

To get the repositories that correspond to the list of package names, I've put together a script vcsdeps.py here. This looks up the repositories using the rosdistro YAML file for the appropriate $ROS_DISTRO and creates a vcstool .repos file that can be used to bulk-clone the needed repos on the correct branches.

vcsdeps.py usage in the root of a Colcon workspace:

rosdep keys --from-paths src --ignore-src -r -y | xargs | ~/dz_rpi_config/scripts/vcsdeps.py

The output is a ws_deps.repos file that contains the source dependencies:

repositories:
  src/diagnostics:
    type: git
    url: https://github.com/ros/diagnostics.git
    version: ros2
  src/realtime_tools:
    type: git
    url: https://github.com/ros-controls/realtime_tools.git
    version: master
  src/ros2_control:
    type: git
    url: https://github.com/ros-controls/ros2_control.git
    version: master
  src/ros2_controllers:
    type: git
    url: https://github.com/ros-controls/ros2_controllers.git
    version: master
  src/xacro:
    type: git
    url: https://github.com/ros/xacro.git
    version: ros2

Chained Extras Workspace

Instead of adding external deps to my ~/ros2ws workspace or the ~/.local/opt/ros/jazzy_ws core ROS 2 workspace, I'm going to make another for external packages that I need but I don't intend to develop:

mkdir -p ~/.local/opt/ros/jazzy_extras_ws/src

Then we import the ws_deps.repos file from the ros2ws workspace above:

cd ~/.local/opt/ros/jazzy_extras_ws
vcs import < ~/ros2ws/ws_deps.repos

We need to do this AGAIN for the jazzy_extras_ws to pick up the transitive source dependencies (i.e. the ros2_controllers packages further depend on other ROS packages that we need to install from source). Run the vcsdeps.py script again in the jazzy_extras_ws and import the resulting file.

cd ~/.local/opt/ros/jazzy_extras_ws
rosdep keys --from-paths src --ignore-src -r -y | xargs | ~/dz_rpi_config/scripts/vcsdeps.py
vcs import < ws_deps.repos

The output .repos file for the ros2_canopen first-order dependencies above is collapsed below:

vcsdeps.py Output for jazzy_extras_ws
repositories:
  src/ackermann_msgs:
    type: git
    url: https://github.com/ros-drivers/ackermann_msgs.git
    version: ros2
  src/angles:
    type: git
    url: https://github.com/ros/angles.git
    version: ros2
  src/backward_ros:
    type: git
    url: https://github.com/pal-robotics/backward_ros.git
    version: foxy-devel
  src/control_msgs:
    type: git
    url: https://github.com/ros-controls/control_msgs.git
    version: master
  src/control_toolbox:
    type: git
    url: https://github.com/ros-controls/control_toolbox.git
    version: ros2-master
  src/cpp_polyfills:
    type: git
    url: https://github.com/PickNikRobotics/cpp_polyfills.git
    version: main
  src/filters:
    type: git
    url: https://github.com/ros/filters.git
    version: ros2
  src/generate_parameter_library:
    type: git
    url: https://github.com/PickNikRobotics/generate_parameter_library.git
    version: main
  src/kinematics_interface:
    type: git
    url: https://github.com/ros-controls/kinematics_interface.git
    version: master
  src/rsl:
    type: git
    url: https://github.com/PickNikRobotics/RSL.git
    version: main

After the source dependencies are all installed, we can install the system dependencies normally:

rosdep install --from-paths src --ignore-src -r -y

It took about 25 minutes to build the packages listed above on a Raspberry Pi 5.

🐛Debugging

ROS APT Sources

Adding the ROS APT sources doesn't work because $UBUNTU_CODENAME does not exist on Debian Bookworm/Raspbian.

For now just making bookworm explicit:

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 bookworm) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

Locale

Only generating en_GB:

dan@computer:~ $ sudo locale-gen en_US en_US.UTF-8
Generating locales (this might take a while)...
  en_GB.UTF-8... done

So I'm going with

sudo locale-gen en_GB en_GB.UTF-8
sudo update-locale LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF-8
export LANG=en_GB.UTF-8

Says in the instructions:

We test with the following settings. However, it should be fine if you’re using a different UTF-8 supported locale.

Missing Tools

For whatever reason, maybe the locale settings I was missing:

sudo apt update
sudo apt install python3-rosdep \
python3-vcstool \
ros-dev-tools \
-y

💡 I went back and ran this step just in case.