Get Started Guide

  • 2021.3
  • 10/21/2021
  • Public Content

Build New and Custom Docker* Images from the Edge Insights for Autonomous Mobile Robots SDK

This tutorial covers:
  • Creating custom Docker* images by adding or removing components in the Docker* files provided in the SDK
  • Creating custom Docker* images from the custom base images you just created
  • Creating completely new Docker* images by selecting components from the Docker* files provided in the SDK

Create a Customized Docker* Image

  1. Go to the SDK root folder, and choose the environment folder for your customized Docker* file:
    cd <edge_insights_for_amr_path>/Edge_Insights_for_Autonomous_Mobile_Robots_<version>/<env_folder_name>/
    Where the <version> is similar to 2021.3 as shown below:
    cd <edge_insights_for_amr_path>/Edge_Insights_for_Autonomous_Mobile_Robots_2021.3/<env_folder_name>
  2. Open the Docker* file from the environment folder in your preferred Integrated Development Environment (IDE), and append component-specific installation instructions in the appropriate place:
    cd amr_ubuntu2004_ros2_foxy_sdk_env/ && chmod 777 Dockerfile
    Here is an example of appending the Wandering application in amr_ubuntu2004_ros2_foxy_sdk_env/Dockerfile:
    ################################# Gazebo adding Ariac world Start ######################################## WORKDIR ${HOME_DOCKER_USER} RUN mkdir gazebo_world COPY ./gazebo_world ${HOME_DOCKER_USER}/gazebo_world RUN chmod +x ${HOME_DOCKER_USER}/gazebo_world/model_copy_script.sh \ && ${HOME_DOCKER_USER}/gazebo_world/model_copy_script.sh \ && rm -rf ./gazebo_world ################################# Gazebo adding Ariac world End ########################################## ################################# Wandering app START ##################################### WORKDIR ${WORKSPACE_DIR}/Wandering COPY Wandering . WORKDIR ${WORKSPACE_DIR}/Wandering/src RUN source /opt/ros/${ROS_DISTRO}/setup.bash && source ${ROS2_WS}/install/setup.bash && source /opt/intel/openvino_2021.2.200/bin/setupvars.sh \ && colcon build --cmake-clean-first --packages-select wandering_app object_detection --install-base ./prebuilt_wandering \ --cmake-args -DBUILD_TESTING=OFF && rm -rf build log ################################# Wandering app END ##################################### ####################################### Cleanup START ###################################################### RUN rm -rf /var/lib/apt/lists/* RUN rm -rf /root/.cache RUN echo -e "#!/bin/bash \n\ source "${ROS_INSTALL_DIR}/setup.bash" \n\ source "${ROS2_WS}/install/setup.bash" \n\ " > ${WORKSPACE_DIR}/ros_entrypoint.sh # All users should have rwx permissions to workspace RUN chmod -R 777 ${WORKSPACE_DIR} RUN chmod -R 777 ${DATA_SAMPLES_DIR} ####################################### Cleanup END ###################################################### ################################# Setup Entrypoint START ##################################### # !!!NOTE: This shell be last block!!! WORKDIR ${WORKSPACE_DIR} COPY docker_entrypoint.sh ../ ENTRYPOINT ["../docker_entrypoint.sh"] CMD ["/bin/bash"] ################################# Setup Entrypoint END #####################################
  3. Copy the Wandering, FastMapping, and gazebo_world folders from Edge_Insights_for_Autonomous_Mobile_Robots<version> to the amr_ubuntu2004_ros2_foxy_sdk_env folder and remove object_detection:
    $>> sudo scp –r <edge_insights_for_amr_path>/Edge_Insights_for_Autonomous_Mobile_Robots<version>/Wandering . $>> sudo scp –r <edge_insights_for_amr_path>/Edge_Insights_for_Autonomous_Mobile_Robots<version>/FastMapping . $>> sudo scp –r <edge_insights_for_amr_path>/Edge_Insights_for_Autonomous_Mobile_Robots<version>/gazebo_world . $>> sudo rm -rf Wandering/src/object_detection
  4. Build the Docker* image with the modified Docker* file:
    $>>docker build --tag 'amr-ubuntu2004-ros2-foxy-sdk:<tag_name> ' --build-arg http_proxy='<http_proxy>' --build-arg https_proxy='<https_proxy>' --file ./Dockerfile .
  5. To see the details of the built image:
    $>>docker images | grep -i amr-ubuntu2004-ros2-foxy-sdk
  6. Run the required, newly-installed application from within the container (see Run a ROS 2 Sample Application in the Docker* Container for details).

Create a Customized Docker* Image from the Custom Base Image

Because the customized Docker* image you just created can be the base image for the next image, provide base_image as build-arg in the docker-build command in order to build the next image with a new base image. For example, if you build amr-ubuntu2004-ros2-foxy-sdk:latest and you want to build image amr-ubuntu2004-openvino-sdk:latest, this is where the base image is used in the Docker* file:
# INTEL CONFIDENTIAL # Copyright 2021 Intel Corporation. # This software and the related documents are Intel copyrighted materials, and # your use of them is governed by the express license under which they were # provided to you ("License"). Unless the License provides otherwise, you may # not use, modify, copy, publish, distribute, disclose or transmit this # software or the related documents without Intel's prior written permission. # This software and the related documents are provided as is, with no express # or implied warranties, other than those that are expressly stated in the # License. SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
To build image amr-ubuntu2004-openvino-sdk:latest, run:
$>> cd amr-ubuntu2004-ros2-foxy-sdk $>> docker build --build-arg base_image='amr-ubuntu2004-ros2-foxy-sdk:<tag_name>' --tag 'amr-ubuntu2004-openvino-sdk:<tag_name>' --build-arg http_proxy='<http_proxy>' --build-arg https_proxy='<https_proxy>' --file ./Dockerfile .

Create New Docker* Images with Selected Applications from the SDK

This is an example of installing GStreamer* on top of the ros2-foxy base image.
These are the recommended blocks in the Docker* file:
  • The block for setting the eiforamr user and environment variables for common use
  • The block for common tools that are needed by multiple components
  • The GStreamer* block
  • The block for cleaning up and setting up the entry point
These blocks can be customized or removed.
  1. You must pick ros2-foxy as the base image to reliably install the components selected from the SDK. Create a Docker* file, described below as an example:
    # INTEL CONFIDENTIAL # Copyright 2021 Intel Corporation. # This software and the related documents are Intel copyrighted materials, and # your use of them is governed by the express license under which they were # provided to you ("License"). Unless the License provides otherwise, you may # not use, modify, copy, publish, distribute, disclose or transmit this # software or the related documents without Intel's prior written permission. # This software and the related documents are provided as is, with no express # or implied warranties, other than those that are expressly stated in the # License. FROM ros:foxy AS base SHELL ["/bin/bash", "-xo", "pipefail", "-c"] USER root ################################# ENV-Vars START ################################# # User name (eiforamr) can be changed while building docker image with # --build-arg DOCKER_USER="<user>" ARG DOCKER_USER=eiforamr ARG DOCKER_USER_UID=9876 ARG DOCKER_USER_GROUPS=sudo,video,audio,plugdev # define env vars to be used by 1: All layered dockerfiles, 2: By docker_entrypoint.sh ENV ROS_DISTRO foxy ENV ROS_INSTALL_DIR /opt/ros/${ROS_DISTRO} ENV DOCKER_USER ${DOCKER_USER} ENV HOME_DOCKER_USER /home/${DOCKER_USER} # ros2_ws should be utilized for ros2 components only. ENV ROS2_WS ${HOME_DOCKER_USER}/ros2_ws # workspace folder is for intel components and for user playground. ENV WORKSPACE_DIR ${HOME_DOCKER_USER}/workspace ENV DATA_SAMPLES_DIR ${HOME_DOCKER_USER}/data_samples ENV MEDIA_SAMPLES_DIR ${DATA_SAMPLES_DIR}/media_samples RUN useradd --create-home --shell /bin/bash --gid root --uid ${DOCKER_USER_UID} --groups ${DOCKER_USER_GROUPS} ${DOCKER_USER} RUN passwd -d root RUN passwd -d ${DOCKER_USER} RUN echo "${DOCKER_USER} ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/${DOCKER_USER} RUN mkdir -p $ROS2_WS RUN mkdir -p $ROS2_WS/src RUN mkdir -p ${DATA_SAMPLES_DIR} RUN mkdir -p ${MEDIA_SAMPLES_DIR} COPY artifacts/multimedia/* ${MEDIA_SAMPLES_DIR}/ RUN chmod 777 -R ${MEDIA_SAMPLES_DIR} RUN mkdir -p ${WORKSPACE_DIR} ################################# ENV-Vars END ################################# ################################# Common-tools/pkgs START ################################# # Common dev tools and packages RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -q -y --allow-downgrades \ apt \ wget=1.20.3-1ubuntu1 \ libboost-filesystem1.71-dev \ libboost-thread1.71-dev \ automake=1:1.16.1-4ubuntu6 \ libtool=2.4.6-14 \ unzip=6.0-25ubuntu1 \ bash-completion=1:2.10-1ubuntu1 \ udev=245.4-4ubuntu3* \ curl \ && rm -rf /var/lib/apt/lists/* # setup Python ENV PYTHON_VER python3.8 RUN apt-get update && apt-get install -y python3-pip python3-venv && rm -rf /var/lib/apt/lists/* RUN ${PYTHON_VER} -m pip install --upgrade pip RUN pip3 install pyyaml requests ################################### Commont Tools END #################################### ################################# gstreamer START ##################################### RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -q -y \ libgstreamer1.0-0=1.16.2-2 \ gstreamer1.0-tools=1.16.2-2 \ gstreamer1.0-plugins-base=1.16.2-4 \ gstreamer1.0-plugins-good=1.16.2-1ubuntu2.1 \ gstreamer1.0-plugins-bad=1.16.2-2.1ubuntu1 \ gstreamer1.0-plugins-ugly=1.16.2-2build1 \ gstreamer1.0-plugins-base-apps=1.16.2-4 \ gstreamer1.0-libav=1.16.2-2 \ gstreamer1.0-qt5=1.16.2-1ubuntu2 \ gstreamer1.0-gl=1.16.2-4 \ gstreamer1.0-x=1.16.2-4 \ && rm -rf /var/lib/apt/lists/* ################################# gstreamer END ##################################### ####################################### Cleanup START ###################################################### RUN rm -rf /var/lib/apt/lists/* RUN rm -rf /root/.cache RUN echo -e "#!/bin/bash \n\ source "${ROS_INSTALL_DIR}/setup.bash" \n\ source "${ROS2_WS}/install/setup.bash" \n\ " > ${WORKSPACE_DIR}/ros_entrypoint.sh # All users should have rwx permissions to workspace RUN chmod -R 777 ${WORKSPACE_DIR} RUN chmod -R 777 ${DATA_SAMPLES_DIR} ####################################### Cleanup END ###################################################### ################################# Setup Entrypoint START ##################################### # !!!NOTE: This shell be last block!!! WORKDIR ${WORKSPACE_DIR} COPY docker_entrypoint.sh ../ ENTRYPOINT ["../docker_entrypoint.sh"] CMD ["/bin/bash"] ################################# Setup Entrypoint END #####################################
  2. Build a new image with GStreamer*:
    $>>cd amr-ubuntu2004-ros2-foxy-sdk $>>docker build --tag 'amr-ubuntu2004-ros2-foxy-cherry-pick:latest' --build-arg http_proxy='<http_proxy>' --build-arg https_proxy='<https_proxy>' --file ./Dockerfile.cherry-pick . => … => … => [20/24] RUN echo -e "#!/bin/bash \nsource "/opt/ros/foxy/setup.bash" \nsource "/home/eiforamr/ros2_ws/install/setup.bash" \n" > /home/eiforamr/workspace/ros_entrypoint.sh 0.3s => [21/24] RUN chmod -R 777 /home/eiforamr/workspace 0.4s => [22/24] RUN chmod -R 777 /home/eiforamr/data_samples 0.3s => [23/24] WORKDIR /home/eiforamr/workspace 0.0s => [24/24] COPY docker_entrypoint.sh ../ 0.0s => exporting to image 1.5s => => exporting layers 1.4s => => writing image sha256:c375afccf0bf2a4648f436facc0a4eafab9384d23b970c5a4576cff45a7f6989 0.0s => => naming to docker.io/library/amr-ubuntu2004-ros2-foxy-cherry-pick:latest 0.0s
  3. To see the details of the built image:
    $>>docker images | grep -i amr-ubuntu2004-ros2-foxy-<new_image_identifier>
  4. Run the required, newly-installed application from within container (see Run a ROS 2 Sample Application in the Docker* Container for details).

Summary

In this tutorial, you learned how to build new and custom Docker* images from the Edge Insights for Autonomous Mobile Robots SDK.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.