ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Actually there is a way to change the texture from within URDF. Put your ".material" file inside /media/materials/scripts/ and your texture images inside /media/materials/textures/. Use this simple snippet for the .material (just to make it simple, your code is right):

material YourMaterialName { technique { pass { texture_unit { texture your_material_image.png scale 1 1 } }
} }

In your URDF, add the material to the link outside of the <link> tag, but referencing it. Example:

<link name="link_name"> <inertial> <mass value="1.0"/> <origin xyz="0 0 0" rpy="0 0 0"/> <inertia ixx="1e-6" ixy="1e-6" ixz="1e-6" iyy="1e-6" iyz="1e-6" izz="1e-6"/> </inertial>

<visual>
    <geometry>
        <mesh filename="full_path_to_your_mesh/mesh.dae"/>
    </geometry>
</visual>

<collision>
    <geometry>
        <box size="1 1 1" /> <!-- anything you want... -->
    </geometry>
</collision>

</link>

<gazebo reference="link_name"> <material>YourMaterialName</material> </gazebo>

That's it. If it still doesn't work, then you'll need to prepare your mesh. Open your mesh using Blender, then first imagine how would you cut your solid with a scissor in order to put all surfaces in a plane. Then, select those edges, press Ctrl+E and select Mark Seam. The edges will become red. Split the window into 2 and in the new window choose UV/Image Editor as the Editor Type (bottom left corner). Then, press A to select everything, press U and choose Unwrap. At the UV/Image Editor will appear a geometry showing all your object faces in a plane. Now you can export to COLLADA (.dae) and put in your visual geometry mesh.

If you could not follow up the Blender steps, take a look at this tutorial: https://youtu.be/f2-FfB9kRmE

Actually there is a way to change the texture from within URDF. Put your ".material" file inside /media/materials/scripts/ and your texture images inside /media/materials/textures/. Use this simple snippet for the .material (just to make it simple, your code is right):

material YourMaterialName
{
   technique
   {
      pass
      {
         texture_unit
         {
          texture your_material_image.png
          scale 1 1
         }
      } 
} }

}

In your URDF, add the material to the link outside of the <link> tag, but referencing it. Example:

<link name="link_name">
    <inertial>
        <mass value="1.0"/>
value="1.0" />
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <inertia ixx="1e-6" ixy="1e-6" ixz="1e-6" ixz="1e-6"
                 iyy="1e-6" iyz="1e-6" izz="1e-6"/>
    </inertial>

iyz="1e-6"
                 izz="1e-6" />
    </inertial>

    <visual>
     <geometry>
         <mesh filename="full_path_to_your_mesh/mesh.dae"/>
     </geometry>
 </visual>

 <collision>
     <geometry>
         <box size="1 1 1" /> <!-- anything you want... -->
     </geometry>
 </collision>
</link>

<gazebo reference="link_name">
    <material>YourMaterialName</material>
</gazebo>

</link>

<gazebo reference="link_name"> <material>YourMaterialName</material> </gazebo>

That's it. If it still doesn't work, then you'll need to prepare your mesh. Open your mesh using Blender, then first imagine how would you cut your solid with a scissor in order to put all surfaces in a plane. Then, select those edges, press Ctrl+E and select Mark Seam. The edges will become red. Split the window into 2 and in the new window choose UV/Image Editor as the Editor Type (bottom left corner). Then, press A to select everything, press U and choose Unwrap. At the UV/Image Editor will appear a geometry showing all your object faces in a plane. Now you can export to COLLADA (.dae) and put in your visual geometry mesh.

If you could not follow up the Blender steps, take a look at this tutorial: https://youtu.be/f2-FfB9kRmE