We need to launch several terminals in order to launch the gazebo simulation with ROS 2.0 compatibility, there are three main steps:
First thing we will do is launching the simulation with ROS 2.0 compatibility. For this, we need to source some environment variables in our terminal.
The first two lines are in charge of loading the environment variables of Gazebo and ROS 2.0. Then we need to extend the environment variable
GAZEBO_MODEL_PATH with the models' install location.
Finally we launch Gazebo with the
-s libgazebo_ros_factory.so option, which will forward command line arguments to ROS 2.0. It will provide the
spawn_entity service for spawning SDF/URFS models and lights into the simulation, and the
delete_entity service for the deletion of models and lights from the simulation. We are also including
--verbose to print all gazebo ros messages in order to debug possible errors.
source ~/ros2_mara_ws/install/setup.bash source /usr/share/gazebo/setup.sh export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/ros2_mara_ws/src/MARA gazebo --verbose -s libgazebo_ros_factory.so
You will see:
Right now Gazebo is launched, but it's not simulating any robot. To spawn a model we need to execute the following python script:
source ~/ros2_mara_ws/install/setup.bash ros2 run mara_utils_scripts spawn_entity.py
After this you will see the robot in the Gazebo world:
Launch another terminal, this one to publish the transformations between links:
source ~/ros2_mara_ws/install/setup.bash ros2 launch mara_bringup mara_bringup.launch.py
Finally we have the option to visualize the robot in RVIZ2.
source ~/ros2_mara_ws/install/setup.bash rviz2
Check this tutorial