In this module, you learn to deploy the trained model to the TurtleBot 3 Waffle Pi and see your trained model work in the real world. This module is optional and the following steps are done on the TurtleBot 3 Waffle Pi. If you do not have one, you can stop and skip this module. It is very important to use the model trained in previous module to run on the TurtleBot 3 Waffle Pi.

Time to complete module: 30 minutes
Services used: AWS RoboMaker, Amazon S3, AWS IoT Greengrass

  • Step 1. Build and bundle the robot application

    In this step, you’ll build and bundle the robot application with the trained RL model for the TurtleBot 3 Waffle Pi ARM architecture.

    a. In AWS Cloud9 IDE shell window, execute the following command to download and build a cross-platform container image. This image is used for compiling and bundling a robot application for the TurtleBot ARM architecture. This process takes about 10 minutes to complete.

    cd /opt/robomaker/cross-compilation-dockerfile && sudo bin/build_image.bash
    Cloud9 IDE

    (Click to enlarge)

    Cloud9 IDE

    b. In AWS Cloud9 IDE, go to ObjectTracker/robot_ws/src/object_tracker_robot/config folder, open model_config.yaml file and fill in required information. This file instructs build process to download the trained reinforcement model from your Amazon S3 bucket and put it in the bundle that you deploy to the robot.


    Model config yaml

    (Click to enlarge)

    Model config yaml

    c. In an AWS Cloud9 IDE shell window, execute the following command to create a running container with image downloaded in earlier step. It also enters into container shell so you can build and bundle the robot application for ARMHF architecture.

    docker run -v $(pwd):/robot_ws -v ~/.aws:/root/.aws -it ros-cross-compile:armhf

    d. You are now in the container shell prompt, execute the following command.

    When you build and bundle your application you use rosdep, a tool used for managing dependencies in ROS. This sample application requires libraries that are not in the rosdep’s default sources. This file, along with the first few commands in the next step, will add a rule to rosdep for this library.

    echo "libjpeg62:
      ubuntu:
        xenial: [libjpeg62]" > /etc/ros/rosdep/custom-rules/object-tracker-rules.yaml

    e. In the container shell prompt, execute the following commands. This process takes about 20 minutes.

    echo "yaml file:/etc/ros/rosdep/custom-rules/object-tracker-rules.yaml" > /etc/ros/rosdep/sources.list.d/23-object-tracker-rules.list
    apt-get update
    cd robot_ws
    rosdep update
    rosdep install --from-paths src --ignore-src -r -y
    colcon build
    colcon bundle

    f. The robot application is now built and bundled for ARMHF, the same architecture that is used by the TurtleBot 3 Waffle Pi. The output.tar.gz bundle file is created in the “ObjectTracker/robot_ws/bundle/” folder. The bundle contains the trained reinforcement learning model and the logic that helps the robot use the model in real world.

    output

    (Click to enlarge)

    output

    g. Exit out of the container shell prompt using the “exit” command.


  • Step 2. Upload the robot application

    a. In a AWS Cloud9 IDE shell window, execute the following command to upload the ARM bundle built by the container to your S3 bucket. Be sure to change the S3 bucket name in the command to your S3 bucket.

    aws s3 cp ObjectTracker/robot_ws/bundle/output.tar.gz s3://robomaker-objecttracker-yourinitials/ObjectTracker/output.tar.gz

    b. In the AWS RoboMaker console, select “Robot applications” in the left panel and choose “Create robot application”.

    c. Give the application a name such as “RoboMakerObjectTrackerApplication” and make sure to put the uploaded S3 bundle location in “ARMHF source file” text box.

    Create robot application

    (Click to enlarge)

    Create robot application

    d. In the Robot application page, find the robot application you created earlier and choose “Create new version” for deployment later.

     

    Create new version

    (Click to enlarge)

    Create new version
  • Step 3. Create a deployment

    a. Follow the instructions in “Creating a Robot” to configure your TurtleBot to connect to AWS RoboMaker. When creating the deployment role, make sure to replace the S3 bucket that you created in this tutorial, e.g. robomaker-objecttracker-yourinitials.

    b. Follow instructions in “Creating a Fleet” to set up a fleet to manage robots.

    c. Follow instructions in “Registering and Deregistering Robots” to register your TurtleBot 3 Waffle Pi to the fleet.

    d. In the AWS RoboMaker console, on the left navigation panel, choose “Deployments” then “Create deployment”.

    e. In the “Create deployment” page, select the Fleet, RobotApplication and latest Version you created in earlier steps. Enter “object_tracker_robot” in “Package Name” field and “main.launch” in “Launch file” field. Leave everything else default and choose “Create”.

     

    Create deployment

    (Click to enlarge)

    Create deployment

    f. You can track your deployment in the deployment detail page.

    Congratulations, you have completed the tutorial!