dojo-sim / Dojo.jl

A differentiable physics engine for robotics
MIT License
294 stars 25 forks source link

Loading Mechanism via URDF error when calling Dojo.Mechanism #69

Closed MrstupidJ closed 1 year ago

MrstupidJ commented 1 year ago

Hi,

I am a bit new to Julia but I would like to use Dojo to build a Simulator for my robot. To start with, I was following this page.

From my understanding, I should specify the path/directory of the urdf files (and the corresponding mesh files). Then call Dojo.Mechanism to load it into the "mechanism" data type. I tried with the urdf file of my robot, as well as the urdf files of rexhopper from this commit.

However it throws the following error when I try to reproduce it, which looks like the input arguments are not what should be expected. error_mechanism

Any hints on what shall I do to fix this? I much appreciate your help!

janbruedigam commented 1 year ago

The documentation is outdated an refers to an old example with slight different input parameters. I believe in your case you just need to change your function call by moving the semicolon: Mechanism("your_path"; floating=false/true, gravity=-0.0, timestep=0.01, spring=1.0, damper=0.5)

We will hopefully update the examples soon and then also update the documentation.

MrstupidJ commented 1 year ago

Thanks for your reply and happy new year Jan! It would be great if you guys can update the examples and documentation.

I will try to catch code from a more recent example (panda) for now and let you know if I have further questions.

MrstupidJ commented 1 year ago

Hi,

I am trying to follow your example code Dojo.jl/DojoEnvironments/src/panda/methods/dev.jl and try to load the same urdf file.

From what I can tell, you loaded panda_end_effector.urdf, by calling get_panda function. Your dev code was working and the panda mechanism object had 9 bodies and 9 joints. However, when I try to load the same file it returns a mechanism with 10 bodies and 10 joints. I was suspecting the "get_panda" function did something to reduce the number of joints, but haven't figured out how. May I ask where and how did you change the number of bodies and joints?

Thanks for your help!

janbruedigam commented 1 year ago

I could imagine the difference occurs because of a recently implemented function that removes/merges Fixed joints. There is an option for this in the constructor: Mechanism(path; keep_fixed_joints=false), that keeps or doesn't keep these joints. This option is set to false for panda here: https://github.com/dojo-sim/Dojo.jl/blob/f488920a4074603274c9eac4dd651d1b9b9f0140/DojoEnvironments/src/panda/methods/initialize.jl#L25

Maybe you just need to update Dojo and/or DojoEnvironments? Either way, you should be able to directly create a Mechanism without fixed joints from the URDF.

Once the examples are clean up, such issues hopefully will be resolved properly.

MrstupidJ commented 1 year ago

Thanks for your help! I can load the panda urdf file from scratch now.

I am going to try it on my own robot and let you know how it goes.