PX4 gazebo地标二维码模型

最简单的办法
通过现有模型改一版
cd /Firmware/Tools/sitl_gazebo/models
可以基于asphalt_plane模型改

vi marker/model.config

<?xml version="2.0"?>

<model>
  <name>land marker</name>
  <version>1.0</version>
  <sdf version="1.5">model.sdf</sdf>

  <author>
    <name>Thomas Zxc</name>
    <email>thomas.zxc@gmail.com</email>
  </author>

  <description>
    An marker.
  </description>

</model>

vi marker/model.sdf

<?xml version="2.0" ?>
<sdf version="1.5">
  <model name="marker">
    <static>true</static>
    <link name="link">
      <collision name="collision">
        <geometry>
          <box>
            <size>0.4 0.4 0.01</size>
          </box>
        </geometry>
      </collision>
      <visual name="visual">
        <cast_shadows>false</cast_shadows>
        <geometry>
          <box>
            <size>0.4 0.4 0.01</size>
          </box>
        </geometry>
        <material>
          <script>
            <uri>model://marker/materials/scripts</uri>
            <uri>model://marker/materials/textures</uri>
            <name>vrc/asphalt</name>
          </script>
        </material>
      </visual>
    </link>
  </model>
</sdf>

vi marker/materials/scripts/asphalt.material

material vrc/asphalt
{
        technique
        {
                pass
                {
                        ambient 0.5 0.5 0.5 1.0
                        diffuse 0.5 0.5 0.5 1.0
                        specular 0.2 0.2 0.2 1.0 12.5

                        texture_unit
                        {
                                texture marker.png
                                filtering anistropic
                                max_anisotropy 16
                                scale 1.0 1.0
                        }
                }
        }
}

ls marker/materials/textures/

marker.png

启动自动添加
mavros_posix_sitl.launch默认使用的是empty.world
vi worlds/empty.world

<!-- 添加 -->
<!-- marker是文件夹名 -->
<include>
  <pose frame=''>0.0 0.0 0.05 0.0 0.0 0.0</pose>
  <uri>model://marker</uri>
</include>

效果

自动生成地标

sudo apt-get install ros-kinetic-ar-track-alvar
rosrun ar_track_alvar createMarker [number]
posted @ 2021-06-30 10:43  thomas_blog  阅读(314)  评论(0编辑  收藏  举报