Tutorials/cloudsim/1.1/start simulation

Introduction === This tutorial covers:
 * logging in the Cloudsim web app
 * launching and terminating virtual simulation machines in the cloud
 * starting and stopping ROS and the DRC simulator on the virtual machine
 * connecting to the simulation machine using rviz

Prerequisites === This tutorial assumes that you have a Google email account that has been granted access to a running CloudSim instance.

On the local machine, install the drcsim package. This will install the Atlas robot meshes on your local machine, as well as the rviz tool. Don't forget to source the setup.sh file if it is not executed in your ~/.bashrc.

sudo apt-get install drcsim openvpn ros-fuerte-visualization

Log in to Cloudsim ===

Point your browser to the CloudSim instance. You should land on the login page.



Following the login link should bring you to the OpenID page where you can choose the provider. At this time, only Google is supported.



Once you have entered your credentials at Google, you should be redirected to the version page. Follow the `Console` link to get to the web app.



This is what the Cloudsim console looks like for normal users when no simulations are running. The top widget section allows you to launch a variety of constellation configurations:
 * robot machine
 * latest drc simulator machine
 * a constellation that contains a pair of machine with appropriate VPN (Virtual Private Network) setup.

The lower section, constellations, shows the running instances.

Cloudsim is capable of launching multiple machines that work together for during a single simulation campaign. Cloudsim uses the term constellation for this concept. In CloudSim, Machines can only be launched within the context of a constellation, so it is possible to encounter constellations that only contain a single machine.



Launch a DRC cloud simulation machine ===

In the "Launch a machine constellation" section, selct "drc_sim_latest" from the drop down menu and press the "Launch" button. After a few seconds, you should see a new section appear inside the "Constellation" section. Here's what happens then:


 * A constellation with a unique name is created. It contains one simulator machine.
 * A new virtual machine with GPU is started with Ubuntu 12.04 precise
 * X and OpenGl are configured for the GPUs (with the current NVidia drivers)
 * Packages for VPN, ROS, Gazebo and DRC simulator are installed
 * The machine has rebooted

The whole process can take up to 20 minutes. Once done, the machine state should indicate "running" with a blue dot. X and GL should also indicate "running" with a blue dot. The graph shows latency measures between the CloudSim virtual machine and the simulator machine instance. It is updated periodically.



Start and stop a Gazebo simulation using ROS === The widget above the graph allows you to start and stop a ROS package from CloudSim. It is used to start the DRC simulator and Gazebo. Type in the package, launch file and arguments and press the `Start` button.



After a few seconds, the red dot should turn blue, indicating that Gazebo is running.



Connecting to the simulator instance ===

It is possible to connect to the simulator machine with a terminal using ssh. You can also establish a VPN connection with the simulator and connect via ROS. Both these connections need keys to be installed on your local machine. You can download these keys (as well as useful scripts) by following the link "Download keys". This should save zip file on your local machine (in the ~/Downloads/simulator_c_05fe3f08.zip in this example). Extract the content in a directory in your local machine.

mkdir cloudsim_start_tutorial cd cloudsim_start_tutorial unzip ~/Downloads/simulator_cx4a0cd28e.zip

. ./simulator_cx4a0cd28e/ssh.sh

In a separate terminal window, launch the VPN (Virtual Private Network): cd simulator_cx4a0cd28e sudo openvpn openvpn.config

Wait until you see the completion message:

... Fri Jan 4 17:13:35 2013 UDPv4 link remote: [AF_INET]50.16.168.233:1194 Fri Jan 4 17:13:45 2013 Peer Connection Initiated with [AF_INET]50.16.168.233:1194 Fri Jan 4 17:13:47 2013 Initialization Sequence Completed

You can now launch ROS nodes such as rviz from your local machine. If you're going to work with drcsim, you should have already sourced the appropriate setup file (e.g., `. /usr/share/drcsim-1.1/setup.sh`). That will ensure that your local ROS nodes have access to drcsim-specific resources such as visual meshes that are used in rendering the robot model.

Before running ROS node, you should source your local drcsim `setup.sh` (if it is not invoked by your ~/.bashrc) and the `ros.sh` file provided in the zip file for the simulation machine; it will configure your local ROS environment to communicate with the remote ROS master over the VPN link. E.g., to run rviz locally:

. /usr/share/drcsim/setup.sh . simulator_cx4a0cd28e/ros.sh rosrun rviz rviz



Now you can do the same things that you can do when running the simulation locally, such as visualizing and logging sensor data.

TODO: gzclient (needs GAZEBO_MASTER_URI setting in some .sh file)

Terminate the constellation and its machines ===

Press the "Terminate" button on the top left corner of the Constellation section. Within a few seconds, you should see the Machine state dot turn to orange and the "running" will change to "shutting down".



Once the state of every machine indicates "terminated", the constellation will not appear if the browser window is refreshed.