Gazebo使用筆記(2) —— SDF建模及傳感器噪聲的添加(以激光雷達爲例)

<?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. 模型外觀

需要的工具:freecadblender

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>即可修改噪聲幅度。

重新加載,發現信號不在圓滑!
在這裏插入圖片描述


參考文獻:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章