• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型

人工智能 我是。 2860次浏览 0个评论

文章目录

  • Step 1 建立基本的sdf模型
    • 1、创建新的.world文件
    • 2、添加地面和光线
    • 3、添加基础部件
  • Step2 添加惯性
    • 1、查看当前的惯性值。
    • 2、添加惯性信息
  • Step3 添加关节(joint)
    • 1、定义关节
    • 2、检验效果
  • Step4 添加传感器
    • 1、添加传感器到顶部link
    • 2、设置传感器
    • 3、开始仿真看下效果
  • 下一篇

本教程基于ubuntu系统

  创建新模型时的第一步是收集相关模型信息。Velodyne LiDAR公司已在其网站上提供了有关其传感器的文档 。如果没有有关模型的详细信息,则可以测量物理版本,向制造商询问规格,或者在最坏的情况下进行猜测。   根据Velodyne文档,我们将创建具有以下功能的传感器:

  • 基础圆柱体和顶部圆柱体,顶部圆柱体在能够旋转
  • 创建垂直圆柱体的一组定向激光。

Step 1 建立基本的sdf模型

1、创建新的.world文件

 

gedit velodyne.world

  界面如下,大家也可以选择自己习惯的文本编辑器,这里只是示范。  
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型  

2、添加地面和光线

 

<?xml version="1.0" ?>
<sdf version="1.5">
  <world name="default">

    <!-- A global light source -->
    <include>
      <uri>model://sun</uri>
    </include>

    <!-- A ground plane -->
    <include>
      <uri>model://ground_plane</uri>
    </include>
  </world>
</sdf>

 

3、添加基础部件

接下来,我们将Velodyne LiDAR的基础部分添加到SDF world文件中。我们将使用Velodyne传感器尺寸来构造基础圆柱体和顶部圆柱体。下面是Velodyne 2D绘图的屏幕截图。  
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型   在<world></world>块中添加以下内容  

<model name="velodyne_hdl-32">
  <!-- Give the base link a unique name -->
  <link name="base">

    <!-- Offset the base by half the lenght of the cylinder -->
    <pose>0 0 0.029335 0 0 0</pose>
    <collision name="base_collision">
      <geometry>
        <cylinder>
          <!-- Radius and length provided by Velodyne -->
          <radius>.04267</radius>
          <length>.05867</length>
        </cylinder>
      </geometry>
    </collision>

    <!-- The visual is mostly a copy of the collision -->
    <visual name="base_visual">
      <geometry>
        <cylinder>
          <radius>.04267</radius>
          <length>.05867</length>
        </cylinder>
      </geometry>
    </visual>
  </link>

  <!-- Give the base link a unique name -->
  <link name="top">

    <!-- Vertically offset the top cylinder by the length of the bottom
        cylinder and half the length of this cylinder. -->
    <pose>0 0 0.095455 0 0 0</pose>
    <collision name="top_collision">
      <geometry>
        <cylinder>
          <!-- Radius and length provided by Velodyne -->
          <radius>0.04267</radius>
          <length>0.07357</length>
        </cylinder>
      </geometry>
    </collision>

    <!-- The visual is mostly a copy of the collision -->
    <visual name="top_visual">
      <geometry>
        <cylinder>
          <radius>0.04267</radius>
          <length>0.07357</length>
        </cylinder>
      </geometry>
    </visual>
  </link>
</model>

  以暂停仿真的状态启动gazebo,看下模型效果,cd到文件所在路径,在命令行中输入gazebo velodyne.world -u  
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型   默认情况下,标签定义了模型的外观。标签定义与其他模型碰撞时的表现。要查看和调试模型上的属性,右键,然后选择viewCollisions。您将看到两个圆柱体(由于靠近而看起来像一个圆柱体)。  
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型  

Step2 添加惯性

我们有了一个Velodyne模型,但是该模型缺乏诸如惯性矩阵之类的动态属性。物理引擎使用惯性信息来计算模型在受力作用时的行为。如果没有或错误惯性值,模型在进行物理仿真的时候会表现得很奇怪。  

1、查看当前的惯性值。

在gazebo运行的情况下,右键单击Velodyne模型,然后选择View->Inertia。然后会出现以下画面。  
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型  

通常,每个紫色框应大致匹配与其关联的链接的大小。由于我们的模型缺少惯性信息,当前的惯性盒尺寸过大。

2、添加惯性信息

我们可以通过同时指定质量矩阵和惯性矩阵来向链接添加惯性。我们将Velodyne的质量设定为1.3kg,使用相关公式来计算惯性矩矩阵 。   在<link name="base">块中添加以下内容:  

<model name="velodyne_hdl-32">
  <link name="base">
    <pose>0 0 0.029335 0 0 0</pose>
    <inertial>
      <mass>1.2</mass>
      <inertia>
        <ixx>0.001087473</ixx>
        <iyy>0.001087473</iyy>
        <izz>0.001092437</izz>
        <ixy>0</ixy>
        <ixz>0</ixz>
        <iyz>0</iyz>
      </inertia>
    </inertial>

  在<link name="top">块中添加以下内容:  

 <link name="top">
   <pose>0 0 0.095455 0 0 0</pose>
   <inertial>
     <mass>0.1</mass>
     <inertia>
       <ixx>0.000090623</ixx>
       <iyy>0.000090623</iyy>
       <izz>0.000091036</izz>
       <ixy>0</ixy>
       <ixz>0</ixz>
       <iyz>0</iyz>
     </inertia>
   </inertial>

  设置好后,会有以下效果:  
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型  

Step3 添加关节(joint)

joint定义了每个link之间的约束。在机器人领域,最常见的关节类型是revolute(旋转)。旋转关节定义了两个连杆之间的单个旋转自由度。完整的关节列表可以在SDF网站上找到。

1、定义关节

我们将定义一个顶部围绕底部旋转的关节,在前添加以下内容  

<!-- Each joint must have a unique name -->
<joint type="revolute" name="joint">

  <!-- Position the joint at the bottom of the top link -->
  <pose>0 0 -0.036785 0 0 0</pose>

  <!-- Use the base link as the parent of the joint -->
  <parent>base</parent>

  <!-- Use the top link as the child of the joint -->
  <child>top</child>

  <!-- The axis defines the joint's degree of freedom -->
  <axis>

    <!-- Revolve around the z-axis -->
    <xyz>0 0 1</xyz>

    <!-- Limit refers to the range of motion of the joint -->
    <limit>

      <!-- Use a very large number to indicate a continuous revolution -->
      <lower>-10000000000000000</lower>
      <upper>10000000000000000</upper>
    </limit>
  </axis>
</joint>

  运行gazebo,点击模型,右键View->JointsView->Transparent我们能看到以下效果:  
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型  

2、检验效果

我们可以使用“关节命令”图形工具来验证关节是否正确旋转。拖动右侧面板在主窗口上打开,然后选择Velodyne模型。使用Force部件中的选项卡向关节施加较小的力(0.01即可)。取消暂停世界,您应该看到可视化的关节开始围绕模型的Z轴旋转。   至此,我们有了一个具有有效惯性,碰撞和关节属性的Velodyne模型。接下来,我们将添加传感器。  
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型  

Step4 添加传感器

传感器用于从环境或模型生成数据。在本节中,我们将为Velodyne模型添加一个激光传感器。gazebo中的激光传感器可以发出一个或多个光束,这些光束会产生距离以及可能的强度数据。   在sdf文件中,该传感器由<scan><range>两个部分组成,<scan>定义波束的布局和数量,<range>限定一个单独的束的性质   <scan>中包含<horizontal><vertical>两个块。<horizontal>组件定义在水平平面中发出的光线,该<vertical>组件定义在垂直平面中发出的光线。   Velodyne传感器需要垂直射线,然后旋转。我们将其模拟为旋转的水平扇面。我们之所以采用这种方法,是因为在gazebo中可视化数据会更容易一些。Velodyne规格表明HDL-32具有32束光线,垂直视场在+10.67到-30.67度之间。  

1、添加传感器到顶部link

<link name="top">中添加以下内容  

<!-- Add a ray sensor, and give it a name -->
<sensor type="ray" name="sensor">

  <!-- Position the ray sensor based on the specification. Also rotate
       it by 90 degrees around the X-axis so that the <horizontal> rays
       become vertical -->
  <pose>0 0 -0.004645 1.5707 0 0</pose>

  <!-- Enable visualization to see the rays in the GUI -->
  <visualize>true</visualize>

  <!-- Set the update rate of the sensor -->
  <update_rate>30</update_rate>
</sensor>

 

2、设置传感器

紧跟上面内容<update_rate>30</update_rate>,添加以下内容  

<ray>

  <!-- The scan element contains the horizontal and vertical beams.
       We are leaving out the vertical beams for this tutorial. -->
  <scan>

    <!-- The horizontal beams -->
    <horizontal>
      <!-- The velodyne has 32 beams(samples) -->
      <samples>32</samples>

      <!-- Resolution is multiplied by samples to determine number of
           simulated beams vs interpolated beams. See:
           http://sdformat.org/spec?ver=1.6&elem=sensor#horizontal_resolution
           -->
      <resolution>1</resolution>

      <!-- Minimum angle in radians -->
      <min_angle>-0.53529248</min_angle>

      <!-- Maximum angle in radians -->
      <max_angle>0.18622663</max_angle>
    </horizontal>
  </scan>

  <!-- Range defines characteristics of an individual beam -->
  <range>

    <!-- Minimum distance of the beam -->
    <min>0.05</min>

    <!-- Maximum distance of the beam -->
    <max>70</max>

    <!-- Linear resolution of the beam -->
    <resolution>0.02</resolution>
  </range>
</ray>

 

3、开始仿真看下效果

 
gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型  


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明gazebo教程(三)创建 Velodyne HDL-32 LiDAR传感器模型
喜欢 (0)

您必须 登录 才能发表评论!

加载中……