--- # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: CC-BY-SA-4.0 title: AWS RoboMaker Demo - simulation job permalink: /modules/3/robomaker-demo-simulation-job.html --- The other way to run the application is through a simulation job. The use case of a simulation job is when the application requires a batch job, e.g., for training a machine learning approach or for automated testing of the code. In the following the main steps to configure the simulation job. ## Build and bundle Use the following commands to build and then bundle your robotics application and simulation application with colcon. # go to your-robotic-application-workspace folder cd ~/environment/aws-robomaker-sample-application-helloworld/robot_ws colcon build colcon bundle # go to your simulation workspace folder cd ~/environment/aws-robomaker-sample-application-helloworld/simulation_ws colcon build colcon bundle which will compile and bundle the code, creating a portable environment. Such a portable environment can be moved to a different Linux system and executed as if the contents of the bundle were installed locally. The colcon build and bundle commands produce the artifacts `robot_ws/bundle/output.tar` and `simulation_ws/bundle/output.tar` respectively. You must upload these to an S3 bucket. ## Create and upload to S3 bucket Before you create a simulation job, you need to create a bucket to use as source location for your applications. You can also create a bucket for output generated during the simulation job. If you didn't previously create buckets, follow the steps below. 1. In the terminal in your IDE, create a bucket for your application source. This bucket will be the source location for your robot and simulation applications. You can choose the name, which should be unique, i.e., no other S3 bucket should have the same name. aws s3 mb s3://myapplicationsource 2. Now create a bucket for output generated by the simulation job. AWS RoboMaker uploads ROS bags, ROS logs and Gazebo logs when the simulation job completes. Select a unique bucket name. aws s3 mb s3://mysimulationjoboutput ## Create a robot application Before you can create a simulation job, you need to create a robot application in AWS RoboMaker. It contains details like target architecture and ROS version. It can be used in a simulation job and can be deployed to physical robots. 1. In the terminal in your IDE copy the robot application source bundle to your Amazon S3 bucket. It is renamed to `/my-robot-application.tar.gz` during the copy. The robot application must be built for the `X86_64` architecture. The bundle might be `.tar` or `.tar.gz` extension. aws s3 cp robot_ws/bundle/output.tar s3://myapplicationsource/my-robot-application.tar.gz 2. Create a robot application in AWS RoboMaker. aws robomaker create-robot-application --name MyRobotApplication --sources s3Bucket=myapplicationsource,s3Key=my-robot-application.tar.gz,architecture=X86_64 --robot-software-suite name=ROS,version=Melodic ## Create a simulation application A simulation application contains all of the assets and logic needed to simulate an environment. You need to create a simulation application in AWS RoboMaker before you can create a simulation job. 1. In the terminal in your IDE copy the simulation application source bundle to your Amazon S3 bucket. The simulation application must be built for the `X86_64` architecture. The bundle might be `.tar` or `.tar.gz` extension. aws s3 cp simulation_ws/bundle/output.tar s3://myapplicationsource/my-simulation-application.tar.gz 2. Create a simulation application in AWS RoboMaker. aws robomaker create-simulation-application --name MySimulationApplication --sources s3Bucket=myapplicationsource,s3Key=my-simulation-application.tar.gz,architecture=X86_64 --robot-software-suite name=ROS,version=Melodic --simulation-software-suite name=Gazebo,version=9 --rendering-engine name=OGRE,version=1.x ## Create the simulation job With all the configuration done in the RoboMaker IDE, the next step is to configure and create a simulation job, where information such as duration, robot application, and simulation application are specified. The steps are as follows: 1. In the AWS RoboMaker console in the left navigation pane, choose **Simulation run**, and then choose **Simulation jobs**, then **Create simulation job**. 2. On the **Simulation configuration** page: 1. **Simulation job duration**: 1 hour 2. **Failure behavior**. Choose **fail** to terminate the if the simulation job fails. 3. **ROS Distribution**: Melodic 4. **IAM Role**, select your previously create role or select **Create new role** to create one. 5. Scroll down and choose **Next**. 3. On the **Specify robot application** page: 1. Select **Choose existing application**: MyRobotApplication 2. **Launch package name**: hello_world_robot 3. **Launch file**: rotate.launch 4. Expand **Robot application tools**. Select **Use default tools** to use preconfigured tools. Later, you can select **Customize tools** to add, remove or edit custom tools to use with application. For more information about custom tools, see [Configuring Custom Simulation Tools](https://docs.aws.amazon.com/robomaker/latest/dg/simulation-job-custom-application-tools.html). 5. Scroll down and choose **Next**. 4. Similarly, on the Specify simulation application page, 1. Select **Choose existing application**: MySimulationApplication 2. **Launch package name**: hello_world_simulation 3. **Launch file**: empty_world.launch 4. Expand **Simulation application tools**. For now, select **Use default tools** to use preconfigured tools. Later on you can select **Customize tools** to add, remove or edit custom tools to use with application. For more information about custom tools, see [Configuring Custom Simulation Tools](https://docs.aws.amazon.com/robomaker/latest/dg/simulation-job-custom-application-tools.html). 5. Scroll down and choose **Next**. 5. Scroll down and select **Create** to create the simulation job. ## View simulation job details By selecting **Create** you will start the simulation. It will take a few minutes for the AWS RoboMaker simulation to start. You will see that the status "Preparing". When "Preparing" becomes "Running", you can use the application tools typically used to inspect the behavior of the code can be launched, by clicking on `"Connect"` of each respective tool. For example `GZClient` for opening the Gazebo graphical user interface. The simulation can be seen, as shown in the following figure. ![Gazebo](/img/gazebo.png) ## Stopping the simulation While there is a max time configurable from the configuration of the simulation as seen during the configuration of the simulation job, it is important to stop the simulation when done to minimize the incurred cost. This can be done clicking from the top right on `"Actions"->"Cancel"` A message will appear asking for confirmation to "Cancel". ---- Here is a full video showing these steps: {% include video-file.html url="/img/robomaker-simulation-job" %} ---- Now that we are familiar with the development environment and running simulations, let's modify in the [next unit]({{ site.baseurl }}{% link _modules/mod-3c-jetbot.md %}) the simulation to include the Waveshare Jetbot, which is part of this course. This will allow us to be ready to learn how to develop robotics applications in the following course. {% capture ref %} {% bibliography --cited %} {% endcapture %} {% include references.html ref=ref %}