Page 1 of 1

MuJoCo soft body force sensor

Posted: 20 Jun 2024, 16:14
by SkytAsul
Hello!
I am trying to link an haptic hand device with CoppeliaSim to simulate the touch of a soft body. For this, I need to get the force generated by the interaction between the virtual finger (a primitive cylinder for testing purpose) and the MuJoCo soft body (that I took from one of the demonstration scenes).
I tried to use the

Code: Select all

sim.getContactInfo
method, but it's too slow due to the large amount of different contacts and rather imprecise. I would prefer to use a force sensor, but I do not how should I link it to the soft body. Does anybody has an idea?
Thanks!

Re: MuJoCo soft body force sensor

Posted: 21 Jun 2024, 08:30
by coppelia
Hello,

have a look at the demo scene scenes/mujoco/compositeAndOtherCallbacks.ttt: in that scene, attache a force sensor to e.g. '/Floor', and an 'auxShape' to the force sensor: the auxShape can have a very small mass and should be non-respondable.
Then, in the script attached to '/softBody', replace '/Floor' with '/auxShape' on line 6: this will attach the composite to the force sensor via the auxShape, and you should be able to read the force sensor via sim.readForceSensor.

Cheers

Re: MuJoCo soft body force sensor

Posted: 24 Jun 2024, 09:37
by SkytAsul
Thank you very much for your reply! In fact, it was not even necessary to change anything in the injection script.

For further reference, it is worth noting that even though the auxShape should be non-respondable, it should still be dynamic. Otherwise you could get weird errors from MuJoCo when trying to attach to it, things like "unknown element".