[How-to Article] Get started with ROS on Yocto

1 Introduction

ROS is a set of software libraries and utilities that help users build robotic applications. A ROS distribution is a versioned set of ROS packages. These are akin to Linux distributions (e.g. Ubuntu) and is primarily tested on Ubuntu. Consequently, it is fully tested with the specific Ubuntu versions. Users can install and run ROS on any Unix-based platform.

Questions or problems may arise when integrating certain solutions. These issues are usually related to compatibility or the lack of compatible versions in some libraries. The best way to ensure success is to use the right version of Ubuntu as recommended by the ROS and ROS2 Distribution, or to use fully-tested ROS on specific hardware and products provided by a hardware vendor. Both methods ensure that the ROS infrastructure runs smoothly.

2 Using ROS on the Advantech RSB-3720

HW Introduction:

RSB-3720 fulfills the needs of diverse vertical applications through a UIO40-Express expansion design.

  • NXP Arm® Cortex®-A53 i.MX8M Plus Quad/Dual up to 1.8 GHz
  • Onboard LPDDR4 4 GB/6 GB and 4000MT/s memory
  • HDMI 1920x1080 at 60Hz, 1 x Single or 1 x Dual Channel 24 bit LVDS (or 1 x 4-Lane MIPI-DSI by Software modification)
  • 1 x 4-wire RS-232/422/485, 1 x USB 3.2 Gen 1 By 1, 1 x USB2.0, 1 x Micro SD, 1 x Mic. in/Line out
  • 1 x mini-PCIe for 3G/4G, 1 x M.2 2230 Key E slot
  • Supports Yocto Project Linux and Android
  • Supports I/O expansion boards via UIO40-Express

3 Use eMMC or SD to boot up the system

There are two methods for booting the OS with RSB-3720. The first is to boot from an SD card and the second is to boot via eMMC. Users conducting an ROS development evaluation may find it easier to use the SD card when flashing the firmware from the build server or PC.

Boot strap SW1-1 SW1-2 SW1-3 SW1-4
SD ON ON OFF OFF
eMMC OFF ON OFF OFF

A. SD Boot
RSB-3720_SD_Card_boot_up_2021-10-28_132021

B. eMMC boot
RSB-3720_eMMC_boot_up_2021-10-28_132058

C. Debug port connection and setting:
RSB-3720 debug port is shared with COM1. Please connect the debug console cable, then connect the USB-to-RS232 cable to your PC terminal. Connect the cable to COM1 pin header next to the HDMI connector. RSB-3720 can communicate with a host server using serial cables. Common serial communication programs such as HyperTerminal, Tera Term, or PuTTY can be used in such applications. Please set the baud rate to 115200.
RSB-3720_connector_location_2021-10-21_143853

4 Environment setup for BSP and building instructions

Advantech has reduced the process required to build an environment and image to 3 steps:

  1. Visit our AIM-Linux developer center and select the related BSP based on the silicon platform
  2. Follow the “One Step Build Image” method to download the script
  3. Flash the build image to SD card and boot it from the SD card
    This method reduces the effort required of engineers during environment setup and helps them address problems as they arise. This task only requires the user to have a local PC or virtual machine in the cloud — all the other necessary elements can be found on the internet. Users should use a powerful PC or virtual machine with SSD to quicken the process. Likewise, if the user has access to Azure VM service, they can complete the task in the cloud using a flash image stored on a local SD card via a PC or notebook. We will detail instructions on how to use these tools for both Linux and Windows later in this instructional.

Docker setup in host
Users can setup a virtual build machine with Ubuntu system in the Azure Cloud Service or in a local build machine.

Docker installation instructions
A. Prepare the container environment on the build machine. Choose Ubuntu 18.04 as the OS for the following instructions.
A-1 Update the APT package index and install packages to allow APT to use a repository over HTTPS:

$sudo apt-get update
$sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

A-2 Add Docker’s official GPG key

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

A-3 set up the stable repository and install docker engine

$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

B. Use the docker image made by Advantech from dockerhub

$ docker pull advrisc/u18.04-imx8lbv1
$ export CONTAINER_NAME=rsb-3720
$ mkdir adv-release-bsp
$ export WORKSPACE=~/adv-release-bsp
$ docker run --privileged -it --name ${CONTAINER_NAME} -v ${WORKSPACE}:/home/adv/adv-release-bsp -v /dev:/dev advrisc/u18.04-imx8lbv1 /bin/bash

5 Building instructions

Use the following operations when entering the docker container environment shell:

5.1 Prepare BSP and include the ROS meta layer

# update CA certificates
$ sudo apt-get install apt-transport-https ca-certificates -y
$ sudo update-ca-certificates
$ export GIT_SSL_NO_VERIFY=1
$ repo init -u https://dev.azure.com/advcharles/IMX-Robot/_git/adv-arm-yocto-bsp -b imx-linux-zeus -m imx8LBVA0271_robot.xml
$ repo sync
$ ln -s sources/meta-robot-platform/imx/meta-robot/tools/setup-imx-robot.sh setup-imx-robot.sh

As you can see, the meta-robot-platform has been included in the BSP. Users can start building their own robot firmware with the version of ROS they’ve specified. They can choose ROS1 melodic or kinetic, or ROS2 foxy, for example.

$ DISTRO=imx-robot-xwayland MACHINE=imx8mprsb3720a1 source setup-imx-robot.sh -r melodic -b imx8mprsb3720a1-robot-melodic
$ bitbake imx-robot-system
$ DISTRO=imx-robot-xwayland MACHINE=imx8mprsb3720a1 source setup-imx-robot.sh -r kinetic -b imx8mprsb3720a1-robot-kinetic
$ bitbake imx-robot-system
$ DISTRO=imx-robot-xwayland MACHINE=imx8mprsb3720a1 source setup-imx-robot.sh -r foxy -b imx8mprsb3720a1-robot-foxy
$ bitbake imx-robot-system

5.2 Flash the image and extend the rootfs space.

Please copy the image to you host pc or notebook.

$ scp charles@desktop:~/adv-release-bsp/imx8mprsb3720a1-robot-melodic/tmp/deploy/images/imx8mprsb3720a1/imx-robot-system-melodic-imx8mprsb3720a1-20220309072100.rootfs.wic.bz2 .

A. Linux
Choose a uDisk name to replace /dev/sdx. Similar to /dev/sdc, users should avoid using the system disk or important storage disks.

$ sudo dd if=./imx-robot-system-melodic-imx8mprsb3720a1-20220309072100.rootfs.wic.bz2 of=/dev/sdx

B. Windows
Users can choose balenaEtcher to flash the image to their Windows OS. Alternatively, they can choose Linux version one. Linux version one operation is similar to the Windows version when using the Linux Desktop GUI.

5.3 Tips and workarounds for build failure for nxp8987 SDK support and source mirror settings:

A. Please also add MACHINE_FEATURES_remove = " nxp8987 " and remove source mirror part in your local.conf file of build folder to prevent build failure

B. Please include orb-slam2 into the image by adding IMAGE_INSTALL_append = " orb-slam2 " to use slam demo

C. If you need to reserve your disk space, you can add feature INHERIT += “rm_work” in your local.conf file of build folder.

6 Launch camera in ROS (USB camera only — MIPI cameras are not currently supported)

ROS1 remains a popular choice for robotic applications. Therefore, we will demonstrate the use of ROS1. The version we use in this instructional is based on Melodic distribution. We will demonstrate how to launch the USB camera node. This demonstration will also show camera previews on your HDMI display — which is an ROS node.

$ source /opt/ros/melodic/setup.bash
$ roscore&
$ roslaunch usb_cam usb_cam-test.launch

7 SLAM Demostration

You can find the necessary materials in the links below

$ mono_euroc /home/root/catkin_ws/src/orb-slam/Vocabulary/ORBvoc.txt Examples/Monocular/EuRoC.yaml mav0/cam0/data Examples/Monocular/EuRoC_TimeStamps/MH01.txt

Follow the link below for an instructional video:
https://advantecho365-my.sharepoint.com/:v:/g/personal/charles_huang_advantech_com/EdrI6_stpmVJt-BxSV-jAOkBUunl-EpFWeJ1ZSu3mdXZhg?e=uQWW6u

8 Conclusion

Users who are familiar with ROS development will discover that ROS integrates well within Ubuntu systems. This is because ROS is widely used for the development of robotic solutions on Ubuntu x86 architecture. Conversely, arm-based platforms usually provide embedded Linux — like Yocto OS — as default, and since embedded Linux is famous for providing a framework that enables end users to design their own OS from building blocks, it is more difficult to install and develop with ROS platforms. Advantech’s BSP is fully-integrated with ROS. ROS developers can focus on developing the ROS applications and spend their efforts designing low power consumption robotic solutions without struggle and/or confusion. This will further help reduce the costs of arm-based platform development and the associated trouble.

7 Likes