锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

Gazebo使用笔记(10) —— gazebo插件与传感器的添加

时间:2022-08-27 09:30:00 exact传感器

文章目录

  • 0. 插件类型
        • 添加ModelPlugin
        • 添加SensorPlugin
  • 1. 相机
        • 普通相机
        • 多机位相机
        • 深度相机
  • 2. 激光
        • GPU Laser
        • Laser
        • Block Laser
  • 3. IMU
        • IMU (GazeboRosImu)
        • IMU sensor (GazeboRosImuSensor)
  • 4. 其他
        • F3D (Force Feedback Ground Truth)
        • Force
        • Joint Pose Trajectory
        • P3D (3D Position Interface for Ground Truth)
        • 保险杠
        • 差速驱动
        • 防滑转向驱动
        • 视频插件
        • 平面移动插件
  • Node:

0. 插件类型

目前有6种插件类型:

  • World
  • Model
  • Sensor
  • System
  • Visual
  • GUI

可通过URDF文件引用类型:

  • ModelPlugins, 提供对 physics::Model API访问,传送门
  • SensorPlugins, 提供对 sensors::Sensor API访问,传送门
  • VisualPlugins, 提供对 rendering::Visual API访问,传送门

添加ModelPlugin

用于指示传递gazebo的信息

<robot>   ... robot description ...   <gazebo>     <plugin name="differential_drive_controller" filename="libdiffdrive_plugin.so">       ... plugin parameters ...     plugin>   gazebo>   ... robot description ... robot> 

添加SensorPlugin

连接到link

<robot>   ... robot description ...   <link name="sensor_link">     ... link description ...   link>    <gazebo reference="/span>sensor_link"> <sensor type="camera" name="camera1"> ... sensor parameters ... <plugin name="camera_controller" filename="libgazebo_ros_camera.so"> ... plugin parameters .. plugin> sensor> gazebo> robot> 

1. 相机

普通相机


  <joint name="camera_joint" type="fixed">
    <axis xyz="0 1 0" />
    <origin xyz="${camera_link} 0 ${height3 - axel_offset*2}" rpy="0 0 0"/>
    <parent link="link3"/>
    <child link="camera_link"/>
  joint>


  
  <link name="camera_link">
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
    <box size="${camera_link} ${camera_link} ${camera_link}"/>
      geometry>
    collision>

    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
    <box size="${camera_link} ${camera_link} ${camera_link}"/>
      geometry>
      <material name="red"/>
    visual>

    <inertial>
      <mass value="1e-5" />
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
    inertial>
  link>


  
  <gazebo reference="camera_link">
    <sensor type="camera" name="camera1">
      
      <update_rate>30.0update_rate>
      <camera name="head">
        
        <horizontal_fov>1.3962634horizontal_fov>
        <image>
          <width>800width>
          <height>800height>
          <format>R8G8B8format>
        image>
        <clip>
          <near>0.02near>
          <far>300far>
        clip>
        <noise>
          <type>gaussiantype>
          
          <mean>0.0mean>
          <stddev>0.007stddev>
        noise>
      camera>
      
      <plugin name="camera_controller" filename="libgazebo_ros_camera.so">
        <alwaysOn>truealwaysOn>
        <updateRate>0.0updateRate>
        
        <cameraName>rrbot/camera1cameraName>
        
        <imageTopicName>image_rawimageTopicName>
		        
        <cameraInfoTopicName>camera_infocameraInfoTopicName>
        
			
		   
        <frameName>camera_linkframeName>
        <hackBaseline>0.07hackBaseline>
        <distortionK1>0.0distortionK1>
        <distortionK2>0.0distortionK2>
        <distortionK3>0.0distortionK3>
        <distortionT1>0.0distortionT1>
        <distortionT2>0.0distortionT2>
      plugin>
    sensor>
  gazebo>

注意:①传感器的名称必须是唯一的;②gazebo reference的名称必须与相应的link名称相同

多机位相机

同步多个相机的快门,以便它们将图像一起发布。通常用于立体摄像机,使用与纯Camera插件非常相似的界面。


注意:目前仅支持stereo cameras

以Atlas的双目相机为例:

  <gazebo reference="left_camera_frame">
    <sensor type="multicamera" name="stereo_camera">
      <update_rate>30.0update_rate>
      <camera name="left">
        <horizontal_fov>1.3962634horizontal_fov>
        <image>
          <width>800width>
          <height>800height>
          <format>R8G8B8format>
        image>
        <clip>
          <near>0.02near>
          <far>300far>
        clip>
        <noise>
          <type>gaussiantype>
          <mean>0.0mean>
          <stddev>0.007stddev>
        noise>
      camera>
      <camera name="right">
        <pose>0 -0.07 0 0 0 0pose>
        <horizontal_fov>1.3962634horizontal_fov>
        <image>
          <width>800width>
          <height>800height>
          <format>R8G8B8format>
        image>
        <clip>
          <near>0.02near>
          <far>300far>
        clip>
        <noise>
          <type>gaussiantype>
          <mean>0.0mean>
          <stddev>0.007stddev>
        noise>
      camera>
      <plugin name="stereo_camera_controller" filename="libgazebo_ros_multicamera.so">
        <alwaysOn>truealwaysOn>
        <updateRate>0.0updateRate>
        <cameraName>multisense_sl/cameracameraName>
        <imageTopicName>image_rawimageTopicName>
        <cameraInfoTopicName>camera_infocameraInfoTopicName>
        <frameName>left_camera_optical_frameframeName>
        
        <hackBaseline>0.07hackBaseline>
        <distortionK1>0.0distortionK1>
        <distortionK2>0.0distortionK2>
        <distortionK3>0.0distortionK3>
        <distortionT1>0.0distortionT1>
        <distortionT2>0.0distortionT2>
      plugin>
    sensor>
  gazebo>

深度相机

以Kinect为例:

<gazebo reference="${link_name}">
  <sensor name="${link_name}_camera" type="depth">
    <update_rate>20update_rate>
    <camera>
      <horizontal_fov>1.047198horizontal_fov>
      <image>
        <width>640width>
        <height>480height>
        <format>R8G8B8format>
      image>
      <clip>
        <near>0.05near>
        <far>3far>
      clip>
    camera>
    <plugin name="${link_name}_controller" filename="libgazebo_ros_openni_kinect.so">
      <baseline>0.2baseline>
      <alwaysOn>truealwaysOn>
      <updateRate>1.0updateRate>
      <cameraName>${camera_name}_ircameraName>
      <imageTopicName>/${camera_name}/color/image_rawimageTopicName>
      <cameraInfoTopicName>/${camera_name}/color/camera_infocameraInfoTopicName>
      <depthImageTopicName>/${camera_name}/depth/image_rawdepthImageTopicName>
      <depthImageInfoTopicName>/${camera_name}/depth/camera_infodepthImageInfoTopicName>
      <pointCloudTopicName>/${camera_name}/depth/pointspointCloudTopicName>
      <frameName>${frame_name}frameName>
      <pointCloudCutoff>0.5pointCloudCutoff>
      <pointCloudCutoffMax>3.0pointCloudCutoffMax>
      <distortionK1>0.00000001distortionK1>
      <distortionK2>0.00000001distortionK2>
      <distortionK3>0.00000001distortionK3>
      <distortionT1>0.00000001distortionT1>
      <distortionT2>0.00000001distortionT2>
      <CxPrime>0CxPrime>
      <Cx>0Cx>
      <Cy>0Cy>
      <focalLength>0focalLength>
      <hackBaseline>0hackBaseline>
    plugin>
  sensor>
gazebo>

关于配置深度相机的更详细说明参见:传送门

2. 激光

GPU Laser

如sensor_msgs中所述,通过广播LaserScan消息来模拟激光测距传感器,参考https://wiki.ros.org/hokuyo_node

 <joint name="hokuyo_joint" type="fixed">
    <axis xyz="0 1 0" />
    <origin xyz="0 0 ${height3 - axel_offset/2}" rpy="0 0 0"/>
    <parent link="link3"/>
    <child link="hokuyo_link"/>
  joint>

  
  <link name="hokuyo_link">
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
    <box size="0.1 0.1 0.1"/>
      geometry>
    collision>

    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://rrbot_description/meshes/hokuyo.dae"/>
      geometry>
    visual>

    <inertial>
      <mass value="1e-5元器件数据手册IC替代型号,打造电子元器件IC百科大全!
          

相关文章