DavidPL1 / assembly_example

Example code for interaction with our assembly simulation ICRA 2023 challenge
7 stars 1 forks source link

How to simulate the tightening of screws and nuts in Mujoco? #29

Closed renyu2016 closed 7 months ago

renyu2016 commented 7 months ago

Hi, there, I'm currently working on simulating the process of tightening screws and nuts in Mujoco. I note when loading models into the simulator in this work, there are no threads on the nut and screw models. I'm curious about how Mujoco achieves the simulation of the tightening process when there are no visible threads after rotation. How is this step implemented?

Thank you for your help!

DavidPL1 commented 7 months ago

With regular point-based contacts this is infeasible, I would even say impossible, because the thin thread causes so many (instable) contacts.

We used constraints to implement this in a sort of simplified way. @fpatzelt implemented this, but IIRC when a matching screw and nut are aligned and the screw rotates clockwise relative to the nut up to a certain threshold, both bodies are welded together with a set of constraints. Another constraint couples the z-axis rotation of the screw to translation on the z-axis, such that clockwise rotation moves it down, while counter-clockwise rotation moves it up. We additionally defined a maximum relative rotation between screw and nut, to limit how far the screw can move down and increase a resistive force against the rotation close to this limit.

This described procedure is implemented in this mujoco_ros plugin. (@fpatzelt, not sure if the example configuration in the repo is up to date, I don't see any parameters in the worldfile. Can we update this?) This implementation has the drawbacks of neglecting thread-alignment and heavily simplifying the physics involved in the process.

However, with its recent 3.0.0 release, MuJoCo introduced SDF contacts. With these enabled, this can be simulated more realistically. Threading is even showcased in this video (here is the used modelfile). Currently mujoco_ros runs on MuJoCo 2.3.6 and there is also a branch for 2.3.7 which should run also fine, but these versions are too old for SDF contacts. I am planning to update to the newest MuJoCo release to include all the new solver options and native MuJoCo plugins, but I have some other more pressing work to do first. Thus, I don't think this will be ready before January.

So if you don't need ROS in this specific setup, I'd recommend using vanilla MuJoCo 3, otherwise you can use our plugin and will have possibility to switch to SDF contacts, once I get to updating mujoco_ros.

renyu2016 commented 7 months ago

I see! Thanks a lot for your detailed and useful response!