Page 1 of 1

Constraint Problem: Fix Constraint is Not Fixed

Posted: Mon Jul 20, 2020 4:29 am
by lqb
Hi, I am using constraints to connect some joints (yellow sphere):
1.png (12.68 KiB) Viewed 380 times
However, as the time goes, the relative position of connected joints changed:
2.png (12.36 KiB) Viewed 380 times
How can I get the connected joints fixed?
Note that I have to use constraints to connect them because the environment is dynamic: I don't know which joint to connect before hand.
I would appreciate any help!

Re: Constraint Problem: Fix Constraint is Not Fixed

Posted: Mon Jul 20, 2020 7:24 am
by S1L3nCe
Fixed constraints
Or you could destroy both bodies to create one with a Compound shape

Re: Constraint Problem: Fix Constraint is Not Fixed

Posted: Mon Jul 20, 2020 2:22 pm
by drleviathan
btFixedConstraints should work ok until you get interconnected pieces with a large number of joints. As the constraint number grows the whole collection gets "soft" and the constraints will not be fully satisfied. The collection will appear to "sag" under collisions (and gravity, if you have it). The number of interconnected constraints at which the softness becomes visible depends on your simulation config (substeps, constraint solver iterations) until you start running out of CPU resources at which point your simulation will fail to be real-time.

If your connected objects remain rigid enough for your needs but the actual connections are drifting over time, then that would be unexpected and I would classify it as a "bug". If that is the case then my first hypothesis would be to guess you are constantly recomputing the local-frame transforms of your constraints, which could introduce drift. Dunno if that is what you're doing but if you are: then I would recommend you only set the local-frame transforms only once when the constraint is first created.

Yes, as S1L3nCe mentioned: you could "connect" two objects by combining them into a btCompoundShape and replacing the two btRigidBodies with one. This is the only way to achieve true rigidity between connections. It might take some trickery to get this exactly right because the destruction/reconstruction of byRigidBodies tends to reset contact points which could introduce non-physical pops, and if you wanted to conserve energy/momentum across transitions then you'd have to do much math.

Re: Constraint Problem: Fix Constraint is Not Fixed

Posted: Thu Jul 23, 2020 3:39 am
by lqb
Thank you. I am using pyBullet, so I guess the "JOINT_FIXED" constraint is the same as btFixedConstraints in Bullet. I do not update anything once I set up the constraint. I also do not have a lot of constraints.

One thing that might be important is that the blue links are connected to motor, while the green links are not. I think that's the reason why the connection between blue links and green links do not have any problem. I inspected all the parameters while running the environment, and I can see there is nothing changed. So I don't know how to fix it using constraints.