Skip to content

Cross-compilation docker repository for ROS/ROS2 robot application using colcon for AWS Robomaker deployment to armhf/arm64 respectively

License

Notifications You must be signed in to change notification settings

carpit680/cross-compilation-docker

Repository files navigation

cross-compilation-docker

Cross-compilation docker repository for ROS robot application using colcon for AWS Robomaker deployment to armhf or arm64.

This page describes in detail the entire process of building and bundling a robot application using colcon for AWS Robomaker deployment.

Some Context

AWS Robomaker requires a ROS robot application bundle specific to the robot architecture and this bundle is created using colcon.

The robot in our case is either an armhf or an arm64(backward compatible with armhf and so this document focuses on armhf from now on) based and to build and bundle our application for armhf on an amd64 host we usually use AWS’s cross-compilation docker(follow The Alternative steps to use that) but it occasionally doesn’t work due to any buggy software updates and so, we have the option to follow the steps given below to set up the cross-compilation docker on any amd64 Linux host to be independent of the AWS platform for development and further reduce the costs. This comes with a downside regularly having to update the repository manually but also gives reliability.

Pre-requisites

  • amd64 based Linux host

  • ROS package

Note: Use foxy-arm64 branch for ROS2 foxy on aarch64.

  • All other pre-requisites are installed in the steps given below. Skip whatever is already installed.

Setup

  1. Install git and Wget if not already installed.
    sudo apt install \
        git \
        wget \
        qemu \
        binfmt-support \
        qemu-user-static
  1. Use quick install script for docker.
    wget -O docker_install.sh https://get.docker.com && chmod 755 docker_install.sh && ./docker_install.sh
  1. This step will execute the registering scripts.
    sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes 
  1. Clone cross-compilation repository.
    git clone https://github.com/carpit680/cross-compilation-docker
  1. Clone your ROS package if not done already.
   git clone <link-to-your-ros-package> 
  1. Go to the cross-compilation directory.
    cd cross-compilation-docker/
  1. Build cross-compilation docker image and set up all the necessary components.
    sudo bash bin/build_image.bash

Building and Bundling

Now that the cross-compilation docker is set up, we will start building and bundling the robot application.

  1. Go to your ROS workspace.
    cd /path/to/your/ros/workspace
  1. Run the cross-compilation docker and mount the workspace as ws.
    sudo docker run -v $(pwd):/ws -it ros-cross-compile:armhf
  1. Go to the workspace inside the docker container
    cd ws
  1. Update the repositories.
    apt update
  1. Install all the required dependencies for your ROS package.
    rosdep install --from-paths src --ignore-src -r -y
  1. Build the package and store the resultant build and install files in relevant folders.
    colcon build --build-base armhf_build --install-base armhf_install
  1. Bundle the package and store the resultant build, bundle, and install files in relevant folders.
    colcon bundle --build-base armhf_build --install-base armhf_install --bundle-base armhf_bundle --apt-sources-list /opt/cross/apt-sources.yaml
  1. Exit the Docker container.
    exit
  1. Rename the output.tar file to .armhf.tar
    mv amrhf_bundle/output.tar armhf_bundle/<bundle-name>.armhf.tar

Now, upload this robot application bundle to your S3 bucket to create a robot application for your specific architecture.

The alternative

The only other alternative at the time of compiling this document is using AWS’s own cross-compilation docker that has similar(at least at the time of writing) building and bundling steps as my method is based on AWS’s method itself. Their method would be more up-to-date but at times not reliable and it would definitely cost us in terms of money.

AWS instructions for cross-compilation for ARMHF:

    cd /opt/robomaker/cross-compilation-dockerfile/
    sudo bin/build_image.bash      
    cd /path/to/your/ros/workspace
    sudo docker run -v $(pwd):/ws -it ros-cross-compile:armhf
    cd ws
    apt update
    rosdep install --from-paths src --ignore-src -r -y
    colcon build --build-base armhf_build --install-base armhf_install
    colcon bundle --build-base armhf_build --install-base armhf_install --bundle-base armhf_bundle --apt-sources-list /opt/cross/apt-sources.yaml
    exit

Now, copy the robot application bundle to your S3 bucket and give it an apt name with the armhf.tar extension.

aws s3 cp armhf_bundle/output.tar s3://<s3-bucket-name>/<bundle-name>.armhf.tar

About

Cross-compilation docker repository for ROS/ROS2 robot application using colcon for AWS Robomaker deployment to armhf/arm64 respectively

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages