Unstable Connected Joints

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Unstable Connected Joints

Postby MeltingPlastic » Mon Jul 01, 2019 1:05 pm

The changes sounds great,

Just curious, will these new changes effect how a newtons cradle will simulate? Will the energy transfer be more accurate? ( I have not actually made one with newton yet )
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Unstable Connected Joints

Postby Julio Jerez » Mon Jul 01, 2019 1:55 pm

actually this change should make newton cradles behave much better.
the reason is the equation of impulse is applied to each pair, pair per pair,
while mixing impulse with forces put try to solve everything together in one system of equation. at the is incorrect for impulse.
must the time missing force and impulse works as long as the impulse is much large the the force.

It is very simple.
the equation of force is
m * a = fe + fc

where fx Is the constraint forces
the eaition for ienpeul si

limit m * dv = fe * dt + fc * dt when dt tends to zero.
in the limit when dt is zero any force time dt when dt ten to zero is zero.

by a constraint forces when dt ten to zero if the connotation force is a resting force then
fc * dt is zoro.

by if the contact is and impact them fc * dt = J is a step imupulse

this leaves the impulse equation as

m * dv = J
m v1 - m * v0 = J

the is the ideal situation

but the equation that is solved by the engine now is not that,
we are saying if dt is small so
fe * dt << fc * dt

this is resting force time dt is much small that the impulse si the right side of the equation is dominated by the impulse.
the assumption work well when the separation and when the magnetic of the right size is small
is clear but fail bad when the magnitude of fe * dt and fc * dt at comparable.

this is exactly what happens when Gyro torques are part of the equation, gyro torques are highly non linear when the inertia matrix is skewed, this lead to discrepancies in contact point velocities.
when these discrepancies are of some significant value now we get a contact with some contact point velocity that came not from a collision but from a resting torque and a solver that mix impulse and force is incapable to distinguish between these two contact point velocities.

the first I am doing now is to make a repro demo with a C shaped body like the one you have in your demo and see if I can reproduce the problem is a controlled setup.

To answered your question directly, a Newton cradle simulation is better done using continue collision mode which is disabled at the movement.
This mode of operation does what I explain but at sub time steps. because is only declare contacts point when two bodies come into collision.
This is the only mode that can resolve accurately stuff like Pool games, Newton Cradles, bowling and stuff like that.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unstable Connected Joints

Postby Julio Jerez » Mon Jul 01, 2019 3:14 pm

ok I added the repro test, I do no see the effect that you are getting.
No tested enough yet but I believe I have the gyro on, and I am using the dCustomSixdof joint

can you sync and check it out, maybe some of my dimensions are off from what you have.

the test is actually quite stable and I quickly check that in fact the mass matric is not spherical
Code: Select all
m_mass   {m_f=0x000001bb867819a0 {0.221354187, 0.221354187, 0.0260416679, 10.0000000}
m_invMass   {m_f=0x000001bb867819b0 {4.51764679, 4.51764679, 38.3999977, 0.100000001}


and I am positive that the gyro torque are applied
Code: Select all
dgJacobian dgDynamicBody::IntegrateForceAndToque(const dgVector& force, const dgVector& torque, const dgVector& timestep)
{
   dgJacobian velocStep;
   if (m_gyroTorqueOn) {
  // if if come here gyro torque is on

anyway I will do more test, but I am not sure why yours is so jumpy now.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unstable Connected Joints

Postby Dave Gravel » Mon Jul 01, 2019 4:49 pm

This is my old newtons cradle test.
It's not perfect but I find the result pretty good, It is a cool project to do.
I need to retest this simulation later with my new system and with computer maths,
I don't use continuous collision but if I remember good I have need to use high mass for the balls.
https://www.youtube.com/watch?v=Lb5kr0XuFn4
https://www.youtube.com/watch?v=NRk5_F0-jfc

Edited:
we should add a Cradle the sand box to show this subtleties. It is always good to now the engine limits.

Yes good idea, It is always fun to play with it.
Last edited by Dave Gravel on Mon Jul 01, 2019 5:27 pm, edited 1 time in total.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unstable Connected Joints

Postby Julio Jerez » Mon Jul 01, 2019 4:59 pm

ok I set the restitution to 0.6 which is the default, this will make the structure bounce.
I do see some different behavior with Gyro/noGyro
but nothing like you show in the video. in fact the behavior I am seeing is quite acceptable.

Dave that Cradle is the typical example of mixing forces and impulse.
you can see that balls do move a little when they should state dead stop.
It is ok but I believe the new Newton can do far better. If is does not them what shooed address that.

we should add a Cradle the sand box to show this subtleties. It is always good to now the engine limits.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unstable Connected Joints

Postby Julio Jerez » Tue Jul 02, 2019 7:50 am

I added a newton cradle demo, and the result are not good.

you can see that even with two ball the behavior is not correct.

what a ball hit the secund ball it should total displace the secund transferring all the momentum a stop dead, intead is hi the ball and bounce back.
the is the result of a missing impulse pass.

so yes the demostrate that the step zero the impulse pass in a not longer just sufficient is also necessary regardless gyro or any other reason.
I am glad you mentioned that cradle test, because this is not an acceptable behavior.

is not really a show stopper, since this is a very specific testy, but it has to be better.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unstable Connected Joints

Postby Julio Jerez » Tue Jul 02, 2019 2:25 pm

Ok I committed an even simpler repro test that exposes the root of the problem.
the demo show three balls, two together and one separated that moves and hight speed toward the other two.

The result is totally incorrect. you see how the two ball moves away and the hit ball bounces back but the correct result is that only the most right ball should move away the other two should stared put.
it just get worse and worse as more ball are placed in the demo.
is totally necessary to bring back the impulse solver.

The solver is somewhere in the engine, but I will just rewrite it over this long weekend.
In any case it was no quite correct either since it resolved impulses contacts by contact which is what you are seen Dave demo. so it kind of work but is not quite correct.

The correct approach is to resolve starti0n for the large impulse and sole the immediate island, meaning all immediately connect contacts and apply the solution, the like a wave find all immodiallt connect joint and solve those, and so on until not more impulse contact are left.
shame on me for removing that.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unstable Connected Joints

Postby MeltingPlastic » Thu Jul 04, 2019 5:19 pm

In the Techgame demo the only change I made between the 2 videos is changing useGryoForces_ in NewtonRigidBody.h in rbfx-newton.

its a compound shape so maybe that is a reason you cant replicate the behalvior?
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Unstable Connected Joints

Postby Julio Jerez » Thu Jul 04, 2019 6:25 pm

Yes I know, the one I put in the gyro demo is also a compound,
I made it such the one has gyro uption and the dies not, the behavior seem almost identical.

My difference should be the dimensions.

But anyway I am adding the impulse pre pass, this weekend.
They Newton Cradles is an embarrassment, and we can't have that. After I commit that let us try again without making any changes.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unstable Connected Joints

Postby MeltingPlastic » Sun Jul 28, 2019 12:37 pm

Hi Julio,

Sometimes I am seeing my contraptions (bodies connected by joints) fly apart and the bodies get positions of +-nan. This happens usually when I am dragging a contraption around using world forces applied to a particular body. everything seems stable until suddenly the whole contraption flies apart and I get nan positions from NewtonBodyGetPosition(...)

Sometimes the application freezes as well ( I am assuming its because of the nan position )

This video shows the behaviour, at the end of the video the application freezes.
https://youtu.be/yC1Jvtr5XZ0

Any Ideas what could be causing this (or ways to prevent it)? At first I thought I was getting too much spin on the rod body but I added drag to that and that seems under control now.

I've tried sensing when this happens and manually setting the newton body matrix back to it's previous value and clearing velocities, and even invalidating the cache. It doesn't seem to respond to that.

Also I am still on newton commit: 2a50b8236f131ee9fd6cb906b2f0a8b5c3f2ad04

Thanks,
Trevor
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Unstable Connected Joints

Postby MeltingPlastic » Sun Jul 28, 2019 4:12 pm

Looking into it further it looks like using manual forces like I am doing can cause excess strain on the contraption. in debug mode I get an assert in the solver.

switching the dragging behalvior to use the kinematic joint gets around the crash (but of course I see discontinuities in the joints when I drag around alot).

I guess Ideally this is a super complex inverse dynamics problem right? Solving only the needed force to get point A on the contraption to point B in world space given all current joint configurations.

I was seeing some good behavior using just distance and velocity to compute the force needed to pull the contraption - but I guess the forces can just get too high? I tried putting a clamp on the forces I am adding as well, but I still get the instability.
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Unstable Connected Joints

Postby Julio Jerez » Tue Jul 30, 2019 1:48 pm

I thought I was going to have time this pass weekend to work on this but I was wrong and have to work.

let us give another try at getting your build this weekend. I am curios what the is happening.
but I need to try using a real test case.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Previous

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest

cron