Gazebo guide

From Robin

Jump to: navigation, search

Gazebo is a very useful tool used for simulations in robotics. You can create/load worlds with objects and your robot inside, and run simulations of movements on the robot. This is useful, as you can develop scripts and test them out in a simulated environment and observe how the robot moves before testing it out on a physical robot.


Contents

Setup

To make it easier working with Tiago and ROS, you can use a Singularity container where the most basic packages you need are already installed. See how you can use the Singularity container on the robin wiki page here.

You might need to set some environment variables to be able to run simulations on your computer successfully. After you enter the Singulairty shell and you are ready to start simulating, check the environment variables ROS_MASTER_URI and ROS_IP. The ROS master should be set to run locally on your computer and the ROS IP should be set to your computer, like this:

 $ export ROS_MASTER_URI=http://localhost:11311
 $ export ROS_IP=vixen-nb.uio.no

If you are not using the vixen computer, change the IP to the computer you are using. In addition, you might need to set these environment variables every time you enter a new Singularity shell.


Running a predefined motion from the play_motion gallery in Gazebo

To simply simulate a predefined motion from the play_motion gallery in Gazebo, you should enter the Singularity shell, open an (empty) world in Gazebo and run your motion. In one terminal, enter the Singularity shell:

 $ singularity shell --nv /projects/robin/programs/sing-con/ros-melodic-pal/ros-melodic-pal.sif

This will open a Singularity shell and you should now see the prompt as Singularity>. Remember to use the --nv flag to be able to run GUI applications from inside the container. Remember to source ROS and the workspace like this:

 $ source /opt/ros/melodic/setup.bash
 $ source /tiago_public_ws/devel/setup.bash

Remember that you have to source every time you enter a Singularity shell. Next, launch Gazebo by running this command:

 $ roslaunch tiago_gazebo tiago_gazebo.launch world:=empty public_sim:=true end_effector:=pal-gripper

In another terminal, enter the Singularity shell again and run the following command in order to run the motion. You can choose which motion from the play_motion gallery you want to simulate. Look here for a list of all motions you can simulate from this gallery. Insert the name of the chosen motion instead of "NAME-OF-MOTION" in the command below to run the simulation.

 $ rosrun play_motion run_motion_python_node.py NAME-OF-MOTION

Then, go to the Gazebo window and observe how the robot simulates the chosen motion.


Running a predefined motion from the play_motion gallery on the physical Tiago

After you have simulated a program in Gazebo, you might want to try it out on the physical Tiago. Follow these steps to do so:

  • One Enter the Singularity shell like explained above.
  • Two source ROS and the workspace like explained above.
  • Three Set the ROS_MASTER_URI environment variable to be Tiago, if it is not already set. You can do so like this:
 $ export ROS_MASTER_URI=http://tiago-135c:11311
 $ export ROS_IP=vixen-nb.uio.no
  • Four Run the motion by running the same command as in the simulation case. To run any motion from the play_motion library, run the following command. Remember to change "NAME-OF-MOTION" to the name of the movement you want to do.
 $ rosrun play_motion run_motion_python_node.py NAME-OF-MOTION


How to make your own programs and simulate them in Gazebo trhough a container

You can also create and run your own programs to simulate in Gazebo. Since you are working with a premade, distributed container, you cannot make changes to it in order to add your own programs. But you do have access to your home directory, so you can create and store your own programs in the home directory and run them through the container as shown in the examples above. So, you can run all ROS-related commands inside the container, even though your workspace is stored in your home directory.

Personal tools
Front page