gazebo中激光雷达组件的使用

gazebo中,激光雷达(lidar)是最常用的传感器之一,其主要用于感知障碍物与车辆之间的距离信息,是进行slam、主动避障等任务所必须的传感器。

gazebo中自带的激光雷达组件(plugins)有两种:libgazebo_ros_gpu_laser.so和libgazebo_ros_velodyne_laser.so。

其中libgazebo_ros_gpu_laser.so输出的数据格式为LaserScan,而libgazebo_ros_velodyne_laser.so输出的数据格式为pointcloud2,这是二者最为重要的区别,同时libgazebo_ros_gpu_laser.so插件通常用于单线激光雷达,而后者则多用于多线激光雷达。

二者典型的代码格式如下:

    <gazebo reference="fastHokuyo">
      <sensor type="ray" name="vodyne16">
        <pose>0 0 0 0 0 0</pose>
        <visualize>false</visualize>
        <update_rate>10</update_rate>
        <ray>
          <scan>
            <horizontal>
              <samples>500</samples> 
              <resolution>0.5</resolution>
              <min_angle>-3.14</min_angle>
              <max_angle> 3.14</max_angle>
            </horizontal>
            <vertical>
              <samples>1</samples>
              <resolution>2</resolution>
              <min_angle>0</min_angle>
              <max_angle>0.5*3.14</max_angle>
            </vertical>
          </scan>
          <range>
            <min>0.055</min>
            <max>100.0</max>
            <resolution>0.05</resolution>
          </range>
          <noise>
            <type>gaussian</type>
            <mean>0.0</mean>
            <stddev>0.0</stddev>
          </noise>
        </ray>
        <plugin name="gazebo_ros_laser_controller" filename="libgazebo_ros_velodyne_laser.so">
          <topicName>/ros_lidar</topicName>
          <frameName>fastHokuyo</frameName>
          <min_range>0.9</min_range>
          <max_range>130.0</max_range>
          <gaussianNoise>0.0</gaussianNoise>
        </plugin>
      </sensor>
    </gazebo> 
  <gazebo reference="fastHokuyo">
    <sensor type="gpu_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>1440</samples>
            <resolution>1</resolution>
            <min_angle>-3.14</min_angle>
            <max_angle>3.14</max_angle>
          </horizontal>
        </scan>
        <range>
          <min>0.10</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>1.570796
      <plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_gpu_laser.so">
        <topicName>/ros_lidar</topicName>
        <frameName>fastHokuyo</frameName>
      </plugin>
    </sensor>
  </gazebo>