Koder Heaven

Hello World

Ros2 Setup

Add the needed apt repositories for debian:

sudo apt update && sudo apt install curl
curl http://repo.ros2.org/repos.key | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'

Install dev-tools:

sudo apt update && sudo apt install -y \
  build-essential \
  cmake \
  git \
  python3-colcon-common-extensions \
  python3-pip \
  python-rosdep \
  python3-vcstool \

# some pip packages for testing
sudo -H python3 -m pip install -U \
  argcomplete \
  flake8 \
  flake8-blind-except \
  flake8-builtins \
  flake8-class-newline \
  flake8-comprehensions \
  flake8-deprecated \
  flake8-docstrings \
  flake8-import-order \
  flake8-quotes \
  pytest-repeat \

#fastRTPS dependencies
sudo apt install --no-install-recommends -y \
  libasio-dev \

Get the ROS2 code:

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
vcs import src < ros2.repos

install dependencies using rosdep

sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro bouncy -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 rti-connext-dds-5.3.1 urdfdom_headers"

To shorten build-time on the raspberry pi ignore a few packages that are not needed:

cd ~/ros2_ws/
touch src/ros2/demos/COLCON_IGNORE
touch src/ros2/examples/COLCON_IGNORE
touch src/ros2/geometry2/COLCON_IGNORE
touch src/ros2/kdl_parser/COLCON_IGNORE
touch src/ros2/orocos_kinematics_dynamics/COLCON_IGNORE
touch src/ros2/realtime_support/COLCON_IGNORE
touch src/ros2/rmw_connext/COLCON_IGNORE
touch src/ros2/rmw_opensplice/COLCON_IGNORE
touch src/ros2/robot_state_publisher/COLCON_IGNORE
touch src/ros2/ros1_bridge/COLCON_IGNORE
touch src/ros2/rosidl_typesupport_connext/COLCON_IGNORE
touch src/ros2/rosidl_typesupport_opensplice/COLCON_IGNORE
touch src/ros2/rviz/COLCON_IGNORE
touch src/ros2/system_tests/COLCON_IGNORE
touch src/ros2/tlsf/COLCON_IGNORE
touch src/ros2/urdf/COLCON_IGNORE
touch src/ros2/urdfdom/COLCON_IGNORE
touch src/ros2/common_interfaces/actionlib_msgs/COLCON_IGNORE
touch src/ros2/common_interfaces/diagnostic_msgs/COLCON_IGNORE
touch src/ros2/common_interfaces/geometry_msgs/COLCON_IGNORE
touch src/ros2/common_interfaces/nav_msgs/COLCON_IGNORE
touch src/ros2/common_interfaces/sensor_msgs/COLCON_IGNORE
touch src/ros2/common_interfaces/shape_msgs/COLCON_IGNORE
touch src/ros2/common_interfaces/stereo_msgs/COLCON_IGNORE
touch src/ros2/common_interfaces/trajectory_msgs/COLCON_IGNORE
touch src/ros2/common_interfaces/visualization_msgs/COLCON_IGNORE

touch src/ros/COLCON_IGNORE
touch src/ros-perception/COLCON_IGNORE
touch src/ros-planning/COLCON_IGNORE
touch src/eProsima/COLCON_IGNORE

change to workspace-root and build it.

cd ~/ros2_ws/
colcon build --symlink-install

TIPP: I recommend installing tmux and just let it build in background, because it still can take a while. Also this list might not be complete. I’ll had to try it a few times. I might try it out again and then update it.

After it has build source it:

source install/local_setup.bash

The ros2 command should be available now.

and create an overlay for your own packages. This just makes your files more organized and not every package gets checked if it was built already:

mkdir -p ~/overlay_ws/src
cd ~/overlay_ws/

In this overlay your packages will be placed.