Custom Damping Forces

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Custom Damping Forces

Postby cgpauli » Mon Jul 12, 2010 4:27 am

Hi,

i am trying to use a custom force callback to generate angular and linear damping forces. This is what the callback looks like: (i am using OgreNewt)

Code: Select all
Ogre::Vector3 angDamping;
angDamping = -10*body->getOmega();
body->addTorque(angDamping);

Ogre::Vector3 damping;
damping = (-3)*body->getVelocity();
body->addForce( damping );


Thereby i am experiencing the following issues: First the body behaves like expected, slowing down continously, but when it reaches an omega of 0.0607868 respectively a damping torque of -0.607868 (only having a rotation about one axis at the start), it suddenly stops to omega=zero, which looks very bad! Even more annoying, if i disable auto-sleep for the body, it keeps revolving at an omega of 0.0607868 till the end of time. If i set the standart newton parameters for damping instead, i do not experience these issues! Is there any way to fix this respectively am i doing something wrong? Thanks for your help :D !

btw: i use a physics update rate of 100Hz
cgpauli
 
Posts: 10
Joined: Mon Jul 12, 2010 4:09 am

Re: Custom Damping Forces

Postby Julio Jerez » Mon Jul 12, 2010 7:42 am

what it it stops or keep moving? I am not clear what you mean
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom Damping Forces

Postby cgpauli » Tue Jul 13, 2010 5:55 am

Julio Jerez wrote:what it it stops or keep moving? I am not clear what you mean


well, there are 2 different cases:

- if i enable auto-sleep: The body suddenly stops to rotate when omega gets smaller than about 0.0607868 rad/s.

- if i disable auto-sleep: The body keeps revolving at a constant omega of about 0.0607868 rad/s as soon as the body has slowed down to that value of omega .

Thank you for your help!
cgpauli
 
Posts: 10
Joined: Mon Jul 12, 2010 4:09 am

Re: Custom Damping Forces

Postby Julio Jerez » Tue Jul 13, 2010 7:53 am

if you disable autosleep the body will rotate controll by the net torque.
set all drga to zero, and you are in total controll of the body.
There is nothing in the engine othe than the coefficent of linai and angular damping that act over the body.

I will have to see a demo of that because I do no thing that happens
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom Damping Forces

Postby JernejL » Wed Jul 14, 2010 4:00 am

Change angular dampening to zero, see how it behaves then.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Custom Damping Forces

Postby cgpauli » Fri Jul 16, 2010 5:08 am

Hi,

thanks for the answers! I have the standart damping forces/torques set to zero, so that's should not be the problem. Actually, if i use the standart damping forces/torques instead of my custom ones it works all well...
@Julio: What do you mean with "demo", the code of the complete program? Sorry if this is a stupid question :-) !
cgpauli
 
Posts: 10
Joined: Mon Jul 12, 2010 4:09 am

Re: Custom Damping Forces

Postby Julio Jerez » Fri Jul 16, 2010 2:34 pm

I mean a test program that exposes the problem and that I can attach to the newton DLL from VS, so that I can check in debug mode.
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom Damping Forces

Postby cgpauli » Tue Jul 20, 2010 3:50 pm

Ok, here is a link to the program that exposes the problem: http://www.megaupload.com/?d=PX6AKKT7

It would be very kind of you if you could have a look at the problem.
Thanks in advance!

p.s: the program shows the model of a submarine, you can apply local forces/torques via the arrow keys, otherwise only the custom damping forces mentioned above are applied to slow the motion down. You will see that the model does not slow down to zero. ( auto sleep is disabled )
Last edited by cgpauli on Sat Jul 24, 2010 7:18 am, edited 1 time in total.
cgpauli
 
Posts: 10
Joined: Mon Jul 12, 2010 4:09 am

Re: Custom Damping Forces

Postby cgpauli » Sat Jul 24, 2010 5:39 am

@Julio: If you don't have the time to look at my problem ( which would be very understandable ) or if there is a something wrong with the test app, could you please tell me, because in the first case i would have to switch to another physics engine, since i seem to be unable to find an error in my own code and the current behaviour is not acceptable for my purposes. Thank You!

Of course, if any one else has thoughts about this, i would appreciate it very much.
cgpauli
 
Posts: 10
Joined: Mon Jul 12, 2010 4:09 am

Re: Custom Damping Forces

Postby Julio Jerez » Sat Jul 24, 2010 10:32 am

Sometime I forget to test problems people post because I cannot run then during the week.
And then when the weekend comes I forget where the post was, people usually send me a PM when they post a test or test.

Ok I run this and you are right there is a bug in the integration when the damp is set to zero
and the force was lower that the minimum threshold. The solver was stopping applying the force as if the internal damp was still on,
but the damp was zero which lead tp the body moving a constant speed.
I fixed it, the force do not have to check if the damp is off, it needs to be applied all the time.

That was a big bug if people set damping to zero, I do not kwno why it took so long to come up.
Thanks for the report. Get 2.24 here
http://www.newtondynamics.com/downloads/NewtonWin-2.24.rar

I am not ready to post it to the download yet since I am changing the editor GUI, but the fix is there, just get the dll.
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom Damping Forces

Postby cgpauli » Sat Jul 24, 2010 6:49 pm

Wow, great service, thanks a lot my friend :-)!
cgpauli
 
Posts: 10
Joined: Mon Jul 12, 2010 4:09 am

Re: Custom Damping Forces

Postby cgpauli » Fri Oct 08, 2010 7:35 am

Hi,

there still seems to be some kind of force or velocity threshold although autosleep is disabled. If velocity or angular velocity of the body becomes smaller than about 0.02, then the body freezes appruptly. To get it moving again, you have to apply a force/moment grater than some minimum threshold. Would be great if you could fix this!

Test App (Newton 2.24):

http://www.megaupload.com/?d=90IA59HG
(you can apply forces/torques via arrow keys)
cgpauli
 
Posts: 10
Joined: Mon Jul 12, 2010 4:09 am

Re: Custom Damping Forces

Postby Julio Jerez » Fri Oct 08, 2010 8:46 am

did not I fixed this bug in 2.24?
This is the same submarine demo you sent before.

this seems to be the same bug as this othe thread
http://newtondynamics.com/forum/viewtopic.php?f=9&t=6173&p=44456#p44456

I will check again but I believe I fixed this, how is this different from what I fixed
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom Damping Forces

Postby misho » Fri Oct 08, 2010 2:34 pm

cgpauli wrote:Hi,

there still seems to be some kind of force or velocity threshold although autosleep is disabled. If velocity or angular velocity of the body becomes smaller than about 0.02, then the body freezes appruptly. To get it moving again, you have to apply a force/moment grater than some minimum threshold. Would be great if you could fix this!

Test App (Newton 2.24):

http://www.megaupload.com/?d=90IA59HG
(you can apply forces/torques via arrow keys)


I can confirm that, the same thing is happening to me at around 0.03 RPS. This bug is already logged at http://newtondynamics.com/forum/viewtopic.php?f=9&t=6173&p=44456#p44456, as Julio says.

Misho
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Custom Damping Forces

Postby Julio Jerez » Sat Oct 09, 2010 5:35 pm

Ok I was looking at this and I see what you say
I run teh demo slowely bachwar and teh velocity start to sloa daown gradually and as soon as it reach
veloc {m_x=-0.031622492 m_y=0.00000000 m_z=0.00000000 ...}

It is damp very rapidly to zero.
that is because ther have a cap velocity of abs (0.03) which I consider very smal whent doing 32 bit float and

Here we need to deal with the reality fo Float arithmetic on a computer,
I cannot let the numbers run wild and become very low or very big because then I run into floating point degeneracy which slow down the float unit.
I reduce the attenuation by a factor of 1000, but I can not make it zero, that will be very disatrous for the engine.
Not for you by for many users that let body update perpetually and tehn as they slow down teh floting point using also slow down nomatlizing denormal numbers intenally.
those are the problem we have to deal with 32 and 64 bit floats, and we most accept that fact.

even if the calculation was done in double presition you cannot really let a values be infinitelly small or infinitleey large you must use error bound arithmetic or
Adaptive precition aritmetic using predicates which mean that a value will be considered zero based of the ration betwenn teh magnitud on the larger value
involve in the calculation to teh machine presition (this is quite conplex for a realtime physic library bu it is use in soem intenal algorithms in newton)

Anyway with the tolerance set to 0.9999 intead 0 0.99 the velocity reach zero when it becomes smaller than 0.03 but it take a lot longer to do so.
in theory the velocity should reach zero in infinite amount of time, but like I said before this is quite desatrus for the engine.
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron