【问题标题】:Gazebo weird behavior when two objects contact两个物体接触时的 Gazebo 奇怪行为
【发布时间】:2020-06-04 21:40:09
【问题描述】:

你好 Stack Overflow 上的 Gazebo/ROS 社区,我正在尝试使用 Gazebo/ROS Kinetic 模拟四轴飞行器在杆子上的着陆。然而,一旦无人机接触着陆杆,它就会以一种非常不切实际的方式弹开。无人机和杆子都定义了它们的质量、惯性和摩擦力。

这里有一段视频: https://youtu.be/8Iis60y5_yk

谁能给我一些建议?非常感谢您的帮助!

这是 .world 文件:

<?xml version="1.0" ?>
<sdf version="1.4">
  <world name="default">
    <include>
      <uri>model://ground_plane</uri>
    </include>
    <include>
      <uri>model://sun</uri>
    </include>
    <!-- Only one ROS interface plugin is required per world, as any other plugin can connect a Gazebo
         topic to a ROS topic (or vise versa). -->
    <plugin name="ros_interface_plugin" filename="librotors_gazebo_ros_interface_plugin.so"/>
    <spherical_coordinates>
      <surface_model>EARTH_WGS84</surface_model>
      <latitude_deg>47.3667</latitude_deg>
      <longitude_deg>8.5500</longitude_deg>
      <elevation>500.0</elevation>
      <heading_deg>0</heading_deg>
    </spherical_coordinates>
    <physics type='ode'>
      <ode>
        <solver>
          <type>quick</type>
          <iters>1000</iters>
          <sor>1.3</sor>
        </solver>
        <constraints>
          <cfm>0</cfm>
          <erp>0.2</erp>
          <contact_max_correcting_vel>100</contact_max_correcting_vel>
          <contact_surface_layer>0.001</contact_surface_layer>
        </constraints>
      </ode>
      <max_step_size>0.01</max_step_size>
      <real_time_factor>1</real_time_factor>
      <real_time_update_rate>100</real_time_update_rate>
      <gravity>0 0 -9.8</gravity>
    </physics>
  </world>
</sdf>

这是着陆杆的 xacro 文件:

<?xml version="1.0"?>
<robot name="target" xmlns:xacro="http://ros.org/wiki/xacro">
    <xacro:property name="pole_height" value="1.2192" />
    <xacro:property name="pole_radius" value="0.05" />
    <!-- cone-shaped top compatible with the drone -->
    <link name="target/cone">
        <inertial>
            <origin xyz="0 0 0"/>
            <mass value="3.0"/>
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
        </inertial>
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://rotors_description/meshes/cone.dae" scale="0.001 0.001 0.001" />
            </geometry>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://rotors_description/meshes/cone.dae" scale="0.001 0.001 0.001" />
            </geometry>
            <contact_coefficients mu ="1" kp="1000" kd="1"/> 
        </collision>
    </link>
    <!-- connect cone to pole -->
    <joint name="cone_to_pole" type="fixed">
        <origin xyz="0 0 0.6096"/>
        <parent link="target/base_link"/>
        <child link="target/cone"/>
    </joint>
    <!-- landing pole -->
    <link name="target/base_link">
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0"/>
            <geometry>
                <cylinder length="${pole_height}" radius="${pole_radius}"/>
            </geometry>
            <material name="white">
                <color rgba="1.0 1.0 1.0 1.0"/>
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <cylinder length="${pole_height}" radius="${pole_radius}"/>
            </geometry>
        </collision>
        <inertial>
            <origin xyz="0 0 0"/>
            <mass value="3.0"/>
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
        </inertial>
    </link>
    <!-- april tag -->
    <link name="target/tag_link">
        <inertial>
            <origin xyz="0 0 0"/>
            <mass value="1.0"/>
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
        </inertial>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <box size="1.7 1.7 0.05" />
            </geometry>
            <surface>
                <friction>
                    <ode>
                        <mu>0.01</mu>
                        <mu2>0.01</mu2>
                    </ode>
                </friction>
            </surface>
        </collision>
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://rotors_description/meshes/pole.dae" scale="1 1 1" />
            </geometry>
        </visual>
    </link>
    <!-- connect pole to tag -->
    <joint name="target/tag_joint" type="fixed">
        <origin xyz="0 0 -0.6096"/>
        <parent link="target/base_link"/>
        <child link="target/tag_link"/>
    </joint>
    <!-- make the landing pole transparent for testing purposes -->
   <!--  <gazebo reference="target/base_link">
      <visual>
        <material>
          <ambient> 1.0 1.0 1.0 0.0</ambient>
          <diffuse> 1.0 1.0 1.0 0.0</diffuse>
          <specular>1.0 1.0 1.0 0.0</specular>
        </material>
      </visual>
    </gazebo>
    <gazebo reference="target/cone">
      <visual>
        <material>
          <ambient> 1.0 1.0 1.0 0.0</ambient>
          <diffuse> 1.0 1.0 1.0 0.0</diffuse>
          <specular>1.0 1.0 1.0 0.0</specular>
        </material>
      </visual>
    </gazebo> -->
    <xacro:include filename="$(find rotors_description)/urdf/component_snippets.xacro" />
    <xacro:default_imu namespace="target" parent_link="target/base_link" />
    <gazebo>
        <plugin name="landing_target_plugin" filename="librotors_gazebo_landing_target_plugin.so">
            <robotNamespace>target</robotNamespace>
            <linkName>target/base_link</linkName>
        </plugin>
    </gazebo>
    <gazebo reference="target/base_link">
        <mu1>0.00000001</mu1>
        <mu2>0.00000001</mu2>
    </gazebo>
</robot>

这是无人机底座的 xacro 文件:

<?xml version="1.0"?>
<!--
  Copyright 2015 Fadri Furrer, ASL, ETH Zurich, Switzerland
  Copyright 2015 Michael Burri, ASL, ETH Zurich, Switzerland
  Copyright 2015 Mina Kamel, ASL, ETH Zurich, Switzerland
  Copyright 2015 Janosch Nikolic, ASL, ETH Zurich, Switzerland
  Copyright 2015 Markus Achtelik, ASL, ETH Zurich, Switzerland
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<robot xmlns:xacro="http://ros.org/wiki/xacro">
  <!-- Macro for the inertia of a box -->
  <xacro:macro name="box_inertia" params="x y z mass">
    <inertia ixx="${0.0833333 * mass * (y*y + z*z)}" ixy="0.0" ixz="0.0"
      iyy="${0.0833333 * mass * (x*x + z*z)}" iyz="0.0"
      izz="${0.0833333 * mass * (x*x + y*y)}" />
  </xacro:macro>
  <!-- Macro for the inertial properties of a box -->
  <xacro:macro name="box_inertial" params="x y z mass *origin">
    <inertial>
      <mass value="${mass}" />
      <xacro:insert_block name="origin" />
      <xacro:box_inertia x="${x}" y="${y}" z="${z}" mass="${mass}" />
    </inertial>
  </xacro:macro>
  <!-- Main multirotor link -->
  <xacro:macro name="multirotor_base_macro"
    params="robot_namespace mass body_width body_height use_mesh_file mesh_file *inertia">
    <link name="${robot_namespace}/base_link">
    </link>
    <joint name="${robot_namespace}/base_joint" type="fixed">
      <origin xyz="0 0 0" rpy=" 0 0 0" />
      <parent link="${robot_namespace}/base_link" />
      <child link="${robot_namespace}/base_link_inertia" />
    </joint>
    <link name="${robot_namespace}/base_link_inertia">
      <inertial>
        <mass value="${mass}" />  <!-- [kg] -->
        <origin xyz="0 0 0" />
        <xacro:insert_block name="inertia" />
      </inertial>
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <xacro:if value="${use_mesh_file}">
            <mesh filename="${mesh_file}" scale="1 1 1" />
          </xacro:if>
          <xacro:unless value="${use_mesh_file}">
            <box size="${body_width} ${body_width} ${body_height}"/> <!-- [m] [m] [m] -->
          </xacro:unless>
        </geometry>
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <xacro:if value="${use_mesh_file}">
            <mesh filename="${mesh_file}" scale="1 1 1" />
          </xacro:if>
          <xacro:unless value="${use_mesh_file}">
            <box size="${body_width} ${body_width} ${body_height}"/> <!-- [m] [m] [m] -->
          </xacro:unless>
        </geometry>
        <contact_coefficients mu ="1" kp="1000" kd="1"/> 
      </collision>
    </link>
    <!-- attach multirotor_base_plugin to the base_link -->
    <gazebo>
      <plugin filename="librotors_gazebo_multirotor_base_plugin.so" name="multirotor_base_plugin">
        <robotNamespace>${robot_namespace}</robotNamespace>
        <linkName>${robot_namespace}/base_link</linkName>
        <rotorVelocitySlowdownSim>${rotor_velocity_slowdown_sim}</rotorVelocitySlowdownSim>
      </plugin>
    </gazebo>
  </xacro:macro>
  <!-- Rotor joint and link -->
  <xacro:macro name="vertical_rotor"
    params="robot_namespace suffix direction motor_constant moment_constant parent mass_rotor radius_rotor time_constant_up time_constant_down max_rot_velocity motor_number rotor_drag_coefficient rolling_moment_coefficient color use_own_mesh mesh *origin *inertia">
    <joint name="${robot_namespace}/rotor_${motor_number}_joint" type="continuous">
      <xacro:insert_block name="origin" />
      <axis xyz="0 0 1" />
      <!-- TODO(ff): not currently set because it's not yet supported -->
      <!-- <limit effort="2000" velocity="${max_rot_velocity}" /> -->
      <parent link="${parent}" />
      <child link="${robot_namespace}/rotor_${motor_number}" />
    </joint>
    <link name="${robot_namespace}/rotor_${motor_number}">
      <inertial>
        <mass value="${mass_rotor}" /> <!-- [kg] -->
        <xacro:insert_block name="inertia" />
      </inertial>
      <visual>
        <geometry>
                  <!-- <cylinder length="0.005" radius="${radius_rotor}"/> --> <!-- [m] -->
          <xacro:if value="${use_own_mesh}">
            <mesh filename="${mesh}"
              scale="1 1 1" />
          </xacro:if>
          <xacro:unless value="${use_own_mesh}">
            <mesh filename="package://rotors_description/meshes/propeller_${direction}.dae"
              scale="${radius_rotor} ${radius_rotor} ${radius_rotor}" /> <!-- The propeller meshes have a radius of 1m -->
            <!-- <box size="${2*radius_rotor} 0.01 0.005"/> -->
          </xacro:unless>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <cylinder length="0.005" radius="${radius_rotor}" /> <!-- [m] -->
        </geometry>
      </collision>
    </link>
    <gazebo>
      <plugin name="${robot_namespace}_${suffix}_motor_model" filename="librotors_gazebo_motor_model.so">
        <robotNamespace>${robot_namespace}</robotNamespace>
        <jointName>${robot_namespace}/rotor_${motor_number}_joint</jointName>
        <linkName>${robot_namespace}/rotor_${motor_number}</linkName>
        <turningDirection>${direction}</turningDirection>
        <timeConstantUp>${time_constant_up}</timeConstantUp>
        <timeConstantDown>${time_constant_down}</timeConstantDown>
        <maxRotVelocity>${max_rot_velocity}</maxRotVelocity>
        <motorConstant>${motor_constant}</motorConstant>
        <momentConstant>${moment_constant}</momentConstant>
        <commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
        <motorNumber>${motor_number}</motorNumber>
        <rotorDragCoefficient>${rotor_drag_coefficient}</rotorDragCoefficient>
        <rollingMomentCoefficient>${rolling_moment_coefficient}</rollingMomentCoefficient>
        <motorSpeedPubTopic>motor_speed/${motor_number}</motorSpeedPubTopic>
        <rotorVelocitySlowdownSim>${rotor_velocity_slowdown_sim}</rotorVelocitySlowdownSim>
      </plugin>
    </gazebo>
    <gazebo reference="${robot_namespace}/rotor_${motor_number}">
      <material>Gazebo/${color}</material>
    </gazebo>
  </xacro:macro>
</robot>

【问题讨论】:

  • 您好,欢迎来到 StackOverflow。请提供更多详细信息,使您的问题更具体、更容易回答。您可以提供一个示例 Gazebo .world 文件、指向您用于无人机和杆的 SDF 文件的链接、随时间变化的无人机位置或方向图,或者捕获您所看到的行为的截屏视频。另外,请提供您的 Gazebo 和 ROS 版本。
  • 您好 Kukanani,感谢您的及时回复!我已经更新了 .world 文件和 SDF/xacro 文件!

标签: ros gazebo-simu


【解决方案1】:

我也遇到过类似的问题。机器人在与表面接触时开始弹跳。就我而言,问题的根源是机器人部件的不切实际惯性值。即使其中一个链接的计算/估计惯性不好,模型也可能会反弹。我建议你在惯性标签下验证计算。

【讨论】:

    猜你喜欢
    • 2021-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-18
    • 2013-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多