Sign in to follow this  
adriansnetlis

Simulating Human with Rigid Body Joints

Recommended Posts

I am willing to simulate a human in Blender Game Engine(which uses Bullet as physics engine) using rigid body joints. I want to set several human parts to be several rigid body objects(with maximally realistic parameters like mass, etc.). It may propably be like this:

[attachment=31593:Idea.png]

The proportions and shapes of the parts are not as they'll be in final, but their count and approximate placement idea must be clear for you.

 

What I want to know:

  • What is approximate weight distribution between theese parts for normal man and normal woman?
  • How to calculate balance, what torques do I need to apply at each part to make it as ballanced as possible?
  • How do I correctly apply different tasks(using torques, propably), e.g. walking, hitting with arm, jumping, etc.?
  • What's the best way to simulate reflexes(e.g. touching hot surface, being cut, etc.)?

Thanks!;)

Share this post


Link to post
Share on other sites

It would probably be a lot more easy to just bake animations for walking, punching etc. rather than calculating all the torques necessary to do these types of things. The forces involved in just standing up are pretty complex, and you don't want to waste CPU time having your character just stand.

You can use physics simulation when the person is actually at the mercy of physics, like when he is dead, or thrown back or something. That is called rag doll physics, but most games don't bother simulating physics for ordinary tasks.

Share this post


Link to post
Share on other sites

The ragdoll functioning is a monstrous thing that I can never understand, nor manage to make(even if every code line and setup part is told to me). That's why I am making physics model. This is more like gone be a template for BGE users. Propably this thing would be very useful for, for example, fighting games, parkour games etc. I think that it is worth to make;)

Share this post


Link to post
Share on other sites

What is approximate weight distribution between theese parts for normal man and normal woman?

I never found data about this, so calculating mass from the volume of the collision shape capsule.


How to calculate balance, what torques do I need to apply at each part to make it as ballanced as possible?

I'm using Newton which is very accurate and can simulate a powered ragdoll using powered joints,
so i luckily don't need to do a custom torque solver, like anyone else has to.


How do I correctly apply different tasks(using torques, propably), e.g. walking, hitting with arm, jumping, etc.?

Balancing is the basis of any upright motion, i use a inverted pendulum model and IK solvers to apply it to the ragdoll.
Inverted pendulum is a system of position dependent acceleration leading to complex equations.

What's the best way to simulate reflexes(e.g. touching hot surface, being cut, etc.)?

A reflex might be caused by loosing balance, Inverted Pendulum has analytical answers if and when this will happen.




Warning:
This is very hard and takes a lot of time. I work >5 years on this and could have done a lot of hand made animation in that time :)
I'm self taught and assume someone with very good math background can do it 10 times faster, but think about it before you start.
There is a high chance of failure.

This is what i have so far: https://www.youtube.com/watch?v=ULRnlAbtL3s[/list][/list] Edited by JoeJ

Share this post


Link to post
Share on other sites

Your work looks cool.

OK! So my question is - how does human actually balance himself(to not to fall down)? It's currently my aim topic. I think that I'm gone build this step by step basing on importancee. First thing, of course, is to make him stand:)

Share this post


Link to post
Share on other sites

So my question is - how does human actually balance himself(to not to fall down)?


There are basically two independent problems:

1. Physics simulation:
Imagine a human standing on only one leg. That's a system of 20 bodies and the foot body and ankle joint has to carry all the weight.
Mass ratio here is 1:50, worst case for game physics libs. Bullet can't even simulate a stack of a few equal mass bodies without jitter (the last time i've checked),
and also it may miss the necessary features for powered joints. So it's not the best choice for a demanding simulation like this and you'll have to add a lot of work,
probably ending up doing your own constraint solver.
I have experience with Bullet, Havok and ODE, but when i tried Newton i was blown away by the difference in stability, accuracy and robustness it offers.
It's by far the best library for this kind of simulation - sadly only few people know about this.
I would consider using Newton instead Bullet - no matter how much effort it takes to integrate it to the blender engine, it will pay off.

Other options would be:
* Simulate in smaller timesteps or use more substeps. That way the problem becomes easier for the physics lib to solve (at the cost of performance).
(Actually all research papers i know on the topic mention that practice - they use much higher settings than actual games do.)

* Cheat and use external forces to stabilize the system :)
(I assume Natural Motion does this, but that's just an assumption)



2. Control the simulation.
For the balancing i'll explain how i do it, but there are lots of totally different approaches.

There is the well studied control problem of balancing a Inverted Pendulum on a moving cart ( = balancing a stick with your hand).
See there at the picture in the middle: http://www.elysium-labs.com/robotics-corner/learn-robotics/biped-basics/zero-moment-point-zmp/

So, by moving the cart left and right, the stick can be balanced to stay upright.
Same is for human feet, but instead moving the cart we move the center of pressure between heel and toes.
Those limits also define the min / max angular acceleration the ankle joint can apply to the center of mass of the humkan body without tipping over.

Controlling this system with max efficiency is harder than it sounds, but you see the nice simplification from a 20 to a 2 bodies system.
To use it for the real ragdoll i use this procedure each simulation step:
* Divide the ragdoll into two groups of bodies, most likely at the ankle joint(s): group1: left and right foot, group2: all the other bodies
* Create a virtual single body for each of the groups conserving physical properties.
* Create the Inverted Pendulum from those 2 virtual bodies.
* Do the control task with the IP, resulting in differnt target state for the upper body
* Rotate the upper group of ragdoll bodies to reflect the changed state, use IK solvers to compensate errors introduced from that simplification. Edited by JoeJ

Share this post


Link to post
Share on other sites

OK!

Firstly, Blender uses Bullet and can't use any other physics library.

 

Secondly, I kind of get the idea how to do it, my real problem is - how to calculate, how strong torque is needed at specific body part(aswell as it's direction) to keep it balanced. I could even figure out the torques if I knew the mouscle stretching factors...

Share this post


Link to post
Share on other sites

Secondly, I kind of get the idea how to do it, my real problem is - how to calculate, how strong torque is needed at specific body part(aswell as it's direction) to keep it balanced. I could even figure out the torques if I knew the mouscle stretching factors...


If i get the question right, you need to solve the control problem first for a target pose and then use a constraint solver to calculate torques to get that pose.
... so you have to solve the hardest problems first without any way to proove what's wrong.

A better approach would be to ignore the control problem and focus on simultion only.
The goal would be to have the ragdoll keeping it's default T-pose (or any pose e.g. from animation).
It may fall over, you may pick a limb and drag it around, but it should keep the pose.

I assume you use Bullets standart ball socket joints to keep the bones at their joint positions, so you only need to worry about torques.
With Newton i can set a relative target acceleration for each joint and it solves the multi body problem for me.
If Bullet has no rotational motorized joints (i'd ask at bullet forum), you need to make your own constraint solver.
(I can't tell how - i have an idea but don't know how well it would work)

Share this post


Link to post
Share on other sites

1. Physics simulation:
Imagine a human standing on only one leg. That's a system of 20 bodies and the foot body and ankle joint has to carry all the weight.
Mass ratio here is 1:50, worst case for game physics libs. Bullet can't even simulate a stack of a few equal mass bodies without jitter (the last time i've checked),
and also it may miss the necessary features for powered joints. So it's not the best choice for a demanding simulation like this and you'll have to add a lot of work,
probably ending up doing your own constraint solver.
I have experience with Bullet, Havok and ODE, but when i tried Newton i was blown away by the difference in stability, accuracy and robustness it offers.
It's by far the best library for this kind of simulation - sadly only few people know about this.


If you want accurate, stable control of a mechanism with lots of joints and large mass ratios, the important thing is to be using an appropriate solver. Bullet does have a Featherstone solver, though I don't know how good it is for actively driving articulations. PhysX has an articulation solver, and I know from first hand experience that it can be used to drive articulations accurately, without excessive numbers of iterations/small timesteps.
 

* Cheat and use external forces to stabilize the system :)
(I assume Natural Motion does this, but that's just an assumption)


Your assumption is wrong :) Of course, we can use external "cheat" forces to add stability, but that's not the fundamental method (and it all works without this). I can't discuss the methods by which we calculate the joint torques, but the character is controlled by joint torques.

For example, there's some nice demo here:

https://youtu.be/HauN98naZ9U

 

You want to know masses and moments of inertia for the different body parts, and don't want to go to the messy trouble of chopping up a cadaver yourself? OK - take a look here: http://www.smf.org/docs/articles/hic/USAARL_88-5.pdf

Share this post


Link to post
Share on other sites
Ooops, sorry for the wrong assumption (still having a copy of jiglib around as an appologize) :)

To complete the updated information about physics engines, Newton has a new feature for accurate joint graphs as well.
I'll try it when i have time to come back on this...

Thanks for the pdf :)

Share this post


Link to post
Share on other sites

Hm... I still want to know the principle of how human balances. For example, if the upper body part is starting to fall backwards - which mouscles does stretch and how much do they stretch?:)

By the way - the physical character in the video is amazing!:)

Share this post


Link to post
Share on other sites
Project the vertices of the feet (or contacts) to the gravity plane (ground) and make the convex hull of them to get the 'support polygon'.

Next calculate the COM of all bodies (mass weighted average), project to ground plane too and try to keep it inside the support polygon.
That would be a very simple approach for balancing good enough for first experiments.

Something better using math from this paper:
https://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0CCsQFjABahUKEwix8_XK3KHHAhVJiRoKHRpUBVs&url=http%3A%2F%2Frepository.tudelft.nl%2Fassets%2Fuuid%3A9e390296-9ba9-46d5-9b3f-3b7653b2d1ba%2FThesis_Sebastiaan_Kiemel.pdf&ei=fUfKVfHAKcmSapqoldgF&usg=AFQjCNFSJJKJA1c26bbxlR1fi1NqvC-jgA&sig2=HWl6Hh1P6NFa16njKwUWiw&bvm=bv.99804247,d.d2s
There is how to calculate the Center of Pressure,
and the Instaneous Capture Point (ICP).
If COP == ICP and both are in the support polygon, the human is balanced.
So a simple balance controller can calculate a ankle counter rotation from (COP-ICP) * userGain (used this in my video)

There's still a lot room for improvement, i took the route towards an analytical solution answering the 'how fast' question,
others use data from real humans as input for an optimization,
others use learning approaches (NaturalMation AFAIK, assumption again)
...

However, most effective muscles to move the com of upright humans are mainly the ankle joints. Edited by JoeJ

Share this post


Link to post
Share on other sites

You can do a lot of balancing by just considering the ankles or, more generally, rotating the floor contact plane relative to the character. For side-side balance, the equivalent of "ankle balance" in the fwd/back direction is pushing down with one foot - and you can generalise this into having a target plane for the feet that. This works when the feet are at awkward angles too, and can be extended to handle the feet being on uneven terrain.

 

However, you can do a lot more than just balancing with the ankles/feet. If you imagine standing facing out over a cliff top, feet so near the edge you can't step, and somebody gives you a shove from behind, you use your whole body to balance/try to recover - leaning forwards at the hip and "windmilling" your arms. It's worth thinking about what these actions are actually doing, how they induce forces on your feet which are the only ones that can affect your COM - its position and velocity. Ankles/feet are good for COM position control. Upper body motion is good for COM velocity control.

 

There are two types of forces on the feet that are relevant - normal and tangential (the latter coming from friction). It's easy to imagine (or even do!) an experiment where there's no tangential/frictional force - e.g. standing on ice. The other extreme, where you have a single contact point (i.e. you can make use of the friction forces, but the centre of pressure is always fixed) is harder to experience - would it be possible to stand on the tip of a spike, where you have no option to balance with just "ankle control"? See the "Balance Controller (new)" video here for the answer! http://royfeatherstone.org/skippy/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this