ROS2 r2b3 on raspberry Pi3
===
**ROS2 r2b3** [link](https://github.com/ros2/ros2/wiki/Beta3-Overview)
**goal:** Build ROS2 beta3 on raspberry pi3
**environment:** ubuntuMATE16.04.3
**requirement:**
- base image
- 32GB empty transecond cards
- ubuntu 16.04.2 lenovo x220 laptop to burn image
- 8GB USB drive use for swap memory (maybe could be less)
My hardware
![](https://i.imgur.com/Hw2oSuQ.jpg)
I create the base image follow [The Duckietown project](http://book.duckietown.org/master/duckiebook/duckiebot_ubuntu_image.html#sec:duckiebot-ubuntu-image)
*this is not necessary!*
**Output:**
- ROS2 r2b3
**Original documents**
[link1](https://github.com/ros2/ros2/wiki/Linux-Development-Setup)
[link2-ros1_bridge](https://github.com/ros2/ros1_bridge/blob/master/README.md#build-the-bridge-from-source)
### steps:
Start from base image:
- add swap memory
- Build ros2 source without ros1_bridge
- Build ros1_bridge with single thread
#### Add swap memory
plug in USB drive to your raspberry pi3
check device name
`$sudo fdisk -l`
you may see your usb device as /dev/sdX
like mine is /dev/sda1
![](https://i.imgur.com/wUGhNKE.png)
``` bash=
$ sudo mkswap /dev/sda1
$ sudo swapon /dev/sda1
```
#### Build ros2 source without ros1_bridge
* Install dependency:
``` bash=
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 421C365BD9FF1F717815A3895523BAEEB01FA116
```
```bash=
sudo apt-get update
sudo apt-get install git wget
sudo apt-get install build-essential cppcheck cmake libopencv-dev libpoco-dev libpocofoundation9v5 libpocofoundation9v5-dbg python-empy python3-dev python3-empy python3-nose python3-pip python3-setuptools python3-vcstool python3-yaml libtinyxml-dev libeigen3-dev
# dependencies for testing
sudo apt-get install clang-format pydocstyle pyflakes python3-coverage python3-mock python3-pep8 uncrustify
# Install argcomplete for command-line tab completion from the ROS2 tools.
# Install from pip rather than from apt-get because of a bug in the Ubuntu 16.04 version of argcomplete:
sudo pip3 install argcomplete
# additional testing dependencies from pip (because not available on ubuntu 16.04)
sudo pip3 install flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes
# dependencies for FastRTPS
sudo apt-get install libasio-dev libtinyxml2-dev
```
* Get ROS2.0 code
```bash=
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
vcs-import src < ros2.repos
```
* use ament build all packages without ros1-bridge
```bash=
cd ~/ros2_ws/
src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install --skip-packages ros1_bridge --make-flags -j1
```
then, go to sleep! XD
It took about 4~5hours for native build
#### Build ros1_bridge with single thread
* source environment
```bash=
source /opt/ros/kinetic/setup.bash
cd ~/ros_ws
source install/local_setup.bash
```
* Build ros1_bridge with sigle thread
```bash=
src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install --only ros1_bridge --force-cmake-configure --make-flags -j1
```
took about 1 hour
this step consume lots of memory
Habonbon! Now you get ROS2 on your Pi3!!!
### Image software contain:
ROS2 r2b3
ROS Kinetic
Opencv 3.3.0
### acknowledgement
Thanks these wonderful people for pushing forth!
ROS2 team, [Hunter Allen](https://github.com/allenh1), [鄭聖文Colin Cheng](https://github.com/shengwen1997), [Asier Bilbao](https://github.com/abilbaotm), [duckietown team](http://duckietown.org/classes/index.html) from ETH Zürich 2017 - Prof. Emilio Frazzoli, Dr. Andrea Censi,University of Montreal, 2017 - Prof. Liam Paull;TTIC/UChicago 2017- Prof. Matthew Walter;National Chiao Tung University, Taiwan - Prof. Nick Wang.
##### reference
https://www.slideshare.net/shengwen1997/ros2-cross-compiling
https://github.com/ros2/ros2/issues/378
https://github.com/ros2/ros1_bridge/blob/master/README.md#build-the-bridge-from-source
https://github.com/ros2/ros2/wiki/Linux-Development-Setup
https://groups.google.com/forum/#!topic/ros-sig-ng-ros/Rdm9gq71N78
Failed to load Python extension for LZ4 support. LZ4 compression will not be available
https://github.com/ros2/ros2/wiki/Real-Time-Programming
opencv-3.3.0 on raspberry pi3 [link](https://hackmd.io/s/S1oIlawDb#)
https://github.com/ros2/ros2/pull/412
###### tags: `rpi3` `ros2` `beta3`