ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ros2 on raspberry pi

asked 2018-09-21 13:01:12 -0600

alsora gravatar image

updated 2018-09-21 13:57:51 -0600

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.

edit retag flag offensive close merge delete

Comments

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

#define RCUTILS_THREAD_LOCAL_PTHREAD 1
#undef RCUTILS_THREAD_LOCAL

To see if that solves the issue ? Does this toolchain support C11?

pokitoz gravatar image pokitoz  ( 2018-09-24 03:26:55 -0600 )edit

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 ?

pokitoz gravatar image pokitoz  ( 2018-09-24 03:35:56 -0600 )edit
1

https://github.com/esteve/ros2_raspbi... is not working for Bouncy. I will try asap the change you suggested.

alsora gravatar image alsora  ( 2018-09-24 10:21:23 -0600 )edit

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

alsora gravatar image alsora  ( 2018-09-24 11:41:45 -0600 )edit

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 ?

pokitoz gravatar image pokitoz  ( 2018-09-24 11:46:06 -0600 )edit

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.

alsora gravatar image alsora  ( 2018-09-24 12:06:52 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2018-09-24 16:45:41 -0600

alsora gravatar image

updated 2018-09-25 11:15:23 -0600

I solved all my issues by using an up to date version of arm-linux-gnueabihf-g++. Thank you @pokitoz for your help.

On the Raspberry, with Raspbian Stretch, this is the compiler which is already installed

# arm-linux-gnueabihf-g++ --version
arm-linux-gnueabihf-g++ (Raspbian 6.3.0-18+rpi1+deb9u1) 6.3.0 20170516

So I installed it on my laptop https://packages.ubuntu.com/search?ke...

$ sudo apt-get install g++-6-arm-linux-gnueabihf

There exists also a more recent version (7.2) but I have not tried if it works.

This is the rpi_toolchainfile.cmake

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc-6)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++-6)

set(CMAKE_FIND_ROOT_PATH
  ${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)

This is the running script

colcon \
    build \
    --merge-install \
    --cmake-force-configure \
    --cmake-args \
    -DCMAKE_TOOLCHAIN_FILE=`pwd`/rpi_toolchainfile.cmake \
    -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
    -DTHIRDPARTY=ON \
    -DBUILD_TESTING=0 \
    -DCMAKE_BUILD_RPATH="`pwd`/build/poco_vendor/poco_external_project_install/lib/;`pwd`/build/libyaml_vendor/libyaml_install/lib/"
edit flag offensive delete link more

Comments

Great! So you stopped using a sysroot file? Or the new toolchain you are using already have the rasbian sysroot?

pokitoz gravatar image pokitoz  ( 2018-09-25 04:33:13 -0600 )edit

Yes, apparently is not required. This is something I will investigate for sure, as when I cross compiled ros for another system I didn't manage to make it work without the sysroot

alsora gravatar image alsora  ( 2018-09-25 10:35:04 -0600 )edit

Yes, the python dependencies are hard to meet without a sysroot. Or you need to ignore the python packages.

pokitoz gravatar image pokitoz  ( 2018-09-25 10:46:11 -0600 )edit

I'm ignoring python and test packages

alsora gravatar image alsora  ( 2018-09-25 11:15:39 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2018-09-21 13:01:12 -0600

Seen: 1,910 times

Last updated: Sep 25 '18