文章目录

  • 1. 传感器
  • 2. 关节测试
  • 3. 模型外观
  • 4. 传感器噪声
  • <?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>
    <!--##################################################################################-->		
    		<!-- ######## cylinder ######### -->
    		<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 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>
    		   <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>
    
    			<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>
    
    
    <!--##################################################################################-->
    
    			<!-- 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>
    				<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>
    			</sensor>
    <!--##################################################################################-->
    		  </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>
    
  • 1. 传感器
    传感器的添加,以激光传感器velodynelidar为例,gazebo中的激光传感器可以发出一个或多个光束,这些光束会产生距离以及可能的强度数据。

    在sdf文件中,该传感器由<scan>和<range>两个部分组成,<scan>定义波束的布局和数量,<range>限定一个单独的束的性质

    <scan>中包含<horizontal>和<vertical>两个块。<horizontal>组件定义在水平平面中发出的光线,该<vertical>组件定义在垂直平面中发出的光线。

    2. 关节测试
    打开右面板可设置力、位置、速度等参数,单击开始方针即可看到效果。

    右面板的打开:点击右侧竖着的.....,并向左拖动,即可打开默认隐藏的右面板!

    Ctrl+R复原world环境

    3. 模型外观
    需要的工具:freecad、blender

    sudo apt-get install freecad
    sudo apt-get install blender
    
  • 具体设置参考这儿:http://gazebosim.org/tutorials?cat=guided_i&tut=guided_i2

    最终效果如下:

  • 在这里插入图片描述
  • 4. 传感器噪声
  • 内置高斯噪声~Ctrl+T打开topic visualization
  • 在这里插入图片描述
  • 在<sensor>的子标签<ray>中添加如下代码:
  •     <noise>
          <!-- Use gaussian noise -->
          <type>gaussian</type>
          <mean>0.0</mean>
          <stddev>0.1</stddev>
        </noise>
    
  • 通过<mean><stddev>即可修改噪声幅度。

    重新加载,发现信号不在圆滑!

  • 在这里插入图片描述
  • 参考文献:

    • http://gazebosim.org/tutorials
    • 3.https://blog.csdn.net/weixin_41045354/article/details/104281283