[Solved]If I want hard constraints is featherstone and multibody the only effective solution?

Post Reply
User avatar
Octavius_Ace
Posts: 20
Joined: Sat Jun 04, 2016 10:34 pm
Location: Edinburgh

[Solved]If I want hard constraints is featherstone and multibody the only effective solution?

Post by Octavius_Ace »

Hi,
For context, I don't use the python binding and only use the core Dynamic, Collision and LinearMaths libraries in my code.

I've had a rag doll implementation, using the sequential impulse solver for years and ignored the "elasticity" in the constraint chains.
I've read most posts relating to this lack of hard constraints in ragdolls and don't want to go over old ground. (I've experimented with damping, softness bias limits, error reduction, CFM, similar mass ratios, using hinge in place of 6DoF etc.)
I've reduced test cases down to a single constraint between a static RB and a dynamic RB, and I can still apply moderate impulses that visibly violate the constraint.

All of the above is recounted in many other posts and I noticed that while the old rag doll demo is gone, it's still in one of the stress tests and still uses Seq Imp Solver and has the same limitations.
So it feels like I'm at the end of the road with the Seq Imp Solver.

Options appear to be:
  • Featherstone / Multibody
  • An MLCP solver
  • Switch physics engines - I'd rather not, as I like Bullet and have invested a fair amount of time understanding it and integrating it.
So questions:
1) Am I missing a trick with Seq Impulse and there is a way to harden up constraints? (Using btNNCGConstraintSolver didn't improve things )
2) Do any of the MLCP solvers offer a solution?
1) Does Featherstone provide genuinely hard constraints or will I find the softness problem reduced but still present?
2) Does Featherstone support more than slider and hinge - I'm unclear on this?
3) Is PhysX (for instance) going to suffer the same problems or is that framework's TGS solver a better option?

Happy to take any advice/experience around this.

Cheers.
Last edited by Octavius_Ace on Sun Feb 07, 2021 11:17 am, edited 1 time in total.
acu192
Posts: 6
Joined: Thu Jan 28, 2021 12:23 am

Re: If I want hard constraints is featherstone and multibody the only effective solution?

Post by acu192 »

I'm also very interested in knowing the answer to your questions. Hopefully someone who knows the multibody world can help us here.
User avatar
drleviathan
Posts: 699
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: If I want hard constraints is featherstone and multibody the only effective solution?

Post by drleviathan »

Years ago (2014) I tried using FixedConstraints (with dynamic transforms) to drive a ragdoll character. I tried a range of numbers of constraints and body-parts. As I recall: with the mass ratios and timesteps I was using: above 15 constraints it was pseudo unstable and with 9 constraints (and fewer body parts) it was stable but soft. So I blended Bullet's solution with a custom verlet solver step (character parts only) and was able to get a stiffer solution with decent performance. The good news: a verlet sovler is relatively simple to implement (the math is not too hard) and if you just need to simulate a small number of characters/constraints I believe such a solution is viable for real-time simulations.
User avatar
Octavius_Ace
Posts: 20
Joined: Sat Jun 04, 2016 10:34 pm
Location: Edinburgh

Re: [Solved]If I want hard constraints is featherstone and multibody the only effective solution?

Post by Octavius_Ace »

Apologies for not replying sooner. I missed your responses.
The good news from my perspective, is that having integrated but not used a multi body loader, I got a well behaving skeleton set up using only the default sequential impulse solver.
How did I do this? By following the rules on world scaling correctly.

As Bullet's multi body solver is limited to ball, hinge and slider joints, I created a model and skeleton, using only hinges with angular limits. My intention was to use seq imp and multi body side by side, for comparison.
I also kept the skeleton simple:
Pelvis, single torso, head, upper arms lower arms, hands, upper legs, lower legs and feet.
In doing this I removed multiple spine bones, neck and toe bones.
It also meant removing a number of 6DOF joints.

But the key to a more stable ragdoll, was also taking notice of a limit that is mentioned here and there throughout forum replies and early documentation. Do not allow any collision shape dimension to fall below 0.2 units.
This turned out to be the key to my problems.
Up until this point I always sized my world to reflect real world dimensions. So arm bones would be around 30cm long and 5 to 10 cm in diameter, i.e. 0.3 by 0.1
At these dimensions, even two RBs with a single hinge between them and equal 1 kg masses, would behave like elastic.
Scaling up and making the min bone diameter 20 cm (0.2 units) has an amazing effect on stability.

So you just need to decide what the smallest dimension is in your simulation and scale that to at least 0.2 then apply that scale to everything else. Remember to adjust masses accordingly too.
Be careful though, as there's a trade off to be had. I scaled up by around 2.5, so my hand bone RBs can have dims as low as 0.2/2.5 = 0.08 so 8cm
This means a 2m tall figure, is modelled as 5 metres in Blender.
There will be limits on this scaling workaround, as masses start to become very large.
When objects get unrealistically large, I find the simulation becomes very 'floaty', as if objects are made of polystyrene and air resistance is becoming noticeable. (I know Bullet doesn't stimulate air resistance but that's what it looks like)

One final thing, observing this lower limit also massively reduces the occurrence of RBs passing through bvh mesh surfaces too. So consider scale first, if you run into pass through problems.
Do this before any of the other suggestions people make in forum replies, such as:
increasing solver iterations
decreasing simulation step length
increasing mesh triangle density

Anyway, there you have it, a simple solution to the problem.
I'll post a video on You Tube in the coming days by way of a demo and add a link here.

Cheers
User avatar
Octavius_Ace
Posts: 20
Joined: Sat Jun 04, 2016 10:34 pm
Location: Edinburgh

Re: [Solved]If I want hard constraints is featherstone and multibody the only effective solution?

Post by Octavius_Ace »

And here's a quick video showing a well-behaved rag doll, where rigid body min dims are greater the 0.2.

https://www.youtube.com/watch?v=vtRmbP0ZwHM

Thanks.
acu192
Posts: 6
Joined: Thu Jan 28, 2021 12:23 am

Re: [Solved]If I want hard constraints is featherstone and multibody the only effective solution?

Post by acu192 »

Thanks for following up with you solution, Octavius_Ace. Glad to hear it, and I'll give it a try soon to see if I can solve my own "constraint stretching" issues as well.

Sidenote... You say:
When objects get unrealistically large, I find the simulation becomes very 'floaty',
Maybe this is because you didn't increase gravity? I found this idea un-intuitive at first, but turns out if you scale objects by X you also have to scale gravity by X to make it look normal.
Post Reply