How to load URDF files with .dae models into MeshCat?


#1

I’m trying to use the JuliaRobotics ecosystem with UR robotic arms and can not find a way to open the official URDF-s. My problem is, that .dae files are not supported, and if I convert those files to .obj, then the model is placed wrongly into the scene:


My question is that, is there a way to load these “original files” without modification? Or I have to modify/build my own URDF-s? I decided to post this question, because that’s the first time I use this format, so I’m not confident with it (yet).


#2

Unfortunately, MeshIO.jl doesn’t support native loading of .dae files yet (see https://github.com/JuliaIO/MeshIO.jl/issues/11), so conversion to .obj is necessary for now. MechanismGeometries.jl does automatically replace the .dae extension with .obj though, so you shouldn’t have to edit the URDF, but it prints a warning. If you want to get rid of that warning, you could do

using Logging # from stdlib
with_logger(ConsoleLogger(stderr, Base.CoreLogging.Error)) do
    # load the URDF
end

Some questions to get started:

  • exactly which xacro file are you using?
  • how are you calling xacro?
  • which tool are you using to convert to .obj?

#3

In addition to what Twan said, I do have an experimental branch of MeshIO that adds .dae file support, and you’re welcome to try it out. You can add my branch with: pkg> add https://github.com/rdeits/MeshIO.jl#rd/dae-support .

Since this branch is still experimental, you’ll also need to tell FileIO that the .dae format exists and that MeshIO can handle it:

julia> FileIO.add_format(format"DAE", (), ".dae")
DataFormat{:DAE}

julia> FileIO.add_loader(format"DAE", :MeshIO)
1-element Array{Symbol,1}:
 :MeshIO

I’d be really curious to hear if that works well enough to load your UR10 model. If not, we can either try to fix the .dae loader or figure out what went wrong with your conversion to .obj.


#4

@rdeits, I’ve rebased your MeshIO branch and added LightXML to the REQUIRE file: https://github.com/tkoolen/MeshIO.jl/tree/tk/dae-support-updates. I’ve also rebased the accompanying dae-geometry branch of MechanismGeometries onto master and removed dead code: https://github.com/JuliaRobotics/MechanismGeometries.jl/tree/tk/dae-geometries-updates. Furthermore, we’ll need https://github.com/tkoolen/FileIO.jl/tree/tk/dae.

I created a git repo with my setup (contains URDF, DAE meshes, toml files, and a script): https://github.com/tkoolen/universal-robot-dae-jl

It’s not working quite yet:

Error encountered while loading "ur_description/meshes/ur10/visual/shoulder.dae".
Fatal error:
ERROR: LoadError: MethodError: no method matching read_polylist(::Nothing)
Closest candidates are:
  read_polylist(::LightXML.XMLElement) at /Users/tkoolen/.julia/packages/MeshIO/SVI0R/src/io/dae.jl:28

#5

Converting to .obj works fine for me by the way:

I used MeshLab to do the conversion. Run

for file in *.dae; do
    meshlabserver -i "$file" -o "${file%.*}.obj" # -om vc
done

in the visuals directory.

Note: on OSX, following https://github.com/cnr-isti-vclab/meshlab/issues/64#issuecomment-280917011, I needed to run

cd /Applications/meshlab.app/Contents/MacOS
install_name_tool -add_rpath "@executable_path/../Frameworks” meshlabserver

and I added the directory containing meshlabserver (/Applications/meshlab.app/Contents/MacOS for me) to my PATH.


#6

I cloned the repo, then

$ cd universal_robot/ur_description/urdf
$ xacro --inorder u10_robot.urdf.xacro > ur10_original.urdf

(I have a feeling that is not the way that it should be done, but does the trick. Probably I should use ROS’s package environment variable or something like that.)

For converting the files, I used the first online tool I found: meshconvert.com. I know it’s not an ideal solution, I will definitely will check MeshLab!
I assume that this converter hacked the coordinate frames which caused my issue.
(I will check later your other responses too!)


#7

I couldn’t get it working. Maybe it’s the issue with the LightXML dependency.
I got the “same” warning as before:

┌ Warning: Could not find the mesh file: package://ur_description/meshes/ur10/visual/wrist2.obj. I t
ried substituting the following folders for the 'package://' prefix: ["C:\\Users\\cstamas\\Documents
\\SZTAKI\\juhulia\\Julia-Mesh-Test"]. Note that I replaced the file's original extension with .obj t
o try to find a mesh in a format I can actually load.

If it’s not problem I wouldn’t go into debugging this on my installation as @tkoolen merged the “issue” into one repo.


#8

To be clear, the repo I created is set up for debugging the native .dae file support (not working yet), not for loading the .objs.

Does the file C:\Users\cstamas\Documents\SZTAKI\juhulia\Julia-Mesh-Test\ur_description\meshes\ur10\visual\wrist2.obj exist?

You may have to use the package_path keyword argument for URDFVisuals (see https://github.com/JuliaRobotics/MechanismGeometries.jl#urdf-visuals), which defaults to ros_package_path() = split(get(ENV, "ROS_PACKAGE_PATH", ""), ':') (an empty string array if the ROS_PACKAGE_PATH environment variable isn’t set). But then again you were apparently able to load meshes (even if they weren’t the right ones) before, so not sure what’s going wrong now.


#9

To be clear, the repo I created is set up for debugging the native .dae file support (not working yet), not for loading the .obj s.

Yes, I’m aware of it, I was just going through every answer and checked them with my configuration.

Does the file C:\Users\cstamas\Documents\SZTAKI\juhulia\Julia-Mesh-Test\ur_description\meshes\ur10\visual\wrist2.obj exist?

No, it doesn’t, I was trying to parse the .dae files with @rdeits MeshIO branch.

After that, I tried your repo:

I created a git repo with my setup (contains URDF, DAE meshes, toml files, and a script): https://github.com/tkoolen/universal-robot-dae-jl

As expected I got the same MethodError as you.
I had some troubles with MeshLab, but now it’s working fine and the converted .obj-s are also perfect.

I appreciate your help and detailed answers!
Also thank your for the JuliaRobotics ecosystem, these packages are very helpful for my work!


#10

Ah, I thought you meant the .obj route wasn’t working.

Thanks, and glad to hear! I hope we can get the native .dae support working soonish. I’m afraid I’m stretched a little thin, so for anybody watching this thread, this would be a great way to contribute.