ros2 on raspberry pi
Hi, I'm trying to cross compile ROS2 Bouncy for a Raspberry pi 3, without success.
I downloaded the raspbian tools from here https://github.com/raspberrypi/tools
I'm using the gcc-linaro-arm-linux-gnueabihf-raspbian-x64
toolchain.
This is my rpi3_toolchain.cmake file
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
# define some paths
set(RASPBERRY_TOOLS_PATH /home/asoragna/repos/raspberrypi3/tools/arm-bcm2708)
set(RASPBERRY_ROOT_FS /home/asoragna/repos/raspberrypi3/rootfs)
set(RASPBERRY_ROS2_WS /home/asoragna/ros2/raspberry_sdk_ws)
# specify the cross compiler
set(CMAKE_C_COMPILER ${RASPBERRY_TOOLS_PATH}/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${RASPBERRY_TOOLS_PATH}/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++)
set(CMAKE_SYSROOT ${RASPBERRY_ROOT_FS})
# where is the target environment
set(CMAKE_FIND_ROOT_PATH
${RASPBERRY_ROOT_FS}
${RASPBERRY_TOOLS_PATH}/gcc-linaro-arm-linux-gnueabihf-raspbian-x64
${CMAKE_CURRENT_LIST_DIR}/install
)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# This assumes that pthread will be available on the target system
# (this emulates that the return of the TRY_RUN is a return code "0"
set(THREADS_PTHREAD_ARG "0"
CACHE STRING "Result from TRY_RUN" FORCE)
Then I build using colcon
colcon \
build \
--merge-install \
--cmake-force-configure \
--cmake-args \
-DCMAKE_TOOLCHAIN_FILE=`pwd`/rpi3_toolchain.cmake \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DTHIRDPARTY=ON \
-DBUILD_TESTING=0
The error I get is in the rcutils
package:
In file included from /home/asoragna/ros2/raspberry_sdk_ws/src/ros2/rcutils/include/rcutils/allocator.h:26:0,
from /home/asoragna/ros2/raspberry_sdk_ws/src/ros2/rcutils/include/rcutils/error_handling.h:31,
from /home/asoragna/ros2/raspberry_sdk_ws/src/ros2/rcutils/src/error_handling.c:22:
/home/asoragna/ros2/raspberry_sdk_ws/src/ros2/rcutils/include/rcutils/macros.h:60:32: error: unknown type name ‘_Thread_local’
#define RCUTILS_THREAD_LOCAL _Thread_local
DO you have any idea about how to solve this issue ? I tried different tutorials on the web but they are quite old and not easily applicable to ros2 bouncy.
I never ran into this issue. But as this is flag not present in your toolchain, can you try to replace the line 60 of macro.h by
To see if that solves the issue ? Does this toolchain support C11?
You can also check out https://github.com/esteve/ros2_raspbi... which is a nice tutorial on cross-compiling for RPi. Or it is the link you were thinking when you said it is not for Bouncy ?
https://github.com/esteve/ros2_raspbi... is not working for Bouncy. I will try asap the change you suggested.
Ok I made the change you suggested, but I get a new error in ament_index_cpp:
arm-linux-gnueabihf-g++: error: unrecognized command line option ‘-std=c++14’
I think this is due to the toolchain being too old
Yeah.. Any reason to use this one instead of a more up to date one ? Can you give the version:
arm-linux-gnueabihf-g++ --version
?arm-linux-gnueabihf-g++ (Linaro GCC 5.2-2015.11-2) 5.2.1 20151005
There are no reasons at all for using it, simply it was the one provided by the official raspbian toolkits repositories.