Explaining the simulation code

The sensor_sim_gazebo package has the following list of files for simulating all self-driving car sensors. Here is the directory structure of this package:

Explaining the simulation code

Figure 17: List of files in sensor_sim_gazebo

To simulate a laser, launch the laser.launch file; similarly, to start simulating the IMU, GPS, and camera, launch the corresponding launch files. Inside URDF, you can see the Gazebo plugin definition for each sensor. The sensor.xacro file is the orange box definition that you saw in the preceding simulation. It is just a box for visualizing a sensor model. We are using this model for representing all the sensors inside this package. You can use your own model instead of this, too.

The laser.xacro file has the Gazebo plugin definition of the laser, as shownhere:

      <gazebo reference="sensor"> 
        <sensor type="ray" name="head_hokuyo_sensor"> 
          <pose>0 0 0 0 0 0</pose> 
          <visualize>false</visualize> 
          <update_rate>40</update_rate> 
          <ray> 
            <scan> 
              <horizontal> 
                <samples>720</samples> 
                <resolution>1</resolution> 
                <min_angle>-1.570796</min_angle> 
                <max_angle>1.570796</max_angle> 
              </horizontal> 
            </scan> 
            <range> 
              <min>0.8</min> 
              <max>30.0</max> 
              <resolution>0.01</resolution> 
            </range> 
            <noise> 
              <type>gaussian</type> 
              <!-- Noise parameters based on published spec for Hokuyo 
    laser 
                   achieving "+-30mm" accuracy at range < 10m.  A mean 
    of 0.0m and 
                   stddev of 0.01m will put 99.7% of samples within 
    0.03m of the true 
                    reading. --> 
              <mean>0.0</mean> 
              <stddev>0.01</stddev> 
             </noise> 
          </ray> 
          <plugin name="gazebo_ros_head_hokuyo_controller" 
     filename="libgazebo_ros_laser.so"> 
            <topicName>/laser/scan</topicName> 
            <frameName>world</frameName> 
          </plugin> 
        </sensor> 
       </gazebo> 

Here, you can see various parameters of the laser scanner plugin. We can fine-tune these parameters for our custom applications. The plugin we've used here is libgazebo_ros_laser.so, and all the parameters are passed to this plugin.

In the laser.launch file, we are creating an empty world and spawning the laser.xacro file. Here is the code snippet to spawn the model into Gazebo and start a joint-state publisher to start publishing TF data:

      <param name="robot_description" command="$(find xacro)/xacro --
    inorder '$(find sensor_sim_gazebo)/urdf/laser.xacro'" /> 
 
      <node pkg="gazebo_ros" type="spawn_model" name="spawn_model" 
    args="-urdf -param /robot_description -model example"/> 
 
      <node pkg="robot_state_publisher" type="robot_state_publisher" 
    name="robot_state_publisher"> 
        <param name="publish_frequency" type="double" value="30.0" /> 
      </node> 
..................Content has been hidden....................

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