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

Converting SolidWorks stuff to URDF. STL and Meshlab problems

asked 2011-04-27 05:33:13 -0600

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

ngrennan gravatar image

We have hard time converting our very cool robot SolidWorks files into URDF. They are way too complicated to make it somehow manually from scratch. As much I know there is no way to draw 3D model with some visual tools into URDF format. So we have options: SolidWorks converter on XML writing with vim.

To point. Simmechanics link creates XML file and lot of STL files. STL files are binary and ROS cannot open them. I compiled Meshlab and converted all STL files into non-binary ones. Content of files look OK to me. But ROS complains a lot about them:

[ERROR] [1303925218.756302760]: Could not load model '../../../../../../../../home/tonu/tyros/phippi/ros/phippi/xml/Media/models/Roboti_algus - roomuk-1 seib_4-3.STL' for link 'seib_4-31': OGRE EXCEPTION(2:InvalidParametersException): Header chunk didn't match either endian: Corrupted stream? in Serializer::determineEndianness at /home/tonu/ros/visualization_common/ogre/build/ogre_src_v1-7-1/OgreMain/src/OgreSerializer.cpp (line 89)

[ERROR] [1303925218.757941298]: Could not load model '../../../../../../../../home/tonu/tyros/phippi/ros/phippi/xml/Media/models/Roboti_algus - roomuk-1 seib_4-4.STL' for link 'seib_4-41': OGRE EXCEPTION(2:InvalidParametersException): Header chunk didn't match either endian: Corrupted stream? in Serializer::determineEndianness at /home/tonu/ros/visualization_common/ogre/build/ogre_src_v1-7-1/OgreMain/src/OgreSerializer.cpp (line 89)

[ERROR] [1303925218.758430673]: Could not load model '../../../../../../../../home/tonu/tyros/phippi/ros/phippi/xml/Media/models/Roboti_algus - roomuk-1 seib_4-4.STL' for link 'seib_4-41': OGRE EXCEPTION(2:InvalidParametersException): Header chunk didn't match either endian: Corrupted stream? in Serializer::determineEndianness at /home/tonu/ros/visualization_common/ogre/build/ogre_src_v1-7-1/OgreMain/src/OgreSerializer.cpp (line 89)

[ERROR] [1303925218.760367921]: Could not load model '../../../../../../../../home/tonu/tyros/phippi/ros/phippi/xml/Media/models/Roboti_algus - roomuk-1 seib_4-5.STL' for link 'seib_4-51': OGRE EXCEPTION(2:InvalidParametersException): Header chunk didn't match either endian: Corrupted stream? in Serializer::determineEndianness at /home/tonu/ros/visualization_common/ogre/build/ogre_src_v1-7-1/OgreMain/src/OgreSerializer.cpp (line 89)"

Example of STL file content:

tonu@hp:~/tyros/phippi/ros/phippi$ head "xml/Media/models/Roboti_algus - roomuk-1 seib_4-5.STL"
solid vcg
  facet normal  0.000000e+00  7.133919e-02 -9.974521e-01
    outer loop
      vertex   0.000000e+00 -2.618593e-04  1.821271e-03
      vertex  -9.000000e-04 -4.506700e-19  1.840000e-03
      vertex   0.000000e+00 -4.506700e-19  1.840000e-03
    endloop
  endfacet
  facet normal -0.000000e+00 -7.133919e-02 -9.974521e-01
    outer loop
tonu@hp:~/tyros/phippi/ros/phippi$ 

tonu@hp:~/tyros/phippi/ros/phippi$ tail "xml/Media/models/Roboti_algus - roomuk-1 seib_4-5.STL"
    endloop
  endfacet
  facet normal -1.000000e+00  0.000000e+00  0.000000e+00
    outer loop
      vertex  -9.000000e-04  1.390579e-03 -1.204944e-03
      vertex  -9.000000e-04  2.687582e-03 -2.242076e-03
      vertex  -9.000000e-04  2.442805e-03 -2.506533e-03
    endloop
  endfacet
endsolid vcg
tonu@hp:~/tyros/phippi/ros/phippi$

I am note sure what else should I show.

EDIT:

I followed first answer and tried to remove word "solid" from STL files:

for i in *.STL; do sed -ie 's/^solid/dilos/'  "$i" ; done

I also verified that files are acutally and properly changed. Still errors. Meshlab opens those modified files nicely ... (more)

edit retag flag offensive close merge delete

5 Answers

Sort by » oldest newest most voted
1

answered 2011-04-29 06:01:24 -0600

hsu gravatar image

I was able to load up STL's from your tar ball in diamondback without errors. Can you post a sample URDF file you used that you were able to reproduce the error? I have not seen the "endian" error before, what kind of system are you running on?

This is what I did: (I put the meshes under my_ros_pkg/debug_objects), and created test.urdf:

<robot name="simple_model">
  <link name="my_link">
    <inertial>
      <mass value="1.0" />
      <!-- center of mass (com) is defined w.r.t. link local coordinate system -->
      <origin xyz="1 0 0" /> 
      <inertia  ixx="1.0" ixy="0.0"  ixz="0.0"  iyy="100.0"  iyz="0.0"  izz="1.0" />
    </inertial>
    <visual>
      <!-- visual origin is defined w.r.t. link local coordinate system -->
      <origin xyz="1 0 0" rpy="0 0 0" />
      <geometry>
        <!--
        <mesh filename="package://my_ros_pkg/debug_objects/Roboti_algus - roomuk-1 Jalg-1 seib-28.STL" />
        -->
        <mesh filename="package://my_ros_pkg/debug_objects/Roboti_algus - roomuk-1 seib_4-3.STL" scale="10 10 10"/>
      </geometry>
    </visual>
    <collision>
      <!-- collision origin is defined w.r.t. link local coordinate system -->
      <origin xyz="1 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://my_ros_pkg/debug_objects/Roboti_algus - roomuk-1 seib_4-3.STL" />
      </geometry>
    </collision>
  </link>
  <gazebo reference="my_link">
    <material>Gazebo/Blue</material>
    <turnGravityOff>true</turnGravityOff>
  </gazebo>
</robot>

started empty world

roslaunch gazebo_worlds empty_world.launch

then spawned the model

rosrun gazebo spawn_model -urdf -file test.urdf -model test_stl_mesh -z 1
edit flag offensive delete link more

Comments

Will check today and give feedback. Thanks for your time!!
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-05-03 01:50:44 -0600 )edit
YESS! http://no.spam.ee/~tonu/rvizphippi2.png still did lot of manual work. Got always OGRE complaints until I removed all "<collision>" elements. Will redo soon all from scratch and post exact procedure we followed.
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-05-03 05:43:32 -0600 )edit
1
nice looking model :)
hsu gravatar image hsu  ( 2011-05-03 06:42:46 -0600 )edit
That looks awesome. I'm really glad you could get the code to work. If you have any suggestions for the simmechanics tool, I'm all ears.
David Lu gravatar image David Lu  ( 2011-05-03 08:21:56 -0600 )edit
marking this as answer as there has been no activity for ~3 weeks
kwc gravatar image kwc  ( 2011-06-17 11:16:59 -0600 )edit
ack. Busy times.
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-06-18 05:15:08 -0600 )edit
3

answered 2011-07-13 10:23:07 -0600

David Lu gravatar image

I finally got around to writing a tutorial! Sorry about the delay.

Converting SimMechanics to URDF

edit flag offensive delete link more
2

answered 2011-04-27 21:18:11 -0600

updated 2011-04-29 05:46:37 -0600

You are affected by a known incompatibility between Solidworks and ROS; see this ticket for details and workarounds. Your STL files have to be binary.

You can also have a look at the package katana_description, which uses STL meshes in URDF (not generated from Solidworks, though).

Also, there has been a similar question some while ago; the root cause of that one was different, but some of the answers fit your question.

EDIT: I downloaded your urdfstl.tar.gz, but was unable to run it unmodified, because a lot of files are missing. So I constructed a minimal example from your files which runs just fine and displays the meshes in RViz. You can get it here. If you still cannot get it to run, first try to construct a minimal example (i.e., only one or two meshes, only the files needed to reproduce the error, all files trimmed down to a minimum) and then upload the complete package folder including all necessary files.

edit flag offensive delete link more

Comments

We spent many other hours on this without positive result. I try to provide more information after.
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-04-29 04:21:58 -0600 )edit
About ticket - I applied such command to STL files but this didn't help: for i in *.STL; do sed -ie 's/^solid/dilos/' "$i" ; done
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-04-29 04:59:21 -0600 )edit
1

answered 2011-05-23 17:55:57 -0600

hsu gravatar image

updated 2011-05-23 18:13:27 -0600

I took the original uploaded tarball, fixed link names and packaged it up as phippi.tar.gz. After unpacking the file and fixing ROS_PACKAGE_PATH, you can reproduce it by running:

roslaunch phippi phippi.launch

The model is spawned 0.5m above ground. Some of the joints/joint-axis looked incorrect (see video).

I am running against trunk of simulator_gazebo, so did not see any ogre asserts. But I was able to reproduce the ogre asserts + crash with released diamondback. This is probably because the improvements in fixed joint reduction prevented the crash.

Please let me know if you need help setting simulator to run from trunk. Thanks.

edit flag offensive delete link more

Comments

The incorrect joint/joint-axes are a known "bug" of the conversion tool. At the moment, the tool is most useful for outputting geometries and using the parameter tool to correct all of the kinematic chains.
David Lu gravatar image David Lu  ( 2011-05-24 06:08:55 -0600 )edit
I really appreciate all help I get here. This is useful input.
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-05-28 00:41:40 -0600 )edit
0

answered 2011-05-23 16:10:32 -0600

updated 2011-05-23 16:36:12 -0600

Please do not mark it answered all the time until person who asked this didn't accept it fully! It takes some time to resolve it. There is a lot of problems like OGRE asserts:

gazebo: /home/tonu/ros/visualization_common/ogre/build/ogre_src_v1-7-1/OgreMain/include/OgreAxisAlignedBox.h:252: void Ogre::AxisAlignedBox::setExtents(const Ogre::Vector3&, const Ogre::Vector3&): Assertion `(min.x <= max.x && min.y <= max.y && min.z <= max.z) && "The minimum corner of the box must be less than or equal to maximum corner"' failed.

Current script:

tonu@hp:~/ocovision$ cat convert.sh 
#!/bin/sh
echo "Please make sure roscore works!"
#roscore &
echo "Removing tildes"
sed -e 's/õ/o/g' < Roboti_algus.xml > robot.xml
echo "Creating conf file"
touch foobar.yaml
echo "Converting robot.xml to robot.urdf"
rosrun simmechanics_to_urdf convert.py robot.xml foobar.yaml xml > robot.urdf
echo "Word count"
wc robot.urdf
echo "Fixing complaints about 'revolute'"
sed -ie 's/revolute/fixed/g'  robot.urdf
echo "Fixing complaints about 'prismatic'"
sed -ie 's/prismatic/fixed/g'  robot.urdf

sed -ie 's,<mesh filename=",<mesh filename="package://phippi/,g' robot.urdf
echo "Copying siles"
cp *.STL /home/tonu/tyros/phippi/ros/phippi/
echo "removing collision"
sed -ie 's/<collision>/<!-- <collision>/g' robot.urdf
sed -ie 's,</collision>,</collision> -->,g' robot.urdf
sed -ie 's/<inertia>/<!-- <inertial>/g' robot.urdf
sed -ie 's,</inertial>,</inertial> -->,g' robot.urdf
tonu@hp:~/ocovision$

I provide full solution when this becomes available. At moment it does not work for me but it will. Some undocumented handwork is involved. http://no.spam.ee/~tonu/rvizphippi3.png is latest screenshot

edit flag offensive delete link more

Comments

Can you restate your question? With all the updates, I'm unclear what problems you're still having.
David Lu gravatar image David Lu  ( 2011-05-24 06:06:46 -0600 )edit
We were unable to convert SolidWorks model into working URDF. Our model is more complicated than anything we have seen in tutorials or other questions. We got errors and problems not documented elsewhere. I try to make sure next guys who google for similar error messages will get answer from here.
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-05-28 00:19:33 -0600 )edit
This size limit in comment is bad. At moment I am not ready to ask more or refine question. Defining good question is always half of problem. But I am close to solution and will publish it as it becomes available. Wrong answer is worse than no answer sometime.
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-05-28 00:22:10 -0600 )edit
Still got some problems. First is related to simmechanics_urdf converter conf file. Unsure what I should enter there as "root" element. Would be good to show working example. I do use things like 'root: "Roboti_algus/RootPart"'.
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-05-28 05:30:09 -0600 )edit
Also OGRE complains gazebo: /home/tonu/ros/visualization_common/ogre/build/ogre_src_v1-7-1/OgreMain/include/OgreAxisAlignedBox.h:252: void Ogre::AxisAlignedBox::setExtents(const Ogre::Vector3&, const Ogre::Vector3&): Assertion `(min.x <= max.x && min.y <= max.y && min.z <= max.z) && "The minimum..
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-05-28 05:32:09 -0600 )edit
I did fresh checkout of https://code.ros.org/svn/ros-pkg/stacks/simulator_gazebo/trunk and recompiled. Is this right place to checkout? Probably ros-users list is proper place for this discussion.
Tõnu Samuel gravatar image Tõnu Samuel  ( 2011-05-28 05:34:10 -0600 )edit
hi! Have you resolved the problems? I also encounter this problem today and can't find any way to figure out.
shenhaobin gravatar image shenhaobin  ( 2011-08-09 19:44:13 -0600 )edit

Question Tools

Stats

Asked: 2011-04-27 05:33:13 -0600

Seen: 6,938 times

Last updated: Jul 13 '11