moving platforms from kinematic bodies

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

moving platforms from kinematic bodies

Postby JoeJ » Sun Dec 29, 2013 5:40 pm

I want to create moving platforms to do some tests for my balancing ragdoll.
To make kinematic bodies behave like dynamic bodies, i set velocity and use set matrix to update position.
The code below works, but i need to ask: Is there any other thing i should do, like setting forces, acceleration...?
And is everything in the correct order?

Code: Select all

NewtonBody *pf = the kinematic platform body

sVec3 vel (sin(balTime) * 0.1, 0, 0); // some animation
NewtonBodySetVelocity (pf, &vel[0]);

sMat4 matrix;
NewtonBodyGetMatrix (pf, &matrix[0][0]);
matrix[3] += vel * step;
NewtonBodySetMatrix (pf, &matrix[0][0]);

NewtonUpdate (world, step);
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: moving platforms from kinematic bodies

Postby Julio Jerez » Sun Dec 29, 2013 5:41 pm

you just set velocity and angular velocity
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: moving platforms from kinematic bodies

Postby JoeJ » Sun Dec 29, 2013 5:59 pm

Do you mean the bodies should be moved by newton when setting velocities?
That's not the case no matter what mass i set, thus i do myself using SetMatrix.

However - it's fine as it is.
Interesting: If i set only velocity but not position, the body behaves like a treadmill / walking belt.
That's cool and easier than messing around with contact velocities :)
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: moving platforms from kinematic bodies

Postby Julio Jerez » Sun Dec 29, 2013 6:47 pm

no you need to integrated it. There is a function in newton for that
Code: Select all
void NewtonBodyIntegrateVelocity (const NewtonBody* const bodyPtr, dFloat timestep)

you also most set to mass to the body.
if you do not then when you move the body it that body is colliding with some other dynamics body it will put with unlimited force.

basically you make you kinematic body, you set mass,

then you set the velocity in you code logig,
kinematic bodies are like static bodies by the have mass. which make then very special because they behave like dynamic bodies when interacting with other bodies


kinematic bodies lend themselves to very interesting effects, than are had to accomplish with static or dynamics bodies.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: moving platforms from kinematic bodies

Postby JoeJ » Mon Dec 30, 2013 5:07 am

Julio Jerez wrote:kinematic bodies lend themselves to very interesting effects, than are had to accomplish with static or dynamics bodies.


Yes, i plan to use them later in the real game, but this leads to more questions:

The ragdoll collects ground velocity information at contact points.
If i use mass for the platform, then newton thinks the weight of the ragdoll moves the platform downwards, even if it moves only sideways.
Somehow this fools ragdoll AI, and to limit this effect i set a real high platform mass (ratio 100:1).
But for this special case i do not need to worry about high mass ratios, and this will not have any bad effect on simulation, yes?

Another interesting thing i see is that contacts do not move with the bodies when velocity and distance is small - they stick at the same world position for a while. Does that mean that contact caching only works as long as the contact can keep it's position?
Example is stacking boxes inside a train moving at constant velocity. Will the simulation in the train be less stable or take longer to calculate?

I'm just curious - up to now i can't see any bad things with the ragdoll standing on moving platform :)
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: moving platforms from kinematic bodies

Postby JoeJ » Wed Jan 01, 2014 12:55 pm

I found a minor problem about kinematic bodies, maybe it's a bug.

I use two kinematic platforms - one for each foot.
When setting one to a different angle, the ragdoll begins to slide as if it would be not in static friction state.
Moving the two platforms apart so there is no penetration between them solves the problem: Sliding stops and ragdoll comes to rest.
Somehow the solver gets confused by penetrating kinematic bodies.

Another experiment shows a similar problem:
One platform moves left / right, the other stays fixed.
As soon as the platforms begin to penetrate, the measured platform velocities are wrong.
Both feet measure the same velocity, which seems the average from both platform bodies.

I'll use smaller platforms and avoid penetrations, but maybe you should know about that...
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: moving platforms from kinematic bodies

Postby Julio Jerez » Wed Jan 01, 2014 2:55 pm

JoeJ wrote:Another experiment shows a similar problem:
One platform moves left / right, the other stays fixed.
As soon as the platforms begin to penetrate, the measured platform velocities are wrong.
Both feet measure the same velocity, which seems the average from both platform bodies.


yes that will happen, basically when the solve is finding are connects by joints, when it find more than one static object, it does not consider then as separate objects,
instead it make a single entry. the reason is that adding multiple static object to a matrix create singular matrices.
I suppose I can add logic to keep track of what goes to what.

in the pass was not a problem since static objects, I see if is easy to fix.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: moving platforms from kinematic bodies

Postby JoeJ » Sat Feb 01, 2014 5:57 pm

There's one confusing thing about kinematic bodies: You MUST set velocity every frame, even if they should not move.
Otherwise they think they are moving (because they have mass) and thus a body resting on top of them goes slowly through them.
Not a problem, but maybe it makes sense you set zero velocity automatically after each step, or something similar.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: moving platforms from kinematic bodies

Postby Julio Jerez » Sat Feb 01, 2014 6:26 pm

don't they have force an torque callback?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: moving platforms from kinematic bodies

Postby JoeJ » Sun Feb 02, 2014 4:32 am

I tried to set callback and apply velocity there, but no movement for kinematic bodies, so it seems it is never called.
Currently i set velocities before NewtonUpdate.

It's just that some people may think it's a collision bug, but on the other side if you set zero velocity for many bodies and the user later overwrites them it's a little waste.

What would make more sense:
If user sets callback, expect he will set velocity there. If not, set zero velocity.
(... loosing the nice property to do it all without callback like i do now)

Similar for dynamic Bodies:
If user does not set a callback, apply user defined global gravity.
(Because maybe it's faster if you don't need to call a callback fer every body, and for most bodies the F/T callback will apply only gravity and does nothing else.)


... just to keep in mind, there's no problem at all.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron