MuJoCo soft body force sensor

Typically: "How do I... ", "How can I... " questions
Post Reply
SkytAsul
Posts: 2
Joined: 20 Jun 2024, 16:09

MuJoCo soft body force sensor

Post 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!

coppelia
Site Admin
Posts: 10504
Joined: 14 Dec 2012, 00:25

Re: MuJoCo soft body force sensor

Post 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

SkytAsul
Posts: 2
Joined: 20 Jun 2024, 16:09

Re: MuJoCo soft body force sensor

Post 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".

Post Reply