rohanpsingh / mc_mujoco

MuJoCo interface for mc-rtc
https://arxiv.org/abs/2209.00274
BSD 2-Clause "Simplified" License
77 stars 18 forks source link

I can't add an additional object to the xml of type free joint #25

Closed N1ckfm closed 2 years ago

N1ckfm commented 2 years ago

Hi, I want to add a block or any object with free joint to the model, for example the robot take this box, but I get this error in the xml:

info] [mc_mujoco] Initialized successful.
qpos size: 41. Should be: 266
qvel size: 40. Should be: 264
[critical] [mc_mujoco] Set inital state failed.
terminate called after throwing an instance of 'std::runtime_error'
  what():  [mc_mujoco] Set inital state failed.
Aborted (core dumped)

I will appreciate your comments thanks Nícolas

rohanpsingh commented 2 years ago

Hi @N1ckfm

I haven't tried this ever so don't know if you're making a mistake or if there's a problem. I think @arntanguy tried adding extra objects but I'm not sure. Anyway I would need some more time to look into this :(

rohanpsingh commented 2 years ago

Hi @N1ckfm
Do you still need help on this?

N1ckfm commented 2 years ago

Hi, I talked with Pierre about that and he mentioned me that is necessary to add an object in the controller and then mc_mujoco will load it. In this case I would like to know an example of put an box in the floor and an box moving with the robot in the controller. In mc_mujoco I can add an object in the floor because it is not a joint. But I guess if the robot walk over this box the controller will be consider there are no box, because it was added in mc_mujoco instead of the controller. I will appreciate your comments.

rohanpsingh commented 2 years ago

Thanks to @gergondet as he just made a commit to auto install the files for new objects!

All you need to do now is to add the object to your controller, perhaps as follows:

robots:
  my_box_object:
    module: object/box
    init_pos:
      translation: [1.0, 0, 0.5]
      rotation: [0, 0, 0]
gergondet commented 2 years ago

Hi @N1ckfm

As @rohanpsingh mentionned I have added support for object/box in your controller so it should appear if you set it in your configuration. However, unless your environment has somewhere to put the box it should start with z = 0.05 to match the height of the box (the box is 0.22x0.22x0.1 with its center in the center of the box)