The previous tutorials have led us through the process of creating a sensor model, and improving the model's visual appearance. This tutorial will improve the output from the sensor through the addition of noise.
Every, or nearly every, sensor has noise in the output. Cameras can have chromatic aberrations, sonars multi-path effects, and lasers incorrect distance readings. We have to add noise to the data generated in simulation in order to more closely match the type of data a real sensor produces.
Gazebo has a built in noise model that can apply Gaussian noise to a variety of sensors. While Gaussian noise may not be very realistic, it is better than nothing and serves as a good first-pass approximation of noise. Gaussian noise is also relatively easy to apply to data streams.
For more information on Gazebo's sensor noise model, visit this tutorial.
Let's start by looking at the current Velodyne output, and then we can add noise.
Open Gazebo, and insert the Velodyne sensor.
gazebo
Add a Box in front of the laser beams, so that we get useful data.
Left click in front the laser beams to place the box.
We can get a closer look at the sensor data through Gazebo's topic visualizer.
Press Ctrl-t, to open the topic selector. Find the
/gazebo/default/velodyne/top/sensor/scan
topic.
Select the /gazebo/default/velodyne/top/sensor/scan
topic, and
press Okay to open a laser visualizer.
Notice the nice smooth lines of the outptut.
Gazebo's noise model can be accessed using the <noise>
tag. See
sdformat.org/spec for more information.
Open the Velodyne model.
gedit ~/.gazebo/models/velodyne_hdl32/model.sdf
Add a <noise>
element as a child of the <ray>
element. We will apply
a large amount of noise at first so that the effects are readily visible.
<sensor type="ray" name="sensor">
<pose>0 0 -0.004645 1.5707 0 0</pose>
<visualize>true</visualize>
<ray>
<noise>
<!-- Use gaussian noise -->
<type>gaussian</type>
<mean>0.0</mean>
<stddev>0.1</stddev>
</noise>
Once again, add the Velodyne sensor to Gazebo, and insert a box in front of the beams.
Open the topic visualizer (Ctrl-t), and select the Velodyne laser scan topic. The output should look very noisy.
Now let's reduce the noise to something reasonable.
<sensor type="ray" name="sensor">
<pose>0 0 -0.004645 1.5707 0 0</pose>
<visualize>true</visualize>
<ray>
<noise>
<!-- Use gaussian noise -->
<type>gaussian</type>
<mean>0.0</mean>
<stddev>0.02</stddev>
</noise>
In the next section we will modify the Velodyne model so that it can be easily shared and reused.