Angular momentum bug

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Angular momentum bug

Postby Julio Jerez » Sun Jan 24, 2021 12:08 pm

alright, that's the spirit. on the getting it fix, before I made that change I am running few test to make sure this bug is onl related to the contact joint. and it does seem it it.

I added a test that after 500 frames, the force callback stops applying acceleration, under these circumstances the body should not gain momentum at all, omega should change but its magnitude and the product on the angular velocity and the moment of inertia should be constant as well.
the change is this
Code: Select all
   void OnApplyExternalForce(dInt32 threadIndex, dFloat32 timestep)
   {
      static int xxxx;
      dVector omega(GetBody()->GetOmega());
      dTrace(("%d wMag = %f  w(%f %f %f)\n", xxxx, dSqrt(omega.DotProduct(omega).GetScalar()), omega.m_x, omega.m_y, omega.m_z));

      if (xxxx > 500)
      {
         return;
      }
      
      ndDemoEntityNotify::OnApplyExternalForce(threadIndex, timestep);
      xxxx++;
      if (xxxx > 500)
         xxxx *= 1;
   }


so now all that remain is to make that fix without affecting the rest, I see if I can get it today.
you can see that the magnitude of omega does increases over time but very very slowly, this is something that can not be solved because if just a fact that numerical integration is never exact. but that can be fixed by adding just a tiny bit of drag, and the simulation become indistinguishable from a reality which is my goal.
It is only when you get a simulation that can reproduce the known cases, that you can trust a predictions of the unknown cases.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Angular momentum bug

Postby Julio Jerez » Sun Jan 24, 2021 8:02 pm

al right now if you sync yo uwill see that the capsule rotation is stable for a long time.
it will eventually drift but that's the problem of numerical integration which we can only solved by reducing the time step. I can live with because if we just add a tiny amount of viscous drag, then it becomes unconditionally stable.

nwo you can check the angular momentum demo that have three phitops, they all behave like it is expected form a real life case.
basically the expected behavior is that when the center of mass rises, they lose part of angular momentum, because energy is conserves.
momentum is also conserved, you may ask how could momentum be conserved if the body loses some angular momentum, the answer is that in rigid body physics when you deal with bodies with infinite mass, the momentum that is transferred to the static body is lost. in the real world there is not such thing as 100% rigid and 100% static bodies. so conservation or momentum is one of these metrics that is very theoretical, conservation of energy is an easier quantity to demonstrate.
conservation of momentum is indeed far more rigorous but very, very eassy to break. take for example Collison between more than two bodies. the empirical law of restitution breaks down when trying to solve more than one sequential body simultaneously but the total energy still remain constant. any way I just wanted to mention that, in case you wonder why the capsule slows down when the COM goes up.
for me the fact that the engine can reproduce these behaviors, is a remarkable achievement that I have not seem in any physic engine and I feel very proud of.

I also decided to take a bold step with 4.xx.
we not longer support non gyro inertia matrices. it is up to the application to make the inertia matric of a body spherical if it wants non Euler inertia matrices. so not more options for that.
this make newton slower but so be it.

I will let the demo for some time and later I will clean it up.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Angular momentum bug

Postby FSA » Sun Jan 24, 2021 9:57 pm

Great, I'll have a look at it.
Now you can finish the particle fluid demo ;)
User avatar
FSA
 
Posts: 318
Joined: Wed Dec 21, 2011 9:47 am

Re: Angular momentum bug

Postby Julio Jerez » Mon Jan 25, 2021 12:21 pm

al right, I now revert the demo to its original state, and I added the angual drag.

if you test it now you will see that the capsules moves with more familiar natural look. that is the goal that I expect from the simulation, the drag should be an option that add to the realism of the simulation, not something that hides a flaw.
ok now back to the fluid.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Angular momentum bug

Postby Dave Gravel » Tue Jan 26, 2021 12:39 am

Hi Julio, The fix look to work good for me too.
https://www.youtube.com/watch?v=apbOLt0TMOU

I can now remove function in my class about Gyro ?
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: Angular momentum bug

Postby Julio Jerez » Tue Jan 26, 2021 1:04 am

nice, yes no more dreaded rotation explosions and gyro is alway on.
if you add some angular drag then it looks even more natural

body->SetAngularDamping(dVector(dFloat32(0.25f)));
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Angular momentum bug

Postby Dave Gravel » Tue Jan 26, 2021 1:11 am

Cool I can test with AngularDamping, Currently I have let's it by default.
I'm back for cofing now, I can test more the sdk and the vehicle in the next days.
I let's you know about the result.
Thanks.
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: Angular momentum bug

Postby Bill » Fri Mar 26, 2021 3:14 pm

Hello,

Is there any possibility that the fix for this bug could also be implemented in the newton-3.14 version of the engine?

I've experienced this same problem (objects rapidly gaining angular velocity and spinning out of control) in newton-3.14 on objects that I've manually set to have very low angular damping values. As a workaround, I've resorted to applying an unrealistically-high angular damping value to the object whenever I detect the problem occurring, but it would be really great if I didn't have to do this, as it makes things look a little bit unrealistic.

Is it feasible to port this bug fix into the latest 3.14 codebase in GitHub, or is that not possible for some reason?

Thanks!
Bill
 
Posts: 22
Joined: Mon Oct 27, 2014 9:40 am

Re: Angular momentum bug

Postby Julio Jerez » Fri Mar 26, 2021 3:42 pm

it possible to ported back but it does required some modification to the joints.
I though you were using 4.0, aren't you.

in 4.0 we have it pretty good. all test has proven to be stable and the angular momentum remain constant at all time with zero damp.
so good that Gyro torques in no longer optional feature and the default grad is set to zero.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Angular momentum bug

Postby Bill » Fri Mar 26, 2021 4:31 pm

Hi Julio,

Thanks for the quick reply. Actually, I haven't switched over to Newton 4.0 yet. I'd definitely like to switch over to 4.0 eventually, but I wasn't sure if it was ready and if it already has all the features I need.

For example, I think the reason I stopped when I first looked at 4.0 was that I couldn't find anything relating to compound collision shapes, which is a feature I use a lot in 3.14. Maybe I just missed it, though...are compound collision shapes already available in 4.0? Anyway, I guess I was just concerned that maybe I was too early and that perhaps I should wait a bit before switching.

Thanks,
Bill
Bill
 
Posts: 22
Joined: Mon Oct 27, 2014 9:40 am

Re: Angular momentum bug

Postby FSA » Wed Apr 28, 2021 10:12 pm

Ha, just found this in the latest Bullet Physics GitHub checkout in the Example Browser/Gyroscopic demo.
Video: https://youtu.be/dXiDTibkRa8

There seem to be more people having problems with this :D

By the way: Is the dry rolling friction joint already implemented in newton4?
User avatar
FSA
 
Posts: 318
Joined: Wed Dec 21, 2011 9:47 am

Re: Angular momentum bug

Postby Julio Jerez » Thu Apr 29, 2021 4:17 pm

it is funny how that worked isn't it, for 15 years the experts criticized Newton base on their position in some community, and it turned out that some how it is newton somehow seems to be doing those thing better. I guess not all engine are created equal this is how newton does it.
https://www.youtube.com/watch?v=UlErvZoU7Q0

no only that but new can reproduce the more challenging simulation like skew inertial axis, and they are all emerging effect form the simulation.

I will add that joint some time tonight, it is no that difficult.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Angular momentum bug

Postby FSA » Fri Apr 30, 2021 12:19 am

Bullet seems to support the things shown in the video too, it looks quite the same. What exactly does Newton better with the gyroscopic forces?
I would expect Bullet to use a more approximate approach to provide better speed. Since it's more like a "look good physics simulator", not an entirely accurate simulator.
User avatar
FSA
 
Posts: 318
Joined: Wed Dec 21, 2011 9:47 am

Re: Angular momentum bug

Postby Julio Jerez » Fri Apr 30, 2021 1:17 am

Maybe I saw it wrong, but the video seemed to show that the object gain angular momentum in each flip. Meaning angular momentum is not conserved.

But I am probably incorrect, if it good enought for you, that's what really count.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Angular momentum bug

Postby FSA » Fri Apr 30, 2021 1:36 am

Yes it gains angular momentum, it seems to be a bug. But the effects shown in your video like precession are supported by bullet too, and look quite correct.
User avatar
FSA
 
Posts: 318
Joined: Wed Dec 21, 2011 9:47 am

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 17 guests