Separating Simulation and Application
Learning Objective
The walkthrough demonstrates a navigation application that controls
turtlebot3 in a Gazebo simulation on rapyuta.io
It shows the separation of launch files into application and simulation.
It is recommended to run the simulation on the cloud and the
application on either a computer or an instance of the cloud.
Prerequisites
- The CPU architecture of the device is AMD64
- Install ROS Melodic on the device.
- Install catkin-tools package on the device.
- Install the Chrome web browser on a computer.
- Familiarity with tools like git, UNIX/LINUX command terminal.
- Optional: ROS launch system concepts and ROS navigation stack structure are suggested readings if you want to run your applications with Gazebo on rapyuta.io. It will help you understand the usage better.
Difficulty
Intermediate
Estimated Time
25 minutes
Background
The source code for the walkthrough is in the
turtlebot_navigation repository on GitHub.
The simulation and navigation application start from separate
launch files so that the former runs on the cloud and the
latter runs on a device.
The package, io_gazebo_turtlebot_bringup, includes files
that start a demo application for navigating a turtlebot3 model
in a Gazebo simulation. These files are:
- common.launch
- load configuration parameters shared between
simulation and navigation application to respective ROS parameter
servers, for example, robot_description, an initial position
of the TurtleBot.
- app.launch
- launches amcl, move_base and other navigation related nodes through io_gazebo_turtlebot_navigation.launch
- launches demo application that sends sequential move_base goals through demo_app.launch
- loads common configuration parameters via common.launch
- sim.launch
- loads Gazebo simulation of turtlebot3 via
io_gazebo_turtlebot_gazebo.launch file.
- loads common configuration parameters via common.launch
- bringup.launch
- launches both sim.launch and app.launch.
- ensures common.launch is called only once.
Prepare Device
On the device’s command line terminal, execute the following commands
in sequence to set up a catkin workspace, install ROS dependencies
and build the catkin workspace.
cd $HOME
mkdir -p catkin_ws/src
cd catkin_ws/src
git clone https://github.com/rapyuta-robotics/io_simulation_tutorials.git
rosdep init
rosdep update
rosdep install --from-paths --ignore-src io_simulation_tutorials/turtlebot_navigation/ -y --rosdistro melodic
cd ../
source /opt/ros/melodic/setup.bash
catkin build io_gazebo_turtlebot_bringup io_gazebo_turtlebot_demo_app io_gazebo_turtlebot_description io_gazebo_turtlebot_navigation
source devel/setup.bash
Onboard Device
- On the left navigation bar, click DEVICES.
- Click ADD NEW DEVICE.
- The name of the device is
Turtlebot3 Navigation Simulation Device
.
- Provide the absolute path of the catkin workspace in the ROS Catkin Workspace box. In this case, the workspace is
/home/rapyuta/catkin_ws
. The absolute path of your catkin workspace may be different, which can be determined by executing command pwd inside the root of the catkin workspace on the device’s terminal.
- Define the purpose of the device in the Description box.
- Click CONTINUE.
- Click COPY to copy the generated device token.
- Execute the token at the device’s terminal to set up rapyuta.io’s device agent on the device.
Create build
To create the build, follow below steps:
- On the left navigation bar, click BUILDS
- Click on ADD NEW BUILD
- In the Build Name box, enter a name for the build say
io-simulation-navigation
- In the Git repository box, enter the url address :
https://github.com/rapyuta-robotics/io_simulation_tutorials
and select Build Recipe as Catkin.
- In the context directory, enter
turtlebot_navigation
- Click on next, select ROS Version as Melodic and select the Has Simulation option.
- Click on next, the build will be created.
The build takes about two to five minutes to build the source code in the io_simulation_tutorials
repository into a running docker container. You may analyse the corresponding
build logs, which help debug failing builds.
Please proceed to creation of package once the build is Complete.
Create Packages
You will create and add two packages, namely, Navigation Application and Turtlebot3 Simulation.
Navigation Application Package
- On the left navigation bar, click CATALOG.
- Click ADD NEW PACKAGE.
- The name of the package:
Navigation Application
- Make sure Is a singleton package is not selected.
- Ensure Is a bindable package is selected.
- The version of the package is
1.0.0
- The purpose of the package is to
Controlled navigation of turtlebot3
- Click NEXT.
- The name of the component:
navigation_component
- The runtime of the component is Device.
- Ensure Is ROS Component is selected.
- Choose Melodic for ROS Version.
- Set Restart Policy to Never.
- The name of the executable:
navigation_executable
- The Executable Type is Default.
- In the Command to run in the docker container box, enter the command:
roslaunch io_gazebo_turtlebot_bringup app.launch
- Click on Add ROS topic. The name of the ROS topic is
/cmd_vel
, and it is set QoS to Low.
- Add a configuration parameter by clicking on Add Parameter. The name of the parameter is
SPAWN_TURTLEBOT_ROBOT
. The Default value is true
.
- Click NEXT > CONFIRM PACKAGE CREATION.
Simulation Package
- On the left navigation bar, click CATALOG.
- Click ADD NEW PACKAGE.
- The name of the package:
Simulation
- Make sure Is a singleton package is not selected.
- Ensure Is a bindable package is selected.
- The version of the package is
1.0.0
- The purpose of the package is to
Simulation of turtlebot3
- Click NEXT.
- The name of the component:
simulation_component
- The runtime of the component is Cloud.
- Ensure Is ROS Component is selected.
- Choose Melodic for ROS Version.
- The number of Replicas to run the component is 1
- The name of the executable:
simulation_executable
- For Executable Type, click on Builds.
- In the Choose Build select the Build (
io-simulation-navigation
) created above
from the drop-down list
- In the Command to run in the docker container box, enter the command:
roslaunch io_gazebo_turtlebot_bringup sim.launch gui:=true
- Set Resource Limit to Medium:2 cpu cores, 8 GiB memory
For simulation, the resource limit should either be Medium or Large. Simulation has issues with Small resource limits.
- Add the following ROS topics:
- Name:
/joint_states
, QoS: Low
- Name:
/tf
, QoS: Low
- Name:
/scan
, QoS: Low
- Name:
/odom
, QoS: Low
- Click NEXT.
- Under Inbound ROS Interfaces, Click on Add Topic to add the ROS topic
/cmd_vel
as an inbound ROS topic.
- Click CONFIRM PACKAGE CREATION.
Deploy Packages
You will first deploy the Simulation package, and then the Navigation Application package.
Deploy Simulation Package
- On the left navigation bar, click CATALOG.
- Select Simulation package.
- Click Deploy package.
- The name of deployment:
SIMULATION
- Enter the value for VNC_PASSWORD
- Click CREATE DEPLOYMENT > Confirm
You will redirect to the Details tab of the newly
created deployment. The SIMULATION is successfully running
if the progress bar reaches Succeeded, and the status is Running.
Deploy Navigation Application Package
- On the left navigation bar, click CATALOG.
- Select Navigation Application package.
- Click Deploy package.
- The name of deployment:
NAVIGATION
- Select Turtlebot3 Navigation Simulation Device as the device on which the navigation_component will be deployed.
- Check if the SPAWN_TURTLEBOT_ROBOT parameter has the value true.
- Check if the ros_wokspace and ros_distro device configuration variables have values set to the correct absolute path for catkin_ws and melodic respectively.
- Click Add dependency to add SIMULATION deployment as a dependent deployment.
- Click CREATE DEPLOYMENT > Confirm
You can verify if NAVIGATION APPLICATION is running successfully by
checking if the progress bar reaches Succeeded and status is
Running.
Result
- On the Details tab of SIMULATION deployment, copy the value of the network endpoint vnc.
- Paste the copied URL address in the address bar of the web browser and press Enter.
- Enter the value of VNC_PASSWORD, which you provided while deploying the package when prompted.
Advanced Tips
If you want to run your application separate from the Gazebo simulation on
rapyuta.io, it will need time synchronization. Since the set
up runs two ROS Masters, one in the cloud with Gazebo and the other on a
computer with navigation nodes. The clock for these two applications will need
to be in sync. The clock synchronization is by /clock ROS topic, which is published by
Gazebo.
- /use_sim_time is set to true in ROS parameter server
to use /clock topic
- If your application requires time synchronization, you have to wait on
the /clock topic as shown here.