Rosanswers logo

I've saved a SolidWorks file as an ASCII .STL, opened it in MeshLab and re-saved as a Binary .STL

When I try to test it using the file:// descriptor in a URDF file I'm getting some errors:

XML code is:

[ERROR] [1342609158.212504927]: Error retrieving file [file://home/username/path/path/filename.stl]: Couldn't open file /username/path/path/filename.stl
[ERROR] [1342609158.213501127]: Could not load model 'file://home/username/path/path/filename.stl' for link 'Mounting_link': OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource file://home/username/path/path/filename.stl in resource group Autodetect or any other group. in ResourceGroupManager::openResource at /tmp/buildd/ros-fuerte-visualization-common-1.8.4/debian/ros-fuerte-visualization-common/opt/ros/fuerte/stacks/visualization_common/ogre/build/ogre_src_v1-7-3/OgreMain/src/OgreResourceGroupManager.cpp (line 753)

** Notice that in the error it looks like it may be truncating the word 'home' and trying to load "/username/path/path/filename.stl".

When I change the path to:

the mesh loads correctly.


Originally posted by dbworth on ROS Answers with karma: 1103 on 2012-07-18

Post score: 0

Original comments

Comment by Lorenz on 2012-07-18:
So what exactly is your question? For bug reports, it's best to file a ticket at the corresponding trac: https://kforge.ros.org/robotmodel/Trac

Comment by dbworth on 2012-07-18:
Ok, will do that. Originally this was a question, then I edited it when I found a solution :-)

Comment by dbworth on 2012-07-24:


2 Answers 2


Rosanswers logo

When you're looking for a file using file:// like http:// usually you need 3 slashes to tell it that it's a absolute url. try "file:///home/username/path/path/filename.stl" if you don't the first argument after the slashes is considered the hostname.

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.urlopen('file:///tmp/foo')
<addinfourl at 17115976 whose fp = <open file '/tmp/foo', mode 'rb' at 0x7f449c12aae0>>
>>> urllib.urlopen('file://tmp/foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/urllib.py", line 86, in urlopen
    return opener.open(url)
  File "/usr/lib/python2.6/urllib.py", line 205, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.6/urllib.py", line 465, in open_file
    return self.open_ftp(url)
  File "/usr/lib/python2.6/urllib.py", line 522, in open_ftp
    host = socket.gethostbyname(host)
IOError: [Errno socket error] [Errno -2] Name or service not known

Originally posted by tfoote with karma: 58457 on 2012-08-08

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by curi_ROS on 2018-10-10:
This syntax worked better for me "file:///$(find package_name)/path/to/file". This will likely work for different machines.


Rosanswers logo

You should use the Resource_retriever syntax which is more platform independent.

Originally posted by David Lu with karma: 10932 on 2012-07-18

This answer was NOT ACCEPTED on the original site

Post score: 2

Original comments

Comment by dbworth on 2012-07-24:
@David Lu: Sorry my post above had a copy-paste error. I've edited it now.

file:// is part of resource_retriever (http://www.ros.org/wiki/resource_retriever)

Comment by Lorenz on 2012-08-09:
What @David Lu probably means is that you should use 'package://name of your package/path/to/file' instead of putting absolute paths that work only on your machine.

Comment by shawnysh on 2017-01-10:
I use package:// instead of file, however still fail. the files were exported from sw_urdf_exporter


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.