AWS Robotics Blog
Deploy Robotic Applications Using AWS RoboMaker
This blog references AWS RoboMaker Fleet Management, a feature that has been deprecated. You should now use AWS IoT Greengrass V2 for deploying and managing your robot software. To learn more about this process, see our blog on how to Deploy and manage ROS robots with AWS IoT Greengrass 2.0 and Docker.
Introduction
AWS RoboMaker is a service that makes it easy to create robotics applications at scale. AWS RoboMaker extends the Robot Operating System (ROS) framework with cloud services including AWS monitoring services, analytics services, and even machine learning services. AWS RoboMaker also provides a robotics application development environment, a robotics simulation service, and a fleet management service to deploy and manage applications on physical robots. In this blog, we will focus on how to create, configure, and register a physical robot in AWS RoboMaker. We will then show you how to deploy the AWS RoboMaker HelloWorld sample robot application to the registered robot.
Prerequisites and assumptions
You need the following for this walk through:
- A working AWS account
- A physical Robot that is already set up and configured with ROS Kinetic/Melodic, SSH, SFTP/SCP, and internet access.
- A Region that supports AWS RoboMaker. This blog uses us-west-2 (Oregon) Region.
Prepare your robot
AWS RoboMaker leverages AWS IoT Greengrass to deploy robot applications to robot. AWS IoT Greengrass seamlessly extends AWS to edge devices, such as robots, so they can execute locally, while still using AWS for management, analytics, and durable storage. With AWS IoT Greengrass, you can seamlessly and securely manage and deploy robot applications to robots at scale.
Before creating a robot, you will need to first create an Amazon S3 bucket, as it will be used for store the HelloWorld sample robot application bundle. Next, create an IAM role for the robot application deployment. This IAM role will provide the necessary permissions for AWS IoT Greengrass to access your robot application bundle in Amazon S3, read update status from AWS RoboMaker, and to access other AWS services such as Amazon CloudWatch for logging and metrics. Then you will register and configure your robot in AWS RoboMaker. You will also create an AWS RoboMaker fleet and register your robot as a member of that fleet. This will allow AWS RoboMaker to manage and deploy your robot applications to your robot. Finally, you will create a robot application, build and bundle it, and deploy it to your robot using AWS RoboMaker.
Create an Amazon S3 bucket
- Sign in to the Amazon S3 console at https://console.thinkwithwp.com/s3
- Create a bucket and give the bucket a name, for example, “robomakerhelloworld” and select the same Region where you will use AWS RoboMaker. Keep everything else default and create the bucket.
Create an AWS IoT Greengrass role
1. Sign in to the AWS Identity and Access AWS Management Console at console.thinkwithwp.com/iam.
2. Create the access policy. On the left, choose Policies, then choose Create policy. Choose JSON and paste the code below, make sure the bucket name in red is correct:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"robomaker:UpdateRobotDeployment"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:List*",
"s3:Get*"
],
"Resource": ["arn:aws:s3:::robomakerhelloworld/*"]
}
]
}
Choose Review policy, type in a Name, and then choose Create policy.
3. Choose Roles and then choose Create role.
4. In the Create role: Step 1 page, choose Greengrass and then choose Next: Permissions.
5. In the Permissions page, select the policy you created above, then choose Next: Tags.
6. In the Add tags page, add optional tags to the role, then choose Next: Review.
7. In the Review page, type in a Role name and then choose Create role.
8. Next, update the trust policy to include AWS Lambda. Select the new role, then select the Trust relationships tab.
9. In the Trust relationship tab, select Edit trust relationship.
10. Update the trust relationship with the following policy document:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com",
"greengrass.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
11. Select Update Trust Policy.
Create a robot
1. Sign in to the AWS RoboMaker console at https://console.thinkwithwp.com/robomaker/.
2. In the left navigation pane, choose Fleet Management, and then choose Robots.
3. Choose Create robot.
4. In the Create robot page, type a name for the robot.
5. Select the Architecture of the robot.
6. Under AWS IoT Greengrass group defaults, select a Create new to create a new AWS IoT Greengrass group for the robot. Optionally, you can select an existing AWS IoT Greengrass group. Each robot must have its own AWS IoT Greengrass group.
If you use an existing AWS IoT Greengrass group, it must have an IAM role associated with it. To create the role, see instructions in the section above.
7. Optionally, modify the Greengrass prefix. This string is prepended to AWS IoT Greengrass objects created on your behalf.
8. Select the IAM role created in the previous section to assign to the AWS IoT Greengrass group. It grants permissions for AWS IoT Greengrass to access your robot application in Amazon S3 and read the update status from AWS RoboMaker.
9. Optionally, under Tags, specify one or more tags for the robot. Tags are words or phrases that act as metadata for identifying and organizing your AWS resources. Each tag consists of a key and a value. You can manage tags for your robot on the Robot details page.
For more about tagging, see Tagging Your AWS RoboMaker Resources.
10. Choose Create.
11. In the Download your Core device page, choose Download to download and store your robot’s security resources.
12. Download AWS IoT Greengrass Core software matching the architecture of your physical robot.
Depending on your robot’s system architecture, your steps below may vary. In this blog, you will learn how to configure and run AWS IoT Greengrass Core on a Raspbian robot with ARMv7l architecture.
Also note this is the only chance to download the certificate and core.
Configure and install AWS IoT Greengrass Core on your robot
1. SSH, remote desktop or open a terminal on your physical robot. Make sure it has internet access.
Depending on your robot’s system architecture, your steps below may vary. In this blog, you will learn how to configure and run AWS IoT Greengrass Core on a Raspbian robot with ARMv7l architecture.
2. Make sure all packages and lists are upgraded and have been updated.
For example, use the following commands to update and upgrade:
sudo apt update
sudo apt dist-upgrade
3. Use the following commands to add AWS IoT Greengrass Core user and group.
sudo adduser –system ggc_user
sudo addgroup –system ggc_group
4. If you are using Raspbian based robot, enable hardlink and softlink protection to improve security by adding the following two lines of configuration in /etc/sysctl.d/98-rpi.conf file.
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
Next, enable and mount memory cgroups in the command line boot file so AWS IoT Greengrass can set the memory limit for Lambda functions. Append the following to the end of the /boot/cmdline.txt file, not as new line.
cgroup_enable=memory cgroup_memory=1
Reboot the robot for the changes to take effect.
5. Use SFTP, SCP, or other methods to transfer both the robot’s security resources zip file and AWS IoT Greengrass Core software in the previous steps to your physical robot.
For example, use the following commands to copy the resources:
cd path-to-downloaded-files
scp greengrass-OS-architecture-version.tar.gz username@IP-address:/home/username
scp RobotName-setup.zip username@IP-address:/home/username
6. SSH, remote desktop or open a terminal on your physical robot, navigate to the folder that contains the resources.
7. Decompress and unzip the AWS IoT Greengrass Core software and the security resources.
For example, use the following commands to decompress and unzip:
sudo tar -xzvf greengrass-OS-architecture-version.tar.gz -C /
sudo unzip RobotName-setup.zip -d /greengrass
8. Use the Amazon Trust Services (ATS) endpoints and download ATS root CA certificates. Certificates enable your robot to communicate with AWS IoT using the MQTT messaging protocol over TLS.
For example, use the following commands to download:
cd /greengrass/certs/
sudo wget -O root.ca.pem
https://www.amazontrust.com/repository/AmazonRootCA1.pem
9. Now that AWS IoT Greengrass is configured and installed on your robot, use the following commands to start the service and you should see the message Greengrass successfully started. If you run into issues starting AWS IoT Greengrass, see Troubleshooting AWS IoT Greengrass.
sudo /greengrass/ggc/core/greengrassd start
Create a fleet
1. Sign in to the AWS RoboMaker console at https://console.thinkwithwp.com/robomaker/.
2. In the left navigation pane, choose Fleet Management, and then choose fleets.
3. Select Create fleet.
4. In the Create fleet page, type a name for the fleet.
5. Optionally, under Tags, specify one or more tags for the fleet. Tags are words or phrases that act as metadata for identifying and organizing your AWS resources. Each tag consists of a key and a value. You can manage tags for your fleet on the Fleet details page.
For more about tagging, see Tagging Your AWS RoboMaker Resources.
6. Click Create to create the fleet
7. Click Register new and select your robot created in earlier section and click Register robot.
Build a robot application with AWS RoboMaker
1. In this section, you will build and bundle the HelloWorld sample robot application in AWS RoboMaker.
2. Sign in to the AWS RoboMaker console at https://console.thinkwithwp.com/robomaker/.
3. On the left, expand Development, choose Development environments, and then choose Create environment.
4. In the Create AWS RoboMaker development environment page, enter HelloWorld as the environment name.
5. For ROS Distribution, select ROS Kinetic/Melodic.
6. Accept the default instance type (m4.large). You can select different instances type to improve bundling performance.
7. Select a VPC. Use the default VPC.
8. Select a Subnet.
9. Choose Create to create the AWS Cloud9 development environment.
10. In the HelloWorld AWS Cloud9 development environment, choose AWS RoboMaker Resources, then choose Download samples, and then select 1. Hello World.
11. On the left, in the Environment tab, expand HelloWorld, HelloWorld, robot_ws, src, hello_world_robot, and then nodes. Select the file rotate to load into the editor.
12. In the rotate tab, modify the code to make the robot turn clockwise by making the rate negative: self.twist.angular.z = -0.1. Save the file by selecting File and then Save.
13. Build the robot application. On the menu, choose AWS RoboMaker Run, then choose Workflow, and then select HelloWorld – Build and Bundle All. This will take a few minutes to finish.
14. Since our robot is a Raspbian robot with ARMv7l architecture, we will need to bundle the HelloWorld robot application for ARMHF. We can achieve this by start a cross compilation Docker container in the AWS Cloud9 development environment.
In the HelloWorld AWS Cloud9 development environment, choose the bash tab at the bottom of the page and then run the following commands to bundle the HelloWorld robot application for ARMHF. This process could take 20 minutes or more to complete.
cd /opt/robomaker/cross-compilation-dockerfile/
sudo bin/build_image.bash
cd ~/environment/HelloWorld/robot_ws
sudo docker run -v $(pwd):/ws -it ros-cross-compile:armhf
cd ws
apt update
rosdep install –from-paths src –ignore-src -r -y
colcon build –build-base armhf_build –install-base armhf_install
colcon bundle –build-base armhf_build –install-base armhf_install –bundle-base armhf_bundle –apt-sources-list /opt/cross/apt-sources.yaml
exit
15. You should see ARM build and install folders created by the container in the Environment tab under robot_ws directory.
16. Before you can deploy the robot application, copy it to an Amazon S3 bucket you created earlier. Copy the robot application to the bucket in the bash tab.
aws s3 cp armhf_bundle/output.tar s3://robomakerhelloworld/hello-world-robot.armhf.tar
The ARMHF version of the robot application is hello-world-robot.armhf.tar.
Create and deploy the robot application with AWS RoboMaker
1. In this section, you will deploy the HelloWorld sample robot application from AWS RoboMaker.
2. Sign in to the AWS RoboMaker console at https://console.thinkwithwp.com/robomaker/.
3. On the left, expand Development, choose Development environments, and then choose Robot applications.
4. Select Create robot application.
5. In the Create robot application page, type a Name for the robot application. Choose a name that helps you identify the robot.
6. Select ROS Kinetic/Melodic.
7. Provide the Amazon S3 path to your bundled robot application file (s3://robomakerhelloworld/hello-world-robot.armhf.tar) into the ARMHF source file field
8. Optionally, under Tags, specify one or more tags for the simulation application. Tags are words or phrases that act as metadata for identifying and organizing your AWS resources. Each tag consists of a key and a value.
For more about tagging, see Tagging Your AWS RoboMaker Resources.
9. Choose Create, then click on the link of the Robot application name.
10. In the Robot application details page, in Versions, select Create new version, and then choose Create.
11. Finally! You are now ready to deploy the robot application to your robot.
12. In the AWS RoboMaker console, select Fleet management, then select Deployments, and then select Create deployment.
13. In the Create deployment page, select the Fleet you created with your robot registered, then select the Robot application and Robot application version you created.
14. In Deployment launch config, type in hello_world_robot for Package name. Then type in deploy_rotate.launch for Launch file.
15. In Deployment settings config, accept the default values for Concurrent deployment percentage and Failure threshold percentage.
16. Select Create. You can track the deployment status and deployment progress detail on the deployment details page.
In this blog, we walked you through the process end-to-end on how to create and configure a robot, build and bundle a robot application in ARMHF architecture, and finally deploy the application to the robot. We hope you enjoyed it and that this information helped you to understand how modular, robust, and complete the AWS RoboMaker service is. For additional tutorials and information, please visit links below.