Simulating an ultrasonic sensor in Gazebo
Ultrasonic sensors also play a key role in self-driving cars. We've already seen that range sensors are widely used in parking assistant systems. In this section, we are going to see how to simulate a range sensor in Gazebo. The range sensor Gazebo plugin is already available in the hector
Gazebo ROS plugin, so we can just use it in our code.
Like we did in earlier demos, we will first see how to run the simulation and watch the output.
The following command will launch the range sensor simulation in Gazebo:
$ roslaunch sensor_sim_gazebo sonar.launch
In this simulation, we are taking the actual 3D model of the sonar, and it's very small. You may need to zoom in Gazebo to view the model. We can test the sensor by putting an obstacle in front of it. We can start Rviz and can view the distance using the Range display type. The topic name is /distance
and the Fixed Frame is world.
Here is the range sensor value when the obstacle is far away:
...