Day 3: Sense the world
We will show how to add sensors to our basic differential drive model. Once equipped with sensors, our robot will be sufficiently equipped to use the , which will enable it to move on its own!
Adding a camera
Let’s add some sensors to our robot. If you already created some environment, you can now see what it is, with the eyes of your robot. For this we have to add a camera plugin to our robot model. For that, two things are necessary, a link and the actual plugin.
Add a joint to connect the camera link in the main model file:
After that, add the camera link in the main model file :
And now add the plugin to the gazebo file:
Gazebo/Blue 30.0 1.3962634 800 800 R8G8B8 0.02 300 true 0.0 mybot/camera1 image_raw camera_info camera_link 0.07 0.0 0.0 0.0 0.0 0.0
Launch your simulation, and add some object in front of the robot. You can obtain the camera image as with any ROS compatible camera, by subscribing to the image topic. You can use the image_view tool to visualize it directly:
rosrun image_view image_view image:=/mybot/camera1/image_raw
Visualisation with RViz
Rviz is one of these fantastic tools that will make you love ROS. It’s capable of visualizing many different kind of information in the same interface. To start rviz:
rosrun rviz rviz
At the bottom left of the window there is an “add” button which allows you to load visualization plugins. In the parameters of these plugins you generally have to define the topic name to which the plugin subscribes, this should be fairly straightforward. A Rviz configuration file is provided with the sources and started by default in the launch file.
Here is an example visualization with plugins for: the robot model, the 3D transforms TF, the camera Image, the odometry: