Simulating a laser scanner

In this section, we will see how to simulate a laser scanner in Gazebo. We can simulate it by providing custom parameters according to our application. When you install ROS, you also automatically install several default Gazebo plugins, which include Gazebo laser scanner plugin.

We can simply use this plugin and apply our custom parameters. For demonstration, you can use a tutorial package inside chapter_10_codes called sensor_sim_gazebo. You can simply copy the package to the workspace and build it using the catkin_make command. This package contains a basic simulation of the laser scanner, camera, IMU, ultrasonic sensor, and GPS.

Before starting with this package, you should install a package called hector-gazebo-plugins using the following command. This package contains Gazebo plugins of several sensors that can be used in self-driving car simulations.

    $ sudo apt-get install ros-kinetic-hector-gazebo-plugins

To start the laser scanner simulation, just use the following command:

    $ roslaunch sensor_sim_gazebo laser.launch

We'll first look at the output of the laser scanner and then dig into the code.

When you launch the preceding command, you will see an empty world with an orange box. The orange box is our laser scanner. You can use any mesh file to replace this shape according to your application. To show laser scanner data, we can place some objects in Gazebo, as shown here. You can add models from Gazebo's top panel.

Figure 14: Simulation of a laser scanner in Gazebo

You can visualize the laser data in Rviz, as shown in the next screenshot. The topic to which the laser data is coming is /laser/scan. You can add a LaserScan display type to view this data:

Figure 15: Visualization of laser scanner data in Rviz

You have to set the Fixed Frame to a world frame and enable the RobotModel and Axes display types in Rviz.

The following is the list of topics generated while simulating this sensor. You can see the /laser/scan topic.

Figure 16: List of topics from the laser scanner simulation
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.191.247