Robot Control using Raspberry Pi

Lecture 1 - AWS Academy and Virtulaztion using Docker

Li Bai

Temple University

September 9, 2023

Mangdang

A quadruped robot dog originated from a stanford project click here

  • software development is done using AWS Robomaker and AWS Cloud 9
    • Virtualization, Docker, Linux, Python 3
    • Robot Operating System (ROS) and Gazebo
  • ReInvent Workshop 2022 for Dance Robot (Gan and Hansen 2022)

AWS RoboMaker Workflow

Note

  • Simulation in Robomaker (or DCV) using Gazebo (simulation_ws)
  • Deployment using IoT Greengrass 2.0 (robot_ws)
  • Docker container registry (contain OS integrity)
  • Cloud storage (S3 - Simple Storage Services)

AWS Greengrass Deployment Process

Note

  • container can run a complete different OS than robot OS (x86 and arm64)
  • container deployed from AWS ECR
  • message call from MQTT bridge

AWS Robot Deployment

AWS Academy

Elastic Computing using AWS Academy account setup

Canvas shell

  • You get a canvas page (not the same as Temple’s Canvas) AWS Academy on Chrome
  • multi-course tiles - create a nickname in the console
  • Manage your cloud instance for a course -learner lab
    • start lab/end lab, $100 credit
  • After you start the lab, click on the green dot for AWS Console

AWS Console Management

  • search for services
  • recent services
  • account or role information

Note

The remote desktop using NICE DCV can be fragile in Firefox, Safari and Edge - please use Google Chrome.

1.  Cloud 9 - virtual instance, 
2.  IAM - user management, role, policy
3.  Simple Storage Service (S3)
4.  robomaker, etc.

AWS Academy

AWS Academy Account Setup

  1. Check an email from AWS Academy
  2. Follow the instruction at to setup an account which is different than your University’s account
  • You should have access to AWS Canvas Console.

  • Better rename a nickname by clicking on ⋮ of the course tile

AWS
Identity and Access Management (IAM)

User and Permission

Note

  • User
  • User group
  • Permission (policy, json file)
  • Role

Setup AWS Cloud 9 …

Requirements for instance setup

Need create an EC2 instance

  • create a new environment
  • New EC2 instance
  • c4.xlarge, ubuntu 22.04, Secure Shell (SSH)

Cloud 9

Cloud 9

Select EC2 Instance

  • c4.xlarge (7.5GB and 4 vCPU)

Cloud 9

Select EC2 OS

  • Ubuntu 22.04 (Jammy)

Cloud 9

Create OS

Cloud 9

Open/Create Cloud 9

  • click open to access cloud 9
  • add other cloud 9 instance by clicking on create environment
  • make sure you do not have a lot instances becasue they run when you start the lab

Cloud 9 IDE

Cloud 9 IDE

uname -m
df -lh
  1. user setting (large fonts, background colors, etc)
  2. open a new terminal window
  3. open a new file editor window
  4. open other new table window

Cloud 9 IDE

Install DCV, ROS, Docker and Gazebo

  • Run the following command in a terminal window
curl -fsSL "https://bit.ly/robomaker2204" | sudo -E bash -
  • Wait for 10 minutes
  • Run the following command to reboot the system
sudo reboot
  • Try
uname -m
df -lh

DCV

Access DCV from cloud 9

  • check the menu bar
  • click on preview application
  • click on preview running application

- click on the expansion icon to open a new tab

XWindow from DCV

Allow XWindow on Browser

DCV from running xeyes application

  • make sure you setup DISPLAY variable
export DISPLAY=:0
xeyes &

Xeyes Application in the browser window

Docker

Docker Installation

sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt install docker.io -y
sudo usermod -aG docker $USER
sudo reboot
  • Download here - download based on your processor

  • If you need to update your kernel, try to type the following command in your command window

wsl --update

Docker: How use

Note

  • pull image, you can find more at here
docker pull ubuntu

Note

  • check avaiable docker image
docker image list
  • check avaiable docker process
docker ps -a
  • [start a new process] vs [attach to a process]
docker run -it [containerid] /bin/bash
docker exec -it [containerid] /bin/bash

Docker: How use

Note

  • remove image
docker rmi -f [containerid]
  • remove all images
docker rmi -f $(docker images -aq)
  • prune image/network/volume/system
docker image prune -a
docker network prune -a
docker volume prune -a
docker system prune -a

Docker Example

FROM --platform=linux/amd64  ubuntu:18.04
RUN apt update && apt install -y openssl python3
COPY echo-server.py /echo-server.py

EXPOSE 5001/tcp
  • Create a file named docker-compose.yaml
version: "3"
services: 
  my_image:
    build: 
        context: ./
    image: bionic-bai:latest
  echoserver:
    image: bionic-bai:latest
    command: python3 -u echo-server.py
    ports:
      - "5001:5001"
  • Run the command
sudo apt install docker-compose -y
docker-compose build
  • check what image is available?
docker image list

You can run the docker container and run a test

docker run -it bionic-bai:latest
echo -n password | iconv -t UTF-16LE | openssl md4 
docker-compose --profile echoserver up
  • Terminal 2
python3 echo-client.py abcd

MinPupper AWS

  • using Robomaker (minimum access in terminals - long setup time, but more computing process)
  • using DCV (multiple terminal windows - short setup time)

MiniPupper AWS Dancing Robot

Note

Follow the instruction on Github(Gan and Bai 2022)

git clone https://github.com/mrkoz/mini-pupper-aws.git
  • A Robomaker approach using AWS Docker Container Registry
  • 15 vCPU core
  • A Cloud 9 Approach
  • c4.xlarge (7.5vPU and 4GB)

MiniPupper AWS Dancing Robot

  • Cloud 9 terminal using the following commands
cd mini-pupper-aws
docker build . -t mini-pupper-base:1.0 -f Dockerfile-Base
docker build . -t mini-pupper-robot:1.0 -f Dockerfile-Robot
docker build . -t mini-pupper-simulation:1.0 -f Dockerfile-Simulation
  • Cloud 9 terminal
cd mini-pupper-aws
pip install Inject==3.5.4
sudo rosdep fix-permissions && rosdep update --include-eol-distros
cd robot_ws
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
colcon build
cd ../simulation_ws
colcon build

MiniPupper AWS Dancing Robot

  • easy way then use AWS ECR on AWS console
aws ecr create-repository --repository-name mini-pupper-robot | grep repositoryUri
aws ecr create-repository --repository-name mini-pupper-simulation | grep repositoryUri
  • Other way to run the commands using AWS account number (111122223333) and region (your-region) information
docker tag mini-pupper-robot:1.0 111122223333.dkr.ecr.your-region.amazonaws.com/mini-pupper-robot:1.0
docker push 111122223333.dkr.ecr.your-region.amazonaws.com/mini-pupper-robot:1.0

docker tag mini-pupper-simulation:1.0 111122223333.dkr.ecr.your-region.amazonaws.com/mini-pupper-simulation:1.0
docker push 111122223333.dkr.ecr.your-region.amazonaws.com/mini-pupper-simulation:1.0
  • Open three Cloud 9 terminals and run the following command in each terminal
export DISPLAY=:0
source /opt/ros/melodic/setup.bash
source ~/environment/mini-pupper-aws/simulation_ws/install/setup.bash
source ~/environment/mini-pupper-aws/robot_ws/install/setup.bash
# Add meshes to Gazbo paths
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(rospack find mini_pupper_simulation)/worlds/meshes

MiniPupper AWS Dancing Robot

  • setup robot application in AWS Robomaker
  • setup simulation application in AWS Robomaker
  • setup simulation job using the robot application and simualtion application
GAZEBO_MASTER_URI=http://ROBOMAKER_SIM_APP_IP:11345
ROS_IP=ROBOMAKER_SIM_APP_IP
ROS_MASTER_URI=http://ROBOMAKER_ROBOT_APP_IP:11311
  • Add tool window, set Name to xterm, and Command to /usr/bin/xterm
  • Cloud 9 terminal 1
roslaunch mini_pupper_simulation aws_stage.launch
  • Cloud 9 terminal 2
source /opt/ros/melodic/setup.bash
source ~/environment/mini-pupper-aws/simulation_ws/install/setup.bash
source ~/environment/mini-pupper-aws/robot_ws/install/setup.bash
roslaunch mini_pupper_simulation aws_stage.launch

MiniPupper AWS Dancing Robot

  • open simulation job
  • open xterm app
./flip.sh
./dance.sh
  • check the dog in the dance move
  • Cloud 9 terminal 3
source /opt/ros/melodic/setup.bash
rostopic pub /dance_config std_msgs/String "data: 'demo'"
  • check the dog in the dance move

AWS Robomaker Excercise*

  • need to expand the size to 100G in cloud9 and edit the size
wget https://raw.githubusercontent.com/lbaitemple/mangdang/main/install-resize.sh
bash ./install-resize.sh
  • check swap memory setting
sudo more /etc/fstab
  • need to add 8G swap storage
wget https://raw.githubusercontent.com/lbaitemple/mangdang/main/process_swap.sh
sudo bash ./process_swap.sh 8192 /etc/fstab
  • show to find out the docker image
  • show where is the docker image store in ECR?
  • how to see the robot in robomaker simulation app
  • add your name in your cloned https://github.com/ros2/demos/tree/foxy

References

Gan, Afreez, and Li Bai. 2022. “MiniPupper AWS - ROS1.” 2022. https://github.com/lbaitemple/mini-pupper-aws.
Gan, Afreez, and Matt Hansen. 2022. “Dance of the Cloud Connected Robots.” 2022. https://catalog.us-east-1.prod.workshops.aws/workshops/511d7599-73bd-4142-bd6b-fa83dbe3d8ce/en-US.
Robots, Building Cloud Connected. 2021. “Building Cloud Connected Robots.” 2021. https://catalog.us-east-1.prod.workshops.aws/workshops/fa208b8e-83d6-4cc1-8356-bfa5b6184fae/en-US.