Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I get the collision model right in xacro robot urdf?

I have a .dae file that I transformed from a .stl file that serves as the mesh in my xacro file. However, I tried to use the same .dae file in the collision section, but when I launch gazebo the robot just spins out of control.

I've been trying to follow the project DAVE tutorial for uav's but there is a lot of information missing.

    <?xml version="1.0"?>
<!-- 
     All rights reserved.

     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 name="test" xmlns:xacro="http://www.ros.org/wiki/xacro" >

  <xacro:arg name="debug" default="0"/>
  <xacro:arg name="namespace" default="test"/>

  <!-- "Dummy" base link to eliminate root link inertia warning --> 
  <link name="$(arg namespace)/base_link"/>

  <link name="$(arg namespace)/test_link">

    <inertial>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <mass value="34.622"/>
      <inertia
        ixx="47.76" ixy="0.0" ixz="0.0"
        iyy="47.73" iyz="0.14"
        izz="0.12"/>
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="1.5708 0 0"/>
      <geometry>
        <mesh filename="package://test_description/meshes/robot_wedge_mast.dae" scale="0.02 0.02 0.02"/>
      </geometry>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 1.5708"/>
      <geometry>
        <mesh filename="package://test_description/meshes/robot_wedge_mast.dae" scale="0.02 0.02 0.02"/>
      </geometry>
    </collision>
  </link>

  <!-- Attach test_link to the dummy base link -->
  <joint name="$(arg namespace)/test_base_joint" type="fixed">
    <origin xyz="0 0 0" rpy="0 0 0"/>  <!-- X-fwd, Y-lft, Z-up (ick!) -->
    <parent link="$(arg namespace)/base_link"/>
    <child link="$(arg namespace)/test_link"/>
  </joint>



 <gazebo>
   <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
     <robotNamespace>/$(arg namespace)</robotNamespace>
     <robotParam>/$(arg namespace)/test</robotParam>
   </plugin>
 </gazebo>

 <!-- Define thrusters for propulsion -->
 <xacro:property name="prop_mesh_file" value="file://$(find test_description)/meshes/robotics_propeller.dae"/>
 <!-- Common values, colors, converstion, standard shapes/inertia etc.
      Dependency for the thruster_snippets.xacro-->
 <xacro:include filename="$(find uuv_descriptions)/urdf/common.urdf.xacro"/>
 <!-- Various thruster models -->
 <xacro:include filename="$(find uuv_gazebo_ros_plugins)/urdf/thruster_snippets.xacro"/>
 <!-- Substitute the ECA A9 prop mesh for the larger uuv_descriptions one -->
 <!--<xacro:property name="prop_mesh_file" value="file://$(find eca_a9_description)/mesh/eca_a9_propeller.dae"/>-->






  <!-- Thruster joint and link snippet
       Wrapper for the the thruster_module_first_order_basic_fcn_macro
       defined in uuv_gazebo_ros_plugins/urdf/thruster_snippet.
       Uses the "thruster_cf_basic_macro"
         1) Basic curve
       Input: x
       Output: thrust
       Function: thrust = rotorConstant * x * abs(x)
  -->
  <xacro:macro name="thruster_macro"
               params="thruster_id *origin">
    <xacro:thruster_module_first_order_basic_fcn_macro
        namespace="$(arg namespace)"
        thruster_id="${thruster_id}"
        mesh_filename="${prop_mesh_file}"
        scale = "0.02 0.02 0.02"
        dyn_time_constant="0.05"
        rotor_constant="0.0001">  <!-- This is a guess for now (~1/3 RexROV) -->
      <xacro:insert_block name="origin"/>
    </xacro:thruster_module_first_order_basic_fcn_macro>
  </xacro:macro>


  <xacro:thruster_macro thruster_id="0">
    <origin xyz="-1.2 -0.415 -0.09" rpy="${0*d2r} ${0*d2r} ${150.0*d2r}"/>
  </xacro:thruster_macro>



 <!-- Default joint state publisher -->
 <gazebo>
   <plugin name="uuv_joint_state_publisher" filename="libuuv_joint_state_publisher.so">
     <robotNamespace>$(arg namespace)</robotNamespace>
     <updateRate>50</updateRate>
   </plugin>
 </gazebo>

</robot>