gazebo仿真之Model Appearance

编程知识 行业动态 更新时间:2024-06-13 00:20:02

这部分的内容是如何将模型进行外观的优化显示。官网教程:http://gazebosim/tutorials?cat=guided_i&tut=guided_i2
两个工具:freecad和blender,需要提前下载
对于Model Appearance:官网的介绍:Models with textures and 3D meshes can improve your visual experience, and more importantly improve the realism of an environment. Simulated cameras that feed information to vision processing algorithms will benefit from models that appear realistic as well.
《一》通过官网的教程,我们得到两个模型文件:velodyne_base.dae and velodyne_top.dae.

(1)为了能够使我们的模型能直接在gazebo上调用,我们将模型放在~/.gazebo/models这个路径下。在该路径下创建一个文件夹velodyne_hdl32存放我们的模型文件包括.config 和 .sdf 文件
官网给的模板(文件名为model.config):

    <?xml version="1.0"?>
    
    <model>
      <name>Velodyne HDL-32</name>
      <version>1.0</version>
      <sdf version="1.5">model.sdf</sdf>
    
      <author>
        <name>Optional: YOUR NAME</name>
        <email>Optional: YOUR EMAIL</email>
      </author>
    
      <description>
        A model of a Velodyne HDL-32 LiDAR sensor.
      </description>
    
    </model>

一开始我们的sdf文件的内容如下:

<?xml version="1.0" ?>
<sdf version="1.5">

<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>
</sdf>

该模型图如下:

对sdf文件进行更改,物体中的cylinder采用mesh来替代,在sdf文件中利用uri来引用dae文件。
更改的内容:

<visual name="top_visual">
  <!-- Lower the mesh by half the height, and rotate by 90 degrees -->
  <pose>0 0 -0.0376785 0 0 1.5707</pose>
  <geometry>
    <mesh>
      <uri>model://velodyne_hdl32/meshes/velodyne_top.dae</uri>
    </mesh>
  </geometry>
</visual>

<visual name="base_visual">
  <!-- Offset the visual by have the base's height. We are not rotating
       mesh since symmetrical -->
  <pose>0 0 -0.029335 0 0 0</pose>
  <geometry>
    <mesh>
      <uri>model://velodyne_hdl32/meshes/velodyne_base.dae</uri>
    </mesh>
  </geometry>
</visual>

最后的效果:
完整的sdf代码如下:

<?xml version="1.0" ?>
<sdf version="1.5">

<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">
        <!-- Offset the visual by have the base's height. We are not rotating mesh since symmetrical -->
  <pose>0 0 -0.029335 0 0 0</pose>
  <geometry>
    <mesh>
      <uri>model://velodyne_hd132/meshes/velodyne_base.dae</uri>
    </mesh>
      </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">
	<!--Lower the mesh by half the height,and rotate by 90 degrees -->
	<pose>0 0 -0.0376785 0 0 1.5707</pose>

      <geometry>
        <!--The mesh tag indicates that we will use a 3D mesh as a visual-->
	<mesh>
	 <!-- The URI should refer to the 3D mesh. The "model:" URI scheme indicates that the we are referencing a gazebo model.-->
	<uri>model://velodyne_hd132/meshes/velodyne_top.dae</uri>
        </mesh>
      </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>

</sdf>

更多推荐

gazebo仿真之Model Appearance

本文发布于:2023-03-29 09:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/553e76c4f5c7a08f23744344135f8e0f.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:gazebo   Model   Appearance

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!