[Installation] Building ARMv64 packages with Docker - cpslabor-education/robotwiki GitHub Wiki

Install on latest ubuntu

Note: as of 2021.04.30, these instructions have been tested for Ubuntu 20.04

On host

Install QEMU on host

sudo apt-get install qemu binfmt-support qemu-user-static

Pull docker image:

docker pull arm64v8/ubuntu
docker tag arm64v8/ubuntu:latest ros2-cross-compile/arm64v8

Start docker image

docker run --rm -it -v /mnt/vmpath:/home/user/cross-ws/ -w /root ros2-cross-compile/arm64v8

Commands

Preliminary instructions (locale setup):

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

Add ROS 2 apt repository

apt update && apt install -y curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'

Install packages (apt):

apt update && apt install -y \
  build-essential \
  cmake \
  git \
  libbullet-dev \
  python3-colcon-common-extensions \
  python3-flake8 \
  python3-pip \
  python3-pytest-cov \
  python3-rosdep \
  python3-setuptools \
  python3-vcstool \
  wget

Install libconsole-bridge:

apt install -y libconsole-bridge-dev

Install format packages, like YAML:

apt install libyaml-dev

Install Python packages:

python3 -m pip install -U \
  argcomplete \
  flake8-blind-except \
  flake8-builtins \
  flake8-class-newline \
  flake8-comprehensions \
  flake8-deprecated \
  flake8-docstrings \
  flake8-import-order \
  flake8-quotes \
  pytest-repeat \
  pytest-rerunfailures \
  pytest

Install Fast DDS dependencies

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

Get ROS 2 sources:

cd ~
mkdir -p ./ros2_foxy/src
cd ./ros2_foxy
wget https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos
vcs import src < ros2.repos

If you don't need any visualization, you can ignore the following packages:

touch src/ros2/rviz/COLCON_IGNORE && touch src/ros2/rviz/AMENT_IGNORE
touch src/ros2/demos/COLCON_IGNORE && touch src/ros2/demos/AMENT_IGNORE
touch src/ros/ros_tutorials/COLCON_IGNORE && touch src/ros/ros_tutorials/AMENT_IGNORE
touch src/ros2/ros1_bridge/COLCON_IGNORE && src/ros2/ros1_bridge/AMENT_IGNORE
touch src/ros-visualization/COLCON_IGNORE && touch src/ros-visualization/AMENT_IGNORE

Also, if you rely on FastRTPS, ignore other packages:

touch src/ros2/rmw_connext/COLCON_IGNORE && touch src/ros2/rmw_connext/AMENT_IGNORE
touch src/ros2/rmw_cyclonedds/COLCON_IGNORE && touch src/ros2/rmw_cyclonedds/AMENT_IGNORE
touch src/eclipse-cyclonedds/COLCON_IGNORE && touch src/eclipse-cyclonedds/AMENT_IGNORE

Additionally required packages:

apt install -y libeigen3-dev liblog4cxx-dev python3-numpy

Install some Python3 packages:

pip3 install lark

Initiate building of ROS 2:

colcon build --merge-install

Note on NVIDIA Jetson systems

As of 2021.04.30, NVIDIA has not released JetPack for new Ubuntu releases (only 18.04 supported). Naturally, life must go on as ROS 2 Foxy is recommended for all new development.

You can pull a 18.04 docker release, with the following command:

docker pull arm64v8/ubuntu:bionic
docker tag arm64v8/ubuntu:bionic ros2-cross-compile/arm64v8:bionic

Start docker image

docker run --rm -it -v /home/user/cross-ws/:/mnt/host -w /root ros2-cross-compile/arm64v8:bionic