ROS教程 Gazebo仿真(2)-激光雷达

接上一篇

ROS教程 Gazebo仿真(1)–ros_control两轮差速控制
https://blog.csdn.net/weixin_43928944/article/details/115899503

配置激光雷达

laser_sensors.xacro

<robot name="my_sensors" xmlns:xacro="http://wiki.ros.org/xacro">

  <!-- 雷达 -->
  <gazebo reference="laser">
    <sensor type="ray" name="rplidar">
      <pose>0 0 0 0 0 0</pose>
      <visualize>true</visualize>
      <update_rate>5.5</update_rate>
      <ray>
        <scan>
          <horizontal>
            <samples>360</samples>
            <resolution>1</resolution>
            <min_angle>-3</min_angle>
            <max_angle>3</max_angle>
          </horizontal>
        </scan>
        <range>
          <min>0.10</min>
          <max>30.0</max>
          <resolution>0.01</resolution>
        </range>
        <noise>
          <type>gaussian</type>
          <mean>0.0</mean>
          <stddev>0.01</stddev>
        </noise>
      </ray>
      <plugin name="gazebo_rplidar" filename="libgazebo_ros_laser.so">
        <topicName>/scan</topicName>
        <frameName>laser</frameName>
      </plugin>
    </sensor>
  </gazebo>

</robot>

robt_car.xacro

<robot name="robot_car" xmlns:xacro="http://wiki.ros.org/xacro">
    <xacro:include filename="inertia.xacro" />    
    <xacro:include filename="robot_base.xacro" />
    <xacro:include filename="camera.xacro" />
    <xacro:include filename="laser.xacro" />

    <xacro:include filename="gazebo/move.xacro" />
    <xacro:include filename="gazebo/laser_sensors.xacro" />
</robot>

在这里插入图片描述
rviz launch

unch>
    <param name="robot_description" command="$(find xacro)/xacro $(find robot_description)/urdf/robot_car.xacro" />

    <node pkg="rviz" type="rviz" name="rviz" args="-d $(find robot_description)/config/car.rviz" />
    <node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher" output="screen" />
    <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen" />
    <node pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" name="joint_state_publisher_gui" output="screen" />

</launch>

在这里插入图片描述
启动rviz的launch Add添加LaserScan 将Topic修改为/scan 配置完成。

以下是将该代码转换为 SDF 文件的示例: ``` <?xml version="1.0"?> <sdf version="1.6"> <model name="livox_sensor"> <link name="link"> <sensor name="laser_sensor" type="ray"> <pose>0 0 0 0 0 0</pose> <visualize>true</visualize> <update_rate>10</update_rate> <plugin name="livox_sensor_plugin" filename="liblivox_laser_simulation.so"> <ray> <scan> <horizontal> <samples>100</samples> <resolution>1</resolution> <min_angle>0</min_angle> <max_angle>6.28318530718</max_angle> </horizontal> <vertical> <samples>360</samples> <resolution>1</resolution> <min_angle>-0.12603669438</min_angle> <max_angle>0.96144910243</max_angle> </vertical> </scan> <range> <min>0.05</min> <max>120</max> <resolution>0.01</resolution> </range> <noise> <type>gaussian</type> <mean>0</mean> <stddev>0.01</stddev> </noise> </ray> <visualize>true</visualize> <samples>1</samples> <downsample>1</downsample> <csv_file_name>/home/kuper/PX4_Firmware/Tools/sitl_gazebo/models/livox/scan_mode/mid360.csv</csv_file_name> <ros_topic>livox_scan</ros_topic> </plugin> </sensor> </link> </model> </sdf> ``` 请注意以下更改: - `<gazebo>` 标记已更改为 `<sdf>` 标记,因为我们正在创建 SDF 文件。 - `reference="${name}"` 属性已被删除。SDF 不需要此属性。 - `visualize`,`update_rate`,`laser_min_range` 和 `laser_max_range` 属性已被替换为 `<visualize>`,`<update_rate>`,`<range><min>` 和 `<range><max>` 元素。 - `<plugin>` 元素已被移动到 `<sensor>` 元素内部,并使用新属性 `name` 和 `filename`。 - `<horizontal>` 和 `<vertical>` 元素现在包含所有相关属性。 - 您可能需要对 `<min_angle>` 和 `<max_angle>` 元素中的角度进行转换,因为某些 Gazebo 版本使用弧度,而其他版本使用度数。 - `<ros_topic>` 元素现在包含您想要将激光扫描数据发布到的 ROS 话题名称。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值