This tutorial intends to give a step-by-step guide into how to use ROS tools in conjunction with an Ignition based simulation. You should be able to achieve a result like the one in this video at the end of the tutorial.
We will be using Ignition Dome and ROS Melodic; however, please note that this tutorial is valid for Ignition releases that are compatible with ros_ign_bridge
and ROS releases that are compatible with teleop_twist_keyboard
and ros_ign
.
We'll start with the steps to complete the tutorial, and later will be explained what's going on behind the scenes.
-
Install Ignition Dome
- Instructions can be found here: Dome Installation
-
Install ROS Melodic
- Instructions can be found here: ROS Melodic Installation
-
Install
ros_ign
. We'll be using ROS Melodic version# Add https://packages.osrfoundation.org sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - sudo apt-get update # Install `ros_ign` sudo apt install ros-melodic-ros-ign
-
Install
teleop_twist_keyboard
sudo apt-get install ros-melodic-teleop-twist-keyboard
mkdir -p ~/ign_teleop_tutorial_ws/src
git clone [email protected]:Blast545/ign_tutorials.git ~/ign_teleop_tutorial_ws/src
cd ~/ign_teleop_tutorial_ws
catkin_make
We will open two different terminals sharing the same environment. In each, we'll run the following commands:
# Shell 1
source ~/ign_teleop_tutorial_ws/devel/setup.bash
roslaunch roslaunch ign_tutorials diff_drive_demo.launch
# Shell 2
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
After running this, you should have an environment similar to this one:
And in the teleop_twist_keyboard terminal you can send commands to the system to move the vehicle robot:
For this tutorial, we've used the example world tunnel.sdf
that includes a diff drive ground vehicle and shows various features available within the simulator. Including the ignition simulator, the whole system works like this:
- The
teleop_twist_keyboard
node transforms the user inputs into ROS Twist commands. - The
ros_ign_bridge
subscribes to those ROS Twist commands and converts them to Ignition Transport msgs. - The Ignition Transport msgs are used by diff drive plugin inside the tunnel.sdf that's running in the simulator.
- The simulator moves the robot accordingly, based on the diff drive plugin output.
We can see from the command used for the ros_bridge within the launchfile:
<node
pkg="ros_ign_bridge"
type="parameter_bridge"
name="$(anon ros_ign_bridge)"
output="screen"
args="/model/vehicle/odometry@nav_msgs/[email protected] /cmd_vel@geometry_msgs/[email protected] ">
</node>
The msg input/output goes to the /cmd_vel topic (this topic applies to both the Ignition Transport and ROS), it takes geometry_msgs/Twist
as input and uses ignition.msgs.Twist
as output. Same principle applies for the odometry information displayed in rviz
.
Also, taking a look to the SDF file from ign_ws/src/ign-gazebo/examples/worlds/tunnel.sdf
we can see:
<plugin
filename="ignition-gazebo-diff-drive-system"
name="ignition::gazebo::systems::DiffDrive">
<left_joint>left_rear_wheel</left_joint>
<left_joint>left_front_wheel</left_joint>
<right_joint>right_rear_wheel</right_joint>
<right_joint>right_front_wheel</right_joint>
<wheel_separation>1.25</wheel_separation>
<wheel_radius>0.3</wheel_radius>
<odom_publish_frequency>1</odom_publish_frequency>
<topic>cmd_vel</topic>
</plugin>
This is the diff drive plugin configured to receive commands in the cmd_vel
topic and to control the four joints: left_rear_wheel
, left_front_wheel
, right_rear_wheel
and right_front_wheel
that control the movement of the ground vehicle.
As homework, can you tackle some challenges to continue the work provided here?
- Try sending commands to the robot using directly the Ignition Transport layer.
- Check this ignition tutorial: Moving the robot.
- Check the structure of the
tunnel.sdf
model.
- Can you change the launchile to use a different physics engine? Like TPE.
- Check
ign-physics
tutorial: Switching physics engines.
- Check
- The
diff_drive.sdf
example world (ign_ws/src/ign-gazebo/examples/worlds/diff_drive.sdf
) does not use the samecmd_vel
topic to receive velocity commands, can you modify the commands to make it work in this scenario?- Check the
diff_drive.sdf
example commands and adjust theros_ign
bridges properly.
- Check the
Want to dig deeper inside Ignition gazebo? Browse the following links:
- Browse the main Ignition portal.
- Browse the official tutorials for Ignition Dome.
- Check discussions and announcements in the Gazebo/Ignition community forum.