学习的内容:
(1)创建HDL-32传感器的SDF文件模型
(2)将创建的模型应用到gazebo的模型库
(3)实现模型的显示和输出
(4)使用插件控制模型
(5)在gazebo和RViz中可视化模型
《一》模型的创建
模型:
(1)a base cylinder and top cylinder, where the top cylinder spins, and
(2)a set of laser rays oriented in the vertical fan.
step 1:创建world文件
选择一个文件夹,打开终端输入:gedit velodyne.world
在文件中输入以下内容:
<?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>
world文件的主要内容是设置地面和灯光。
step2:在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>
step3:利用gazebo velodyne.world -u
看暂停仿真下的模型。
step4:在模型上加入惯性单元,实现对外力作用下的反应
<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">
<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>
step5:加入关节,在的前面加入以下内容:
<!-- 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>
step6:加入传感器,在这个模块中加入以下内容:;
<!-- 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>
step7:定义ray的scan和rage,在sensor模块中的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/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>
仿真效果:
gazebo velodyne.world -u
点击开始仿真:
全部的模型代码:
<?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>
<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>
<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>
<collision name="base_collision">
<geometry>
<cylinder>
<!-- Radius and length provide 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>
<link name="top">
<!--Add a ray sensor,and give it a name -->
<sensor type="ray" name="sensor">
<!-- Position the ray sensor based on the specifucation Also rotate it by 90 degrees around the x-axis so that the <horizontal> rays become wertical -->
<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>
<ray>
<!-- The scan element contains the horizontal and vertiral 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 multiplited by sample to detemine number of simulated beams vs interpolated beams-->
<resolution>1</resolution>
<!--minimum angle in radians-->
<min_angle>-0.535299248</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>
</sensor>
<!-- 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>
<inertial>
<mass>0.1</mass>
<inertia>
<ixx>0.000090632</ixx>
<iyy>0.000090632</iyy>
<izz>0.000091036</izz>
<ixy>0</ixy>
<ixz>0</ixz>
<iyz>0</iyz>
</inertia>
</inertial>
<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>
<!-- 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>
</model>
</world>
</sdf>
更多推荐
gazebo仿真之Velodyne
发布评论