ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

ROS2 Cross compilation


#1

Hi,

Following the multiple discussions around the cross-compilation of ROS2, I would like to combine all the effort under the same topic.

There are a couple of different link regarding the cross-compilation (for arm architecture):

The different instructions are using the same tools to achieve the cross-compilation:

  • a cmake toolchainfile
  • docker/chroot + qemu to prepare the target filesystem
  • docker as environment for the cross-compilation

To simplify the life of the people who would like to cross-compile ros2 and concentrate the contribution on this topic at one place, I would like to:

  • create a “ROS2 Cross-compilation” page with the instructions under ros index tutorials (I will do the PR in the coming days)
  • push the required files on the ros2/crosscompile repo (Docker files + cmake toolchainfile)

how does it sound ?
Please give me your opinions on this and any suggestions are welcome !


ROSCon 2018 Informal Meetings of Special Interest Groups
#2

I agree 100%.

It would be nice to include in the repository some subdirectories for the most common platforms, containing scripts for creating a sysroot and cross-compiling.

I think that this is the biggest lack of the current tutorial: the provided instructions are easy to translate to other architectures as long as you don’t use a sysroot.

In any case I will be happy to contribute to this new repository!

EDIT: I just noticed this post from the ROSCon meetups


#3

I agree as well. It would be so nice if there were a general guide to “cross-compile ROS2” for other platforms (RTOS as well).
I’m searching something on web about this topic but I found the same links which you already presented.
Could you let us know? thank you so much


#4

Thanks for your support on this !

Here some news of my progress:

I’m almost done with the tutorial page. I add some general information about CMake and cross-compilation.

I’m still thinking on the best way to upstream the cross-compilation related files. The last idea is to create a ros2/crosscompile repo, which will contains a package with the same name.
This repo will come by default with a COLCON_IGNORE, allowing us to add it to the ros2.repos file. Native compilation will not be affected, and cross-compilation would be possible by simply removing this file.
This approach allows us to add a script to generate the sysroot with colcon, before the other packages.

Regarding the cross-compilation itself, I still have to ignore the following packages:

touch
ros2_ws/src/ros2/rviz/COLCON_IGNORE
ros2_ws/src/ros2/demos/intra_process_demo/COLCON_IGNORE
ros2_ws/src/ros2/demos/image_tools/COLCON_IGNORE
ros2_ws/src/ros2/robot_state_publisher/COLCON_IGNORE

@Silvia, I think support for RTOS is a more complicate topics than just cross-compilation. You will probably find more info on this if you look for “embedded ROS2” topics, like this one ROS2 Embedded SIG meeting


#5

@lmayencourt additional request from my team:

Could we have an example of cross-compiling an application against a pre-built ROS2 (for example, to cross-compile https://github.com/ros-perception/vision_opencv without having to cross-compile ROS2 along with it)?


#6

good point, I will see what I can add regarding this !


#7

@Silvia, @lmayencourt, We have created and implementation of the rmw layer using Micro XRCE-DDS, a middleware specific for microcontrollers. Regarding the cross-compiling topic here I think you may want to check how we cross-compile part of the ROS 2 stack into an STM32, using an RTOS like NuttX.

The RTOS and cross-compilation interesting parts are in this repository (Following NuttX way):

It is a WIP project so any feedback, idea or question will be helpful.


#8

Thank you all so much. I’ll investigate on your suggested links and If I 'll find something useful, I’m goint to share with you.


#9

@BorjaOuterelo I can’t find a .cmake file to cross-compiling ROS2 in NuttX in your microROS/apps link. Is there? how do you perform the cross-compilation?


#10

Please, have a look at the first version of the cross-compile repo.
Note that this is a temporary location for the repo ! We want to move this under ros2/cross-compile.

The following PR add the documentation and the repo to ros2.repos:



#11

@Silvia.

In that case, NuttX build system is a set of plain makefiles.
We have a makefile calling colcon with a cross-compilation toolchain.
In this link:

You can find the makefile and the related toolchain file.
I think those are the files you may be interested.