Skip to content

Instantly share code, notes, and snippets.

@fjctp
Last active February 20, 2019 04:37
Show Gist options
  • Save fjctp/221163f84596616d7adea39e00427166 to your computer and use it in GitHub Desktop.
Save fjctp/221163f84596616d7adea39e00427166 to your computer and use it in GitHub Desktop.
Build ROS 2 crystal for raspberry pi

Reference

Setup locale (optional, should be default)

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

Add ROS2 apt repo

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

Install packages

ROS 2

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

Fast-RTPS

sudo apt install --no-install-recommends -y \
  libasio-dev \
  libtinyxml2-dev

Get ROS 2 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 crystal -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69 rti-connext-dds-5.3.1 urdfdom_headers python3-lark-parser"

Ignore some packages

cd ~/ros2_ws/
touch \
  src/ros-perception/laser_geometry/COLCON_IGNORE \
  src/ros/resource_retriever/COLCON_IGNORE \
  src/ros2/geometry2/COLCON_IGNORE \
  src/ros2/urdf/COLCON_IGNORE \
  src/ros2/demos/COLCON_IGNORE \
  src/ros2/kdl_parser/COLCON_IGNORE \
  src/ros2/ros1_bridge/COLCON_IGNORE \
  src/ros2/orocos_kinematics_dynamics/COLCON_IGNORE \
  src/ros2/examples/rclpy/COLCON_IGNORE \
  src/ros2/robot_state_publisher/COLCON_IGNORE \
  src/ros2/rviz/COLCON_IGNORE \
  src/ros2/rcl/rcl/test/COLCON_IGNORE \
  src/ros2/urdfdom/COLCON_IGNORE \
  src/ros2/system_tests/COLCON_IGNORE \
  src/ros2/rosidl_typesupport_opensplice/COLCON_IGNORE \
  src/ros2/rosidl_typesupport_connext/COLCON_IGNORE \
  src/ros2/rmw_connext/COLCON_IGNORE \
  src/ros2/rmw_opensplice/COLCON_IGNORE \
  src/ros2/common_interfaces/visualization_msgs/COLCON_IGNORE \
  src/ros2/common_interfaces/stereo_msgs/COLCON_IGNORE \
  src/ros-planning/COLCON_IGNORE \
  src/ros-visualization/COLCON_IGNORE

Increase swap size

sudo nano /etc/dphys-swapfile

Change CONF_SWAPSIZE to 2000

Restart service

sudo systemctl restart dphys-swapfile

Build ROS 2

cd ~/ros2_ws/
colcon build --symlink-install --packages-ignore qt_gui_cpp rqt_gui_cpp

Install argcomplete

sudo apt install python3-argcomplete

Example

. ~/ros2_ws/install/local_setup.bash
ros2 run demo_nodes_cpp talker
. ~/ros2_ws/install/local_setup.bash
ros2 run demo_nodes_py listener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment