Visualising in Gazebo
Robot in a 3D simulated world
A Gazebo simulation is a robot simulation made with Gazebo, a 3D simulator with the ability to accurately and efficiently simulate populations of robots in complex indoor and outdoor environments. With Gazebo you are able to create a 3D scenario on your computer with robots, obstacles and many other objects. Gazebo also uses a physical engine for illumination, gravity, inertia, etc. You can evaluate and test your robot in difficult or dangerous scenarios without any harm to your robot. Most of the time it is faster to run a simulator instead of starting the whole scenario on your real robot.
Installing Gazebo
Gazebo is not installed in ROS 2 by default. We will install the classic version of gazebo.
Copying Gazebo example files
Copy wolf-robot
folder from t3_gazebo_teleoperation
to src
folder in your workspace.
The above command runs joint state publisher. It also makes sure simulated time is set to true so that gazebo sets the time and all other packages are in sync. We can even check if simulated time is being used by typing:
With all the checks correct, try the following code to visualize your robot in a 3D simulated world. Remember to type each one in a new terminal tab or window after sourcing it.
Launch Files
To make things easy, all the above scripts can be included in a single launch file. Launch files basically allow different nodes and services to be run in a sequential order. Launch files have an xml structure and end with a .launch extension.
Controlling a Simulated Robot
To Control the robot in simulated world, we can run teleop (teleoperation) twist keyboard.
We have created a construction world file called construction.world with few objects placed already. To view this world in gazebo, use:
Lastly, To check if cmd_val
is passed, type : ros2 topic echo /cmd_vel
Last updated