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

Using AppImage to deploy cross compiled ROS2 applications

Hi all,

Recently I made a demo for cross compiling a ROS2 application and packaging it as an AppImage.

The steps for cross compiling and packaging a ROS2 based software is as follows:

  • Install a cross compiler
  • Create a sysroot
  • Create a colcon workspace (new folder with a symlink to sources)
  • Invoke colcon, and pass it a toolchain file
  • Bundle the install folder into an AppImage single file

Benefits of using an AppImage are:

  • Single file, like an android APK, easy to distribute / deploy
  • Easy testing different versions of an app side by side
  • For more benefits of using AppImage, see the website of AppImage

The demo is located here:

Hope this might be useful for some people!

7 Likes

Thanks for sharing, I’ll have to try this out. I’ve been using Docker for a similar goal of being able to deploy self-contained images, but this is interesting because it looks like it would allow me to do the same thing without the docker dependency on the deployment machine.

Out of curiosity, what’s your use-case for this, and was there anything that made you choose AppImage over Flatpak or Docker?

My usecase for doing this, is running ROS2 on a CPU which is located in a robot (pretty common I guess for ROS :D).

The cpu is able to build ROS2, but the filesystem is located on eMMC, so it’s not superfast, and does not have infinite write cycles. Also, the CPU is good, but not as fast as my desktop PC. Final point, is that the system does not have mouse/keyboard/display attached. This can off course be solved with VS-code-remote. All-in-all reasons for wanting a proper cross compilation.

What I want, is to develop on my PC, cross compile my application and deploy it on my robot. Several solutions came to mind:

  • Using deb/rpm/opkg: using the package manager of the target makes sense, since you then can deploy a package, and install it, including it’s dependencies. Downside of this approach is that only a single version can be installed. So no easy side by side testing.
  • As you mentioned, docker is another option, but I’m not sure how heavy weight the runtime is. I guess it is pretty light weight, but still it is a bit unclear to me where the application container should be downloaded to.
  • Another option I considered was android APK / iOS app. This is a bundle format which can be started from the home screen. Pretty convenient when testing / deploying. So I wanted a single file solution.

All options above led me to AppImage, which hits a sweet spot:

  • Single file: easy to share, e-mail, archive, deploy
  • Directly executable, single command to launch the app
  • Side by side testing of versions: Start one version, kill it, start another one from a single folder without full re-install or re-compile
  • No daemon / package management: The app is actually an executable with a squashfs appended. It is mounted via libfuse, so this is a runtime dependency.
  • Another advantage might be the option to make your app truly portable. You could in theory bundle the entire ros2 installation with your app. This app will be large, but it will run on many systems. This off course was one of the first reasons for AppImage to emerge. Whether or not this is a good idea in case of ros probably depends.
2 Likes

Interesting, thanks for elaborating!

It is common to cross compile from one system to another especially when building for Embedded system such as a STM32 or Raspberry Pi. For an Embedded Linux platform, or other non native platform, QEMU is another option to build an application on one system for a separate target.
Ex:
https://github.com/ros-tooling/cross_compile

I like the Docker option but even a separate VM on a host would work.

With regards to your eMMC, it should be fairly fast, but any device such as a Solid State Drive, SD card or flash USB drive will have a finite number of writes it is rate for. Thus, if you are using a SSD on your PC to build with, then it will have an issue eventually. It depends on the quality of the drive.

Cheers,

Jon.

I’ve seen the cross_compile project, but did not try it yet. Even the output of this compilation is probably an install folder which can be copied to the target. Even in this case, an AppImage could be created from the install folder, resulting in an executable, app like file.