mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

Converting the freebody into a static body and vice versa

Open jwcho0609 opened this issue 1 year ago • 5 comments

Hello, I am using MuJoCo's python binding to create a robot that can pick up and place items from different heights.

I have found that if I spawn too many items (~1000 different objects) into the simulation environment, the simulation crashes with a stack overflow error. I am assuming the potential cause of this is due to too many contacts being detected and calculated.

As a work around, I was thinking of initializing these objects as static, but when the object is picked up (or maybe if the robot end effector is near the object) the object becomes a free body so that it can be picked up.

My question is, is there a way to convert a body into a freebody from a static body and vice versa on the fly? These attributes are predefined in the xml files, so I was wondering if there is a way to maybe "toggle" it during simulation in code.

Thank you.

jwcho0609 avatar Jun 28 '23 09:06 jwcho0609

Are all of your boxes overlapping at t=0? Usually an easy fix would be to just set box qpos to different places.

saran-t avatar Jun 28 '23 18:06 saran-t

No, they are all generated at different positions with no overlap on each other.

jwcho0609 avatar Jun 29 '23 05:06 jwcho0609

Try using the Conjugate Gradient solver.

yuvaltassa avatar Jun 29 '23 14:06 yuvaltassa

@jwcho0609 Were you able to solve your problem?

kevinzakka avatar Dec 03 '23 20:12 kevinzakka

No, not necessarily; we just ended up having to decrease the number of bodies being used in simulation. I am still wondering if there are ways of disabling and enabling the freejoint attribute of a geom.

jwcho0609 avatar Dec 06 '23 21:12 jwcho0609