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

How to import stl files into urdf files

asked 2011-03-31 05:24:06 -0600

updated 2014-01-28 17:09:27 -0600

ngrennan gravatar image

I am trying to use stl files with the tag mesh with this code:

  <geometry>
    <mesh filename="package://auriga_model/auriga_base.stl"/>
  </geometry>

The package existes and the file is located there but I get this message when I try to launch it:

[ERROR] [1301591093.704357996]: Malformed geometry for Visual element
[ERROR] [1301591093.704545807]: Could not parse visual element for Link '/base_laser'
[ERROR] [1301591093.704624976]: link xml is not initialized correctly

I have been doing some test with PR2 stl model and I had no success. Here are some of my tries:

  <!-- description of the robot -->
  <link name="/base_link">
    <visual>
      <origin rpy="0 0 0" xyz="0.15 0 0.35"/>
      <geometry>
        <!-- mesh filename="package://auriga_model/meshes/auriga_base.stl" /-->
        <!-- mesh filename="package://auriga_model/meshes/head_pan.stl" /-->
        <mesh filename="package://pr2_description/meshes/head_v0/head_pan.stl"/>
      </geometry>
    </visual>
  </link>

  <link name="/base_laser">
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>
    </visual>
  </link>

For me, it looks like it can't resolve properly "filename="package://". Is it possible? I tested and "rospack find" command works fine with me.

Any clue?


Now I am able to load PR2 models but not the one of my robot. The original model was build in solidworks and maybe this is the problem. I will try to port it from Catia and I will say if it works.

edit retag flag offensive close merge delete

Comments

That seems correct at first pass. What node are you launching that gives you this error? Also, could you post the whole Link xml, please?
David Lu gravatar image David Lu  ( 2011-03-31 05:48:37 -0600 )edit
If solidworks was the problem, one thing you can try is open the solidworks mesh in a text editor (e.g. vi), and replace the first word "solid" with spaces.
hsu gravatar image hsu  ( 2011-04-07 09:41:03 -0600 )edit

2 Answers

Sort by » oldest newest most voted
6

answered 2011-04-03 00:19:32 -0600

The link "base_link" is just fine. The problem is that the second visual tag (in the link "base_laser") is missing the required <geometry> element. You also need to specify a joint between the two links, otherwise the robot_state_publisher will complain that there are two root links. Below are working versions of the URDF and launch file. Also see the URDF XML documentation and the URDF tutorials.

URDF file:

<robot name="your_robot_name">
  <link name="base_link">
    <visual>
      <origin rpy="0 0 0" xyz="0.15 0 0.35"/>
      <geometry>
        <mesh filename="package://pr2_description/meshes/head_v0/head_pan.stl"/>
      </geometry>
    </visual>
  </link>

  <joint name="base_link_to_base_laser_joint" type="fixed">
    <parent link="base_link"/>
    <child link="base_laser"/>
    <origin xyz="0 0 1.0"/>
  </joint>

  <link name="base_laser">
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <cylinder length="0.6" radius="0.2"/>
      </geometry>
    </visual>
  </link>
</robot>

launch file:

<launch>
  <!-- upload urdf -->
  <param name="robot_description" textfile="$(find your_package_name)/urdf/your_robot.urdf" />

  <!-- robot state publisher -->
  <node pkg="robot_state_publisher" type="state_publisher" name="robot_state_publisher" />

  <!-- joint state publisher with gui -->
  <param name="use_gui" value="true" />
  <node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher"/>
</launch>
edit flag offensive delete link more

Comments

I am not sure if I need to ask new question or extend it. I see on similar issue strace output like this: stat64("/home/it/ros/visualization_common/ogre_tools/media/materials/programs/package://xml/Roboti_algus - roomuk-1 Jalg-1 1-1.STL"... Why "package://" is not parsed/rewritten? Some trick?
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-04-26 11:17:54 -0600 )edit
Please post a new question with all of the relevant XML.
David Lu gravatar image David Lu  ( 2011-04-26 11:39:47 -0600 )edit

+1 But, I would still like to know how a model created in Catia/Blender (say a simple two joint three link structure hand equivalent) can be simulated in ROS Gazebo interface through C++ code (from scratch).

PrasadNR gravatar image PrasadNR  ( 2016-12-16 04:55:48 -0600 )edit

Hello, I see that you declare the base_laser link in the urdf file, but is it possible to declare it using tf package and in the urdf file just declare the base_link with the stl model?

Alessandro Melino gravatar image Alessandro Melino  ( 2020-06-19 05:23:11 -0600 )edit
1

Sure, you can have a URDF that only has the base_laser link in it, and publish the TF transform yourself. If you want to display meshes for both the base_laser and base_link while publishing the base_link to base_laser joint yourself via TF, you cannot simply delete the base_link_to_base_laser_joint, because URDF doesn't allow two unconnected trees of links. Instead, you should change the joint type from fixed to floating. This will cause robot_state_publisherto ignore that joint and not publish TFs for it: https://github.com/ros/robot_state_pu...

Then you can publish that TF yourself.

Martin Günther gravatar image Martin Günther  ( 2020-06-19 09:28:46 -0600 )edit

Okay, I understood it perfectly. Thank you for your answer.

Alessandro Melino gravatar image Alessandro Melino  ( 2020-06-22 03:42:52 -0600 )edit
1

answered 2011-03-31 06:26:23 -0600

hsu gravatar image

Was the stl generated from Solidworks? If so, it might be related to this ticket. We can reopen the ticket and submit a patch to assimp if necessary.

Can you please post the stl file as well? To check, you can copy another working stl (e.g. from pr2_description) into auriga_model, and see if a different stl brings up correctly.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2011-03-31 05:24:06 -0600

Seen: 22,538 times

Last updated: Apr 06 '11