Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Case1: ROS2 Core (Yocto Native) / Galactic
Case2: ROS2 Core (Docker container) / Humble

...

Simple "Hello World" publisher:

View filenameHelloWorld_ROS2.tar.gzheight250


Code Block
languagebash
title1. cross-compile the "Hello World" example with the following script:
linenumberstrue
collapsetrue
#!/bin/bash


#-# path used to install the SDK:
export ROS2_SDK_PATH="/opt/poky/3.1.26_RZV2H_ROS2"

export ROS2_SDK_PATH2=${ROS2_SDK_PATH//\//\\/}


### #######  cross-compilation on a Linux PC

pip install -U colcon-common-extensions


#-# start SDK with
unset LD_LIBRARY_PATH 
source ${ROS2_SDK_PATH}/environment-setup-aarch64-poky-linux

export PYTHONPATH="${ROS2_SDK_PATH}/sysroots/x86_64-pokysdk-linux/usr/lib/python3.8/site-packages"
export PYTHONPATH="${PYTHONPATH}:${ROS2_SDK_PATH}/sysroots/aarch64-poky-linux/usr/lib64/python3.8/site-packages"

export CMAKE_PREFIX_PATH="${ROS2_SDK_PATH}/sysroots/x86_64-pokysdk-linux/usr"
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${ROS2_SDK_PATH}/sysroots/x86_64-pokysdk-linux/usr/lib"
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${ROS2_SDK_PATH}/sysroots/x86_64-pokysdk-linux/usr/lib/cmake"
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${ROS2_SDK_PATH}/sysroots/aarch64-poky-linux/usr"
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${ROS2_SDK_PATH}/sysroots/aarch64-poky-linux/usr/lib64"
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${ROS2_SDK_PATH}/sysroots/aarch64-poky-linux/usr/lib64/cmake"
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${ROS2_SDK_PATH}/sysroots/aarch64-poky-linux/usr/share"

export AMENT_PREFIX_PATH="${ROS2_SDK_PATH}/sysroots/aarch64-poky-linux/usr"
export AMENT_PREFIX_PATH="${AMENT_PREFIX_PATH}:${ROS2_SDK_PATH}/sysroots/aarch64-poky-linux/usr/lib64"
export AMENT_PREFIX_PATH="${AMENT_PREFIX_PATH}:${ROS2_SDK_PATH}/sysroots/aarch64-poky-linux/usr/lib64/cmake"

PKGARGS=""
if [ $# == 1 ] ; then
  PKGARGS="--packages-select $1"
  echo $PKGARGS
fi

#-# ##

cd ros2_ws

cp -f cross.cmake.tmp cross.cmake
sed -i "s/\/opt\/poky\/3.1.31/$ROS2_SDK_PATH2/g" cross.cmake


colcon build --merge-install \
    --cmake-force-configure \
    --cmake-args \
        -DCMAKE_TOOLCHAIN_FILE=${PWD}/cross.cmake \
        -DCMAKE_MAKE_PROGRAM=/usr/bin/make \
        -DENABLE_PRECOMPILED_HEADERS=OFF \
    $PKGARGS

...