ROS2 is composed of several layers. Some have been modified to be able to run on microcontroller. Here is a summary of the main difference between the ROS2 stack and the RIOT-ROS2 stack :
|ROS Client Library bindings||rclc|
|ROS Client Library||rcl|
|ROS IDL Generators||generator_c|
|ROS IDL Type Support||introspection_c|
|ROS IDL Interfaces||common_interfaces|
All examples should be able to handle any RMW implementation (see Usage).
sudo apt install cmake git python3-pip python3-empy g++-multilib pip3 install vcstool
If pyparsing is not installed :
pip3 install pyparsing
If your arm-none-eabi-gcc is too old (< gcc 5) :
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa sudo apt-get update sudo apt install gcc-arm-embedded
Required for RIOT (native) :
sudo apt install libc6-dev-i386
Required for ROS2 :
sudo dnf install cmake git python3-pip python3-empy python3-pyparsing pip3 install vcstool # if g++ is not already installed sudo dnf install gcc-c++
Required for RIOT (native) :
sudo dnf install glibc-devel.i686
Please, follow the requirements for ros2 official installation instructions.
Get the sources
mkdir -p ~/ros2_riot_ws/src cd ~/ros2_riot_ws wget https://raw.githubusercontent.com/astralien3000/riot-ros2/master/ros2.repos wget https://raw.githubusercontent.com/astralien3000/riot-ros2/master/ament2riot.cmake vcs import src < ros2.repos
Some downloaded package are not supported, you may run these commands to disable them :
Two build phase
ROS2 and RIOT have 2 very different build systems. To be able to use them together, you need to build applications in 2 steps : using Ament, as a ROS2 user would normally do (but in the case of cross compilation), and then compiling each application for it's target microcontroller with RIOT's Makefiles.
First phase :
cd ~/ros2_riot_ws ./src/ament/ament_tools/scripts/ament.py build --symlink-install --cmake-args -DCMAKE_TOOLCHAIN_FILE=`pwd`/ament2riot.cmake
After that, you can go to the second build phase.
Linux native 2nd build phase example
First, setup the tap interface :
On a first terminal :
(cd install/talker_c && make PORT=tap0 all term)
On a second terminal :
(cd install/listener_c && make PORT=tap1 all term)
Board to Linux example
This example have been tested with a samr21-xpro, but should work with any RIOT-supported board that can communicate via UART with a computer.
Setup the tap interface :
To flash the board, and enable the serial link :
(cd install/talker_c && make BOARD=samr21-xpro PORT=tap0 flash term)
To run the native application :
(cd install/listener_c && make BOARD=native PORT=tap1 all term)
listener_c apps should be seamlessly switchable between the board and native.
If this command fails :
> ./install/RIOT/dist/tools/tapsetup/tapsetup creating tapbr0 RTNETLINK answers: File exists
Maybe it's because you already called it. It is not supposed to be called twice.