Bo2d - humanoid model

Hi,

I created a model using a few box2d-bodies. I can keep it from falling onto the ground
by having a hardcoded mouse joint between it's head-body and the ground.

But it doesn't seem to be the proper way. When moving it, I destroy the previous mousejoint
and create a new one in the same hight (initialized at the begining) and the new x-position.

It is working sometimes, but when I move the model a little bit more violent, then it is falling onto the ground.

Of course I can send the piece of code I use and the executable itself (using the 'testbed').

How else can be created a model? And specifically, how else can be kept standing up ?
It it the proper way, by having such a mousejoint? Or is there something better? Did anyone from you guys (or girls) have successfully created something like this?

If you need any other details, please tell me.

Any help would be appriciated

thanks

theodosi
Use a neural network for this :]
I'm in the process of creating something simular. This was achieved using (8.6)Revolute Joints and all joints with motors. Turns out the Wiki will be taken-down very soon:

"You can also use joint motors to track a desired joint angle."
Code:
... Game Loop Begin ...
float32 angleError = myJoint->GetJointAngle() - angleTarget;
float32 gain = 0.1f;
myJoint->SetMotorSpeed(-gain * angleError);
... Game Loop End ...


Neosano mentioned neural networking in another thread, which at first I thought he was joking but now I've started learning how they are created/ uses. I'm not 100% sure how it would help ...yet.

I'm assuming each limb is a neuron with it's current joint angle as it's input and desired angle as it's output - continually correcting each limb to maintain overall balance of the RagDoll. But it seems to me that you gotta let the program run (learning / pre 'real game') till balance is achieved then record all the figures to be used later for the 'real game'.
You could make him ride on something. What I mean is if you created an invisible box that attaches to his torso and extends down to his feet, then that would be a good way to fake it.
aitken85 wrote:
Neosano mentioned neural networking in another thread, which at first I thought he was joking but now I've started learning how they are created/ uses. I'm not 100% sure how it would help ...yet.

I'm assuming each limb is a neuron with it's current joint angle as it's input and desired angle as it's output - continually correcting each limb to maintain overall balance of the RagDoll. But it seems to me that you gotta let the program run (learning / pre 'real game') till balance is achieved then record all the figures to be used later for the 'real game'.

You'll need more inputs. Something like a human vestibular system. Maybe some other input neurons for controlling your human. You'll be able to teach him to jump, walk, run and even more!
But I'm not sure about performance :-S


Edit:
Don't forget about the visual perception! For this I suggest some raycasts around the body.
And maybe even it should feel the restitution and friction of the ground it is touching.
guys,

My issue is solved.

And, as all solutions in this universe, it was very very simple:

I apply in every iteration of the game loop a force (x = 0,y = in Newtons,according to the total mass of the actor) at the center of mass of the (box2d-)body that plays the roll of the head of my actor.

so, in my case, these three lines are enough to keep my actor from falling into the ground as if he was dead:
....
b2Vec2 centerOfMass = head->GetWorldCenter();
b2Vec2 force(0, 200.0f);
head->ApplyForce(force, centerOfMass);

and for moving him I use a mouseJoint by stealing source parts from Testbed.

Now what remains to me is to set precise values in common parameters (frictions, densities,etc)
so that I can give more physical behavior to the actor.

Theodosis

Original thread: https://box2d.org/forum/viewtopic.php?t=4770