Main Content

Read and Visualize ROS 2 bags in AWS S3 Cloud

This example shows how to read and visualize ROS 2 bags stored in Amazon® Web Services (AWS®) Simple Storage Service (S3) cloud using ROS Toolbox and a customized MATLAB reference architecture. This architecture is designed to deploy on a Linux® virtual machine in AWS. The reference architecture incorporates MATLAB and the ROS Toolbox to facilitate this visualization.

Overview

In this example, we assume that the ROS 2 bag files are stored in an AWS S3 bucket. You can easily visualize ROS 2 bags data using ROS Data Analyzer from the MATLAB web browser. You can create multiple viewers within the app and visualize different ROS 2 messages simultaneously.

The architecture involves the deployment of a CloudFormation template in the AWS cloud, utilizing a preconfigured image that includes MATLAB proxy application. For more information on architecture, see MATLAB on AWS.

arch.png

AWS Services and Costs

This example uses these AWS services, some of which can incur costs on your AWS account. For cost estimates, see the linked pricing page for each AWS service.

You can visualize, understand, and manage AWS costs and usage over time using AWS Cost Explorer.

Requirements

To visualize ROS 2 bag data from the cloud, you will require:

  • AWS account with full access permissions to S3 services.

  • SSH key pair for your AWS account in the selected region. For more information, see  Amazon EC2 Key Pairs.

  • ROS 2 bag files stored in S3 bucket.

  • A MATLAB license that meets the following conditions: 1. Linked to a MathWorks Account. 2. Configured for cloud use. Individual and Campus-Wide licenses are already configured. For other license types, contact your administrator. You can identify your license type and administrator by viewing your MathWorks Account. Administrators can consult Administer Network Licenses.

Run from GitHub

To access MATLAB directly in your web browser, use the reference architecture templates provided in this GitHub® repository: MATLAB on AWS.

In the Deploy Prebuilt Machine Image step, select the appropriate MATLAB release and follow the instructions to deploy the resources. During the stack deployment process, it is essential to provide information for these parameters:

Parameters

Description

Stack name

Specify a stack name.

Additional IAM Policies

Include the subsequent AWS inline policy to obtain complete access to S3 buckets: arn:aws:iam::aws:policy/AmazonS3FullAccess

Keep public IP the same

Select Yes, this flag indicating whether you want to keep the same public IP address for the instance.

Allow connections from

The allowed IP address format is <ip_address>/<mask>, for example, 172.x.x.x/32. This IP address can be found by searching 'what is my IP address' on the web.

SSH key pair

Name of an existing EC2 KeyPair to allow SSH access to all instances.

Remote password

Password for the ubuntu user.

Confirm remote password

Confirm Password.

VPC to deploy this stack

ID of an existing VPC for deploying this stack.

Subnet

ID of an existing subnet. To access the instance from anywhere, make sure the subnet assigns public IP addresses and is connected to the internet.

Optional user command

Put this command into the Optional User Command section to install the mount-s3 feature, replacing <s3-bucket-name> with your S3 bucket containing ROS 2 bags. For additional details, refer to the mount point for Amazon S3.

wget -O /home/ubuntu/mount-s3.deb https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.deb; cd /home/ubuntu/; sudo apt-get install -y ./mount-s3.deb; rm -r /home/ubuntu/mount-s3.deb; sudo -u ubuntu mkdir /home/ubuntu/s3files; sudo -u ubuntu mount-s3 <s3-bucket-name> /home/ubuntu/s3files

After providing all the necessary information, click the Create Stack button depicted in the figure below. The CloudFormation service will then commence the creation of the stack's resources.

capabilities.png

Wait for the status to reach CREATE_COMPLETE, this may take up to 4 minutes. After successful deployment of stack you will see MATLABProxyConnection link from the Outputs of the CloudFormation stack. For more information on MATLAB proxy app, see MATLAB Proxy.

AWS Cloud ROS Bag Visualization

Open the MATLABProxyConnection link on a web browser. Upon opening the proxy link, you may encounter the following. Click the Advanced button to proceed and launch the proxy application in the browser.

warniing.png

Insert the Remote password to authenticate MATLAB proxy app in your web browser.

warn.png

If you are using MathWorks account, enter credentials for a MathWorks account associated with a MATLAB license.

license.png

If you are using a network license manager, then change to the Network License Manager tab and enter the license server address instead.

license2.png

If you are using an Existing License, then change to the Existing License tab and then click Start MATLAB.

license3.png

To determine the appropriate method for your license type, consult MATLAB Licensing Info. Wait for the MATLAB session to start. This can take several minutes.

AWS connected to MATLAB

Mount and Visualize ROS 2 Bags

To read and visualize ROS 2 bag files from the mounted S3 bucket, by following these steps:

  1. Open the ROS Data Analyzer app from the MATLAB web browser.

  2. Click "Open" and select "Bag file" to load your bag file.

  3. Navigate to the mounted files located in the "/home/ubuntu/s3files" directory.

  4. Choose the desired bag file to visualize. Now select the topic and click the play button in the Playback controls.

ROS Data Analyzer to view ROS 2 bags in AWS

For more detailed instructions on how to load and play a bag file, refer to the Load and Play ROS or ROS 2 Bag File page.

Additional Information

You can continue utilizing the same web browser proxy link and resources until either the CloudFormation stack is deleted or the EC2 instance is terminated. In the event that you temporarily stop the EC2 instance, you must manually remount the S3 bucket by executing the following command in the MATLAB command window:

!mount-s3 <s3-bucket-name> /home/ubuntu/s3files

Delete Your Cloud Resources

Once you have finished using your stack, it is recommended that you delete all resources to avoid incurring further cost. To delete the stack, do the following:

  1. Log in to the AWS Console.

  2. Go to the AWS CloudFormation page and select the stack you created.

  3. Click the Delete button from the menu that appears.

Related Topics