Skip to content

OpenEmbedded Build Instructions

Herb Kuta edited this page Sep 9, 2019 · 25 revisions

OpenEmbedded Build Instructions

Revision: 12 Published: 2019-09-18

These instructions are for building ROS 2 crystal and dashing, and the "core" portion of ROS 1 melodic using OpenEmbedded thud (Yocto 2.6.x) on Ubuntu bionic (18.04). There is also support for building images for the TurtleBot 3 Waffle Pi under ROS 1 melodic.

Additional information on meta-ros can be found in Superflore OE Recipe Generation Scheme.

Build Environment Setup

  1. Install these prerequisites once:

    sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
            build-essential chrpath socat cpio python python3-pip python3-pexpect \
            xz-utils debianutils iputils-ping \
            g++-multilib locales lsb-release python3-distutils time
    sudo locale-gen en_US.utf8
  2. Setup bitbake and OE-Core using a separate disk for the build artifacts (~100GB required if the working files are kept). NOTE: If you have previously done this using the [morty-draft] branch, please start again from scratch.

    mkdir <NEW-PROJECT-DIR>
    cd <NEW-PROJECT-DIR>
    
    # The final branch for OpenEmbedded "thud" is not yet available. In the meantime, use a rebaseable draft of the branch.
    git clone -b thud-draft [email protected]:ros/meta-ros
    mkdir conf
    cp meta-ros/files/*.mcf conf/.
    
    # Clone the OpenEmbedded metadata layers. Select a configuration based on the DISTRO and ROS distro you wish to build:
    # cfg=ros2-crystal.mcf
    # cfg=webos-crystal.mcf
    # cfg=ros2-dashing.mcf
    # cfg=webos-dashing.mcf
    # cfg=ros1-melodic.mcf
    # cfg=webos-melodic.mcf
    meta-ros/scripts/mcf -f conf/$cfg
    
    # oe-init-build-env defaults to using "./build" as the build directory. Bitbake expects to find the "conf" subdirectory under
    # the build directory, so create a symlink there to where we've created it.
    mkdir build
    ln -snf ../conf build/.
    
    # Set up the shell environment for this build and create a conf/local.conf . We expect all of the variables below to be unset.
    unset BDIR BITBAKEDIR BUILDDIR OECORELAYERCONF OECORELOCALCONF OECORENOTESCONF OEROOT TEMPLATECONF
    source openembedded-core/oe-init-build-env
    
    # The current directory is now the build directory; return to the original.
    cd -
    
    # Create a common artifacts directory on the separate disk. The edits to conf/local.conf done below will set TMPDIR to be a
    # subdirectory of it.
    mkdir -p /absolute/path/to/directory/on/separate/disk
  3. Add this to the bottom of conf/local.conf:

    # ROS-ADDITIONS-BEGIN
    # ^^^^^^^^^^^^^^^^^^^ In the future, tools will expect to find this line.
    
    # NB. DISTRO is not set in this file; instead, it is set in conf/bblayer.conf to the Distribution setting in *.mcf .
    
    # Increment this whenever you add or change a setting in this file.
    ROS_LOCAL_CONF_SETTINGS_VERSION = "1"
    
    # Uncomment one:
    # MACHINE = "qemux86"
    # MACHINE = "raspberrypi3"
    
    ROS_COMMON_ARTIFACTS = "/absolute/path/to/directory/on/separate/disk"
    
    DL_DIR = "${ROS_COMMON_ARTIFACTS}/downloads"
    SSTATE_DIR = "${ROS_COMMON_ARTIFACTS}/sstate-cache"
    TMPDIR = "${ROS_COMMON_ARTIFACTS}/BUILD-${DISTRO}-${ROS_DISTRO}"
    # Don't add the libc variant suffix to TMPDIR.
    TCLIBCAPPEND := ""
    
    # As recommended by https://www.yoctoproject.org/docs/2.6.2/mega-manual/mega-manual.html#var-BB_NUMBER_THREADS
    # and https://www.yoctoproject.org/docs/2.6.2/mega-manual/mega-manual.html#var-PARALLEL_MAKE:
    BB_NUMBER_THREADS = "${@min(int(bb.utils.cpu_count()), 20)}"
    PARALLEL_MAKE = "-j ${BB_NUMBER_THREADS}"
    
    # Reduce the size of the build artifacts by removing the working files under TMPDIR/work. Comment this out to preserve them
    # (see https://www.yoctoproject.org/docs/2.6.2/mega-manual/mega-manual.html#ref-classes-rm-work).
    INHERIT += "rm_work"
    
    # Any other additions to the file go here.
    
    # Uncomment to allow "root" to ssh into the device. Not needed for images with webOS OSE because it implicitly adds this
    # feature.
    # EXTRA_IMAGE_FEATURES += "ssh-server-dropbear"
    
    # Uncomment to include the package management utilities in the image ("opkg", by default). Not needed for images with
    # webOS OSE because it implicitly adds this feature.
    # EXTRA_IMAGE_FEATURES += "package-management"
    
    # Uncomment to have all interactive shells implicitly source "setup.sh" (ROS 1) or "ros_setup.sh" (ROS 2).
    # EXTRA_IMAGE_FEATURES += "ros-implicit-workspace"
    
    # vvvvvvvvvvvvvvvvv In the future, tools will expect to find this line.
    # ROS-ADDITIONS-END

Building Images

Various WARNING-s will be issued by bitbake when building these images. They can be ignored.

DISTRO = ros1 or DISTRO = ros2 Images

core-image-ros-roscore

This image contains just the ROS "core".

source openembedded-core/oe-init-build-env
cd -
bitbake core-image-ros-roscore

To include additional packages in this image, append them to the IMAGE_INSTALL variable in conf/local.conf:

IMAGE_INSTALL_append_pn-core-image-ros-roscore = " <PKG1> <PKG2> ..."

Note that the leading space after the opening double-quote is mandatory. See Customizing Images Using local.conf for more information.

core-image-ros-world

By default, this image contains all of the "non-optional" ROS packages. In the future, you will be able to include "optional" ones by setting DISTRO_FEATURES in conf/local.conf. Currently, this image does not build for ROS 1 melodic.

source openembedded-core/oe-init-build-env
cd -
bitbake core-image-ros-world

core-image-ros-turtlebot3-core (ROS 1 melodic on raspberrypi3 only)

This image contains the packages required for the core TurtleBot 3 operation listed here and here. (Note that this is not needed, because the images use root for their user account.)

source openembedded-core/oe-init-build-env
cd -
bitbake core-image-ros-turtlebot3-core

To include additional packages in this image, append them to the IMAGE_INSTALL variable in conf/local.conf:

IMAGE_INSTALL_append_pn-core-image-ros-turtlebot3-core = " <PKG1> <PKG2> ..."

core-image-ros-turtlebot3-all (ROS 1 melodic on raspberrypi3 only)

By default, this webOS OSE image contains all of the non-simulation related turtlebot3- prefixed packages and their prerequisities mentioned in the TurtleBot3 e-Manual. (Note that this is not needed, because the images use root for their user account.)

source openembedded-core/oe-init-build-env
cd -
bitbake core-image-ros-turtlebot3-all

To include additional packages in this image, append them to the IMAGE_INSTALL variable in conf/local.conf:

IMAGE_INSTALL_append_pn-core-image-ros-turtlebot3-all = " <PKG1> <PKG2> ..."

DISTRO = webos Images

webos-image-ros-roscore

This webOS OSE image contains just the ROS "core".

source openembedded-core/oe-init-build-env
cd -
bitbake webos-image-ros-roscore

To include additional ROS packages in this image, append them to the IMAGE_INSTALL variable in conf/local.conf:

IMAGE_INSTALL_append_pn-webos-image-ros-roscore = " <PKG1> <PKG2> ..."

Note that the leading space after the opening double-quote is mandatory. See Customizing Images Using local.conf for more information.

webos-image-ros-world

By default, this webOS OSE image contains all of the "non-optional" ROS packages. In the future, you will be able to include "optional" ones by setting DISTRO_FEATURES in conf/local.conf. Currently, this image does not build for ROS 1 melodic.

source openembedded-core/oe-init-build-env
cd -
bitbake webos-image-ros-roscore

webos-image-ros-turtlebot3-core (ROS 1 melodic on raspberrypi3 only)

By default, this webOS OSE image contains the packages required for the core TurtleBot 3 operation listed here and here.

Note that this is not needed, because the images use root for their user account.

source openembedded-core/oe-init-build-env
cd -
bitbake webos-image-ros-turtlebot3-core

To include additional ROS packages in this image, append them to the IMAGE_INSTALL variable in conf/local.conf:

IMAGE_INSTALL_append_pn-webos-image-ros-turtlebot3-core = " <PKG1> <PKG2> ..."

webos-image-ros-turtlebot3-all (ROS 1 melodic on raspberrypi3 only)

By default, this webOS OSE image contains all of the non-simulation related turtlebot3- prefixed packages and their prerequisities mentioned in the TurtleBot3 e-Manual.

Note that this is not needed, because the images use root for their user account.

source openembedded-core/oe-init-build-env
cd -
bitbake webos-image-ros-turtlebot3-all

To include additional ROS packages in this image, append them to the IMAGE_INSTALL variable in conf/local.conf:

IMAGE_INSTALL_append_pn-webos-image-ros-turtlebot3-all = " <PKG1> <PKG2> ..."

Image Sanity Testing

For now, only the barest minimum sanity testing is done on these images:

ROS 1 Sanity Test

# ping lge.com
# source /opt/ros/melodic/setup.sh
# roscore &
...
started core service [/rosout]
# rosnode list
/rosout
# rosnode info /rosout
--------------------------------------------------------------------------------
Node [/rosout]
Publications:
* /rosout_agg [rosgraph_msgs/Log]

Subscriptions:
* /rosout [unknown type]

Services:
* /rosout/get_loggers
* /rosout/set_logger_level

contacting node http://127.0.0.1:34643/ ...
Pid: 1363

ROS 2 Sanity Test

Note that without a network connection, there's no output from ros2 topic echo /chatter.

# ping lge.com
# source ros_setup.sh
# ros2 topic list
/parameter_events
/rosout

# ros2 msg list
...

# (sleep 5; ros2 topic pub /chatter std_msgs/String "data: Hello world") &
# ros2 topic echo /chatter
publisher: beginning loop
publishing #1: std_msgs.msg.String(data='Hello world')

data: Hello world

publishing #2: std_msgs.msg.String(data='Hello world')

data: Hello world

webOS OSE Sanity Test

The webOS OSE menu must appear after pressing the Windows key and allow the settings for Network to be launched.

TurtleBot 3 Sanity Test

Follow the TurtleBot 3 Bringup Instructions. If the message:

[WARN] [<timestamp>]: Failed to get param: timeout expired

appears, restart turtlebot3_bringup and try again.

Usage Notes

  • If you previously had been building from the now deleted [morty-draft] branch, please start again from scratch.

  • The images are placed in TMPDIR/deploy/images/MACHINE. We've found balenaEtcher to be an excellent tool for flashing them to SD cards.

  • These images default to being non-production: the root account has no password.

  • When using the core-image-ros-* images on a raspberrypi3, the login prompt appears only on the HDMI display, not on the serial port. The opposite is true when using webos-image-ros-* images.

  • When using the webos-image-ros-* images, press the Windows key to bring up the webOS OSE menu. Navigate to the network settings page to discover the IP address assigned by DHCP to the Ethernet connection, and its MAC address. Once you know the MAC address of a connection, you can use ip neigh from another Linux machine to discover it's IP address.

  • If you have not added ros-implicit-workspace to IMAGE_FEATURES, you must set up a ROS workspace explicitly by issuing:

    source /opt/ros/ROS_DISTRO/setup.sh       # ROS 1
    source ros_setup.sh                       # ROS 2
  • When using the webos-image-ros-* images, you can arrange for per-device configuration by attaching a USB flash drive containing an executable rc.local script under USBROOT/webos-device-config/v1. If present, it will be run by the /etc/rc.local on the device. An example rc.local script can be found under meta-ros/files/examples/webos-device-config/v1.

  • The *.mcf files do not pin the commit of meta-ros; to update it to its current head, issue:

    # Select the configuration you are building:
    # cfg=ros2-crystal.mcf
    # cfg=webos-crystal.mcf
    # cfg=ros2-dashing.mcf
    # cfg=webos-dashing.mcf
    # cfg=ros1-melodic.mcf
    # cfg=webos-melodic.mcf
    meta-ros/scripts/mcf -f conf/$cfg
    
    # If there happens to be a new version of $cfg in meta-ros, update conf/$cfg and rerun:
    diff meta-ros/files/$cfg conf/. || {
      cp meta-ros/files/$cfg conf/.
      meta-ros/scripts/mcf -f conf/$cfg
    }
  • WiFi does not work "out-of-the-box" on the core-image-ros-* images.

  • WiFi does not work when running webOS OSE images on the B+ model of the Raspberry Pi 3. The symptom is that Network Configuration spins forever waiting for the list of SSIDs to appear.

  • If a webOS OSE image is booted without a display connected, start up is delayed (systemd waits for 90s for a event that never arrives because luna-surfacemanager has crashed).

TurtleBot 3 Waffle Pi with webOS OSE Usage

There is no need to compile packages on the TurtleBot 3. The webos-image-ros-turtlebot3-all image contains all of the packages that exist in ROS1 melodic needed to run the examples in the TurtleBot3 e-Manual -- except those related to simulation and the visualization applications (eg RViz, rqt), which must continue to be run on a remote PC. (Also note that turtlebot3-follower does not run due to a missing dependency.)

For example, the SLAM application can be run on the TurtleBot 3 by issuing the usual command, adding the option not to launch RViz:

# roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping open_rviz:=false

The other two SLAM methods available in ROS 1 melodic, cartographer and karto can also be specified.

Tips

  • If you add ros-implicit-workspace to IMAGE_FEATURES, then you won't have to issue source /opt/ros/ROS_DISTRO/setup.sh every time you login.
  • If your TurtleBot 3 has a Raspberry Pi 3 model B instead of a B+, we recommend creating a device configuration USB flash drive so that when the TurtleBot 3 starts up, it's connected to a WiFi network. You can use the example in meta-ros/files/examples/webos-device-config/v1/rc.local as a starting point. Remember to change its file mode to be executable.

Change Log

Revision 12

  • Push (unforced) to [thud-draft] to publish numerous changes, in particular:
    • Added support for creating images for the TurtleBot 3 Waffle Pi under ROS 1 melodic:
      • There are core-image-ros-turtlebot3-core and webos-image-ros-turtlebot3-core images that contain the packages required for the core TurtleBot 3 operation listed here and here.
      • There are core-image-ros-turtlebot3-all and webos-image-ros-turtlebot3-all images that contain all of the non-simulation related turtlebot3- prefixed packages in ROS 1 melodic and their prerequisities mentioned in the TurtleBot3 e-Manual
    • Per-device configuration using a USB flash drive can be done when using webOS OSE images.
    • The recipes for ROS 1 melodic were regenerated from its 2019-09-10 release.
    • The Raspberry Pi video camera is now enabled.
  • Convert the items under Build Environment Setup to numbered steps.
  • Add instructions for building the TurtleBot 3 images, a TurtleBot 3 sanity test, and a section on its usage.

Revision 11

  • Force push to [thud-draft] to publish numerous changes, in particular:
    • *-roscore images can be built for ROS 1 melodic. Note that you must set the environment variable ROS_IP or ROS_HOSTNAME before source-ing setup.sh if the machine will be communicating with remote ROS nodes.
    • The recipes for ROS 2 crystal were regenerated based on its 2019-09-05 release.
    • webOS OSE images now continuously synchronize the machine's time with time.google.com. Previously, it was only set once at startup.
    • webOS OSE images now have all of the kernel modules installed. Previously, only a portion were.
    • webOS OSE images for qemux86 now have linux-yocto v4.18.
    • core-image-ros-* images now contain connman, which means that Etherent networking is automatically started. (However, WiFi isn't; add an item mentioning this under Usage Notes.)
  • Add instructions for building ROS 1 melodic images.
  • Document various values for EXTRA_IMAGE_FEATURES that can be set in conf/local.conf.

Revision 10

  • Push (unforced) a commit that enables the Ethernet connection when running webOS OSE images on the B+ model of the Raspberry Pi 3; however, the Wi-Fi remains broken. Add an item to this effect under Usage Notes.
  • Add ping lge.com to the sanity test to confirm that networking is working.

Revision 9

  • Clarify that the build environment setup instructions are for a new project without any settings in the environment of variables used by openembedded-core/oe-init-build-env.

Revision 8

  • Update for the migration to OpenEmbedded thud.
  • Update for the support of ROS 2 dashing.
  • Add lines that delimit the additions made to conf/local.conf. Introduce ROS_LOCAL_CONF_SETTINGS_VERSION to track the version of the settings.
  • Reduce the size of the build artifacts by adding the setting to conf/local.conf that causes rm_work to be inherited globally.
  • Drop the PARALLEL_MAKE_pn-pcl setting in conf/local.conf as the calculation of the value for PARALLEL_MAKE has been added to the recipe for pcl.
  • Add an Image Sanity Testing section.

Revision 7

  • Drop setting DISTRO in conf/local.conf. It's now set in conf/bblayser.conf to the Distribution setting in *.mcf.
  • Add instructions on how to include additions ROS packages to the *-ros-core images.
  • Add more usage notes.

Revision 6

  • Problems have been observed when TMPDIR is shared between ROS_DISTRO-s => include -${ROS-DISTRO} in its value.
  • Fix typo.

Revision 5

  • Update the plans for ROS 2 dashing support.
  • Simpify and clarify the build setup instructions. Also make them more robust.
  • Add a note on to how update meta-ros.
  • Fix typos.

Revision 4

  • Revise for the inclusion of mcf in meta-ros.
  • Add support for using webOS OSE as the OpenEmbedded DISTRO.

Revision 3

  • Add a step to install the prerequisites.
  • Add instructions to build for Raspberry Pi.
  • Fix typo.

Revision 2

  • Drop setting SSTATE_MIRRORS because meta-ros adds global environment variables that invalidates even the shared state for native packages.
  • Specify a PARALLEL_MAKE_pn-pcl setting so that building pcl doesn't take nearly 3 hours.
  • Fix typos.

Revision 1

  • Initial publication.
Clone this wiki locally