Gazebo:使用移动行人搭建动态仿真环境

Gazebo:使用移动行人搭建动态仿真环境

如果想要实现自己搭建机器人在gazebo中的使用ros_control做运动,请参考如下链接
link1
link2

一、前提

版本要求:
将gazebo升级到8+以上的vision.

二、Actors Model

gazebo中有个运动模型叫做actor,他在普通static_model上赋予运动能力。本质上还是个model,也可以在里面添加joints和links

举个例子:

  1. 定义空世界
<?xml version="1.0" ?>
<sdf version="1.6">
   <world name="default">
      <!-- A ground plane -->
      <include>
         <uri>model://ground_plane</uri>
      </include>
      <!-- A global light source -->
      <include>
         <uri>model://sun</uri>
      </include>
  1. actor标签下创建link
      <!-- An actor -->
      <actor name="animated_box">
        <link name="link">
          <visual name="visual">
            <geometry>
              <box>
                <size>.2 .2 .2</size>
              </box>
            </geometry>
          </visual>
        </link>
  1. 创建<script>标签
        <script>
          <loop>true</loop>
          <delay_start>0.000000</delay_start>
          <auto_start>true</auto_start>

我们让他世界一旦启动就开始转,永远转下去

  1. 通过一系列的点定义轨迹:
          <trajectory id="0" type="square">
             <waypoint>
                <time>0.0</time>
                <pose>-1 -1 1 0 0 0</pose>
             </waypoint>
             <waypoint>
                <time>1.0</time>
                <pose>-1 1 1 0 0 0</pose>
             </waypoint>
             <waypoint>
                <time>2.0</time>
                <pose>1 1 1 0 0 0</pose>
             </waypoint>
             <waypoint>
                <time>3.0</time>
                <pose>1 -1 1 0 0 0</pose>
             </waypoint>
             <waypoint>
                <time>4.0</time>
                <pose>-1 -1 1 0 0 0</pose>
             </waypoint>
          </trajectory>
        </script>
      </actor>
   </world>
</sdf>
  1. 查看效果:
    gazebo worlds/animated_box.world
    在这里插入图片描述

  2. 添加skin
    actor标签中添加skin属性
    vim walk.world,然后将下面部分贴进去

<?xml version="1.0" ?>
<sdf version="1.6">
  <world name="default">
    <include>
      <uri>model://sun</uri>
    </include>
    <actor name="actor">
      <skin>
        <filename>walk.dae</filename>
      </skin>
    </actor>
  </world>
</sdf>

运行gazebo walk.world查看效果:

在这里插入图片描述

如果dae文件通过mesh贴在在link的话,输出结果就会忽略dae文件中的动画部分。但是在gazebo中使用skin标签,动画部分也可以展示出来。

  1. 结合不同的skin和animation

动作和皮肤可以相互替换。

<?xml version="1.0" ?>
<sdf version="1.6">
  <world name="default">
    <include>
      <uri>model://sun</uri>
    </include>
    <actor name="actor">
      <skin>
        <filename>walk.dae</filename>
      </skin>
      <animation name="animation">
        <filename>moonwalk.dae</filename>
      </animation>
    </actor>
  </world>
</sdf>
  1. animation和轨迹结合

不多说,重点就是animation的name与trajectory的type保持一致

三、加上插件

插件的使用可以让人走的时候自主避障。


<actor name="actor1">
  <pose>0 1 1.25 0 0 0</pose>
  <skin>
    <filename>moonwalk.dae</filename>
    <scale>1.0</scale>
  </skin>
  <animation name="walking">
    <filename>walk.dae</filename>
    <scale>1.000000</scale>
    <interpolate_x>true</interpolate_x>
  </animation>
  <plugin name="actor1_plugin" filename="libActorPlugin.so">
    <target>0 -5 1.2138</target>
    <target_weight>1.15</target_weight>
    <obstacle_weight>1.8</obstacle_weight>
    <animation_factor>5.1</animation_factor>
    <ignore_obstacles>
      <model>cafe</model>
      <model>ground_plane</model>
    </ignore_obstacles>
  </plugin>
</actor>

参考文献

http://gazebosim.org/tutorials?tut=actor&cat=build_robot

猜你喜欢

转载自blog.csdn.net/allenhsu6/article/details/112966600