Issues cross-compiling ROS2 for Raspberry Pi

asked 2020-03-06 00:47:52 -0600

McKay gravatar image

updated 2020-03-06 01:00:28 -0600

gvdhoorn gravatar image

I have been having a tonne of trouble trying to cross-compile ROS2 for my raspberry pi model 3 B+ from Ubuntu 18.04 x86. I have, for the most part, been following this guide: https://index.ros.org/doc/ros2/Tutori... with a little bit of help from this guide: http://wiki.ros.org/ROS/CrossCompilin....

What I have done so far:

I have mapped the root directory of my pi to a virtual drive at ~/mnt/pi. I have then imported ros2.repos and github.com/ros-tooling/cross_compile.git according to the first guide. I then set my environment variables to:

export TARGET_ARCH=arm-linux-gnueabihf
export TARGET_TRIPLE=arm-linux-gnueabihf
export CC=/usr/bin/$TARGET_TRIPLE-gcc
export CXX=/usr/bin/$TARGET_TRIPLE-g++
export CROSS_COMPILE=$TARGET_TRIPLE-
export SYSROOT=~/mnt/pi
export ROS2_INSTALL_PATH=~/ros2_pi_ws/ros2_ws/install
export PYTHON_SOABI=cpython-36m-$TARGET_TRIPLE

Then I basically followed the rest of the ROS2 cross-compiling guide and its not working.

The issue:

Aside from some compiler warnings, it looks like CMake is unable to locate the ament_cmake_core package and I can't seem to figure out why and whenever CMake returns an issue like this, setting the CMAKE_PREFIX_PATH doesn't seem to help. Albeit, in this case, I don't know where the config files for the ament_cmake_core package actually are.

I tried using Docker to compile it for aarch64 according to the ROS2 tutorial I linked and it seems to be able to find the packages without a problem. The only things I am changing are the C/C++ compilers, the architecture spec in CMake (TARGET_ARCH) and the root (which now points to the virtual raspberry pi root). Given this, I can't see why the CMAKE_PREFIX_PATH would be the issue, given that the ROS2 application is likely to set this during cross-compilation anyway. Both of my arm-linux C and C++ compilers are version 7.4.0.

Seeing as I can't upload the output in a tex file ( I need 5 points apparently - not sure what that means), here it is:

(base) cde01@cde01:~/ros2_rpi_ws/ros2_ws$ colcon build --merge-install     --cmake-force-configure     --cmake-args         -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON         -DCMAKE_TOOLCHAIN_FILE="$(pwd)/src/ros2/cross_compile/cmake-toolchains/generic_linux.cmake"         -DSECURITY=ON
[4.341s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/cde01/ros2_rpi_ws/ros2_ws/install' in the environment variable AMENT_PREFIX_PATH doesn't contain any 'local_setup.*' files.
Starting >>> ament_package
Starting >>> ament_lint
Starting >>> osrf_testing_tools_cpp
Starting >>> fastcdr
Starting >>> poco_vendor
Starting >>> ament_cppcheck
Starting >>> tinydir_vendor
Starting >>> gtest_vendor                                                                                                                                                                           
Starting >>> osrf_pycommon
Starting >>> tinyxml2_vendor
Starting >>> orocos_kdl
Starting >>> tinyxml_vendor                                                                                                                                                                              
Starting >>> urdfdom_headers
Starting >>> ament_pep8
Starting >>> sqlite3_vendor
[4.932s] WARNING:colcon.colcon_ros.task.ament_python.build:Package 'ament_package' doesn't explicitly install a marker in the package index (colcon-ros currently does it implicitly but that fallback will be removed in the future)
[4.932s] WARNING:colcon.colcon_ros.task.ament_python.build:Package 'ament_package' doesn't explicitly install the 'package.xml' file (colcon-ros currently does it implicitly but that fallback will be removed in the future)
[5.170s] WARNING:colcon.colcon_ros.task.ament_python.build:Package ...
(more)
edit retag flag offensive close merge delete

Comments

Would this not be better posted on the ros-tooling/cross_compile issue tracker?

gvdhoorn gravatar image gvdhoorn  ( 2020-03-06 01:02:28 -0600 )edit