SetTorque questions

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

SetTorque questions

Postby misho » Fri Oct 01, 2010 6:07 pm

Can someone (Julio?) please shed some light at this behaviour:

I have 2 objects set up "suspended" in space (no gravity). 2nd object has Angular and Linear damping values set to zero. (I have also tried very small values, as advised in WIKI).

I have it set up so that at each key "F" press (or, while the key is down, each cycle), both objects are given an x torque some small value.

Object 1 starts to rotate while the "F" is down, but slows down to a stop when the key is released - this is as expected, since the damping value is non-zero.

Object 2 also starts to rotate, and given sufficient torque, it keeps rotating. That is as expected, also.

BUT, if I apply just a small amount of torque, the object 2 starts to rotate slightly, but then it stops. That is unexpected behaviour. Why would it stop on small torques, and not on large? When it rotates, I checked the Omega, and it doesn't change (i.e. it doesn't slow down gradually)

I understand that damping can't be completely eliminated, but why does it seem to work for large torque (no slowdown), but not for small ones?

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

Re: SetTorque questions

Postby ledahut » Mon Oct 04, 2010 3:19 am

Maybe autoSleep is set to true.
Try again with autosleep to off.
See NewtonBodySetAutoSleep
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: SetTorque questions

Postby Julio Jerez » Mon Oct 04, 2010 8:26 am

yiss that was a problem, when an omega was very small auto sleep keek in a stop teh body.

but it was fixed in some vertion of teh SDK, are yuo using 2.24?

Try setting auto sleep off like ledahut
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: SetTorque questions

Postby misho » Tue Oct 05, 2010 12:51 am

Thanks guys, that helped! However, it still happens for very small torques and resulting omegas... Anything less than 0.03 rad/s will stop. Omegas larger than 0.03 will "keep going".

Actually, applying very small torques is not moving the object at all. Perhaps it is not enough to overcome angular inertia?

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

Re: SetTorque questions

Postby Julio Jerez » Tue Oct 05, 2010 1:23 am

Are you the same person that was making a demo with a submaring whe the body was not moving when a small force was applied?
I remember I fixed that.
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: SetTorque questions

Postby misho » Tue Oct 05, 2010 10:55 am

No, that's not me :) I'm the guy waiting for the VS2010 SDK Example compatibility :D

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

Re: SetTorque questions

Postby Julio Jerez » Tue Oct 05, 2010 1:33 pm

if autosleep is off I believe it should spin

How do I test that?
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: SetTorque questions

Postby misho » Tue Oct 05, 2010 3:56 pm

Hi Julio,

Testing that is easy - set up your body like this (I'm using entity class from tutorials, just to easily visualize the bodies)

Code: Select all
   eStage2 = sceneManager->CreateEntity();
   eStage2->LoadMesh ("dumb.dat");
   eStage2->m_curPosition.m_x = 0.0f;
   eStage2->m_curPosition.m_y = 0.0f;
   eStage2->m_curPosition.m_z = -2.0f;
   eStage2->m_prevPosition = eStage2->m_curPosition;

   // add a body with a Convex hull shape
   shape = CreateNewtonBox (world, eStage2, 2);
   Stage2Body = CreateRigidBody (world, eStage2, shape, 20.0f);

   NewtonBodySetLinearDamping( Stage2Body, 0.00000000000f);

   dFloat angularDamp[3];
   angularDamp[0] = -0.0000000000000000000000000f;
   angularDamp[1] = -0.0000000000000000000000000f;
   angularDamp[2] = -0.0000000000000000000000000f;
   NewtonBodySetAngularDamping(Stage2Body, angularDamp);

   NewtonBodySetAutoSleep(Stage2Body,0);
   NewtonReleaseCollision (world, shape);


Then, in ApplyForceAndTorqueCallback,

Code: Select all
      dFloat Torques[3];

   Torques[0] = 0.0f;
   Torques[1] = 0.0f;
   Torques[2] = 0.0f;

   if(FKey)
      Torques[0] = 0.5f;
   if(GKey)
      Torques[0] = -0.5f;

   NewtonBodySetTorque(body, Torques);
   NewtonBodyGetOmega(body, mOmega);


FKey and GKey are booleans that are true when F and G keys are down. You can use them to apply torque to the object in + and - direction on x axis, effectively speeding up or slowing down rotation.
With this setup, you'll see that small omegas of less than 0.03 rps will "stop". Also, you'll notice that, if you just tap the F/G key and add very small torque, there will be a small Omega value displayed momentarily, and it will instantly go back to 0. I have the omega values displayed on screen:

Code: Select all
   Print (dVector (1.0f, 1.0f, 1.0f, 1.0f), 10, 124, "Omega: x = %5.8f", mOmega[0]);
   Print (dVector (1.0f, 1.0f, 1.0f, 1.0f), 10, 144, "Omega: y = %5.8f", mOmega[1]);
   Print (dVector (1.0f, 1.0f, 1.0f, 1.0f), 10, 164, "Omega: z = %5.8f", mOmega[2]);


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

Re: SetTorque questions

Postby Julio Jerez » Tue Oct 05, 2010 4:35 pm

I will try tonight

can you post this in the Bug Track forum?
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: SetTorque questions

Postby misho » Wed Oct 06, 2010 11:00 am

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


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest