# [PhysX] Damping

This topic is 2748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

First of all hello everybody!

I'm trying to achieve an ideal perpetual motion in PhysX simulation. Something wich acts like a pendulum in vacuum with frictionless joints. I have two rigid bodies (boxes of size 1x1x1). One of them is kinematic actor placed in (0,0,0) and second is dynamic with starting point in (3,0,0). What I do is simply make a hinge in z axis between them and then start the simulation. The result is that movable body starts to swing beneath kinematic body and reaches values (-3,3) in x axis and (-3,0) in y axis, but after some time it gradually stops. To do this first I used revolute joint, but then switched to 6DOF joint since I'm planning to modify it in future.

I believe I've switched off all damping but I still get something which looks like damped motion and I'm not sure why. Is there a global flag wich allows me to switch off all damping and/or friction on joints? I make simulation with fixed timestep and with console interface only. Can anyone point me what should I do to achieve this?

Btw is it possible to post attachments on this board?

Thanks

##### Share on other sites
Quote:
 Original post by keymBtw is it possible to post attachments on this board?
If you mean images, then yes, you can use the HTML 'img' tag.

##### Share on other sites
Quote:
 Original post by keymI believe I've switched off all damping but I still get something which looks like damped motion and I'm not sure why.

Some other things that might be affecting the motion are:

NxReal NxBodyDesc::angularDamping - this defaults to 0.05 so will be interfering

NxReal NxBodyDesc::linearDamping - defaults to 0 so unlikely to be a problem

NxReal NxBodyDesc::maxAngularVelocity - this defaults to -1 which means use NX_MAX_ANGULAR_VELOCITY which defaults to 7 rad/sec

##### Share on other sites
Thank you for replies.

I think I set both angular damping and linear damping to 0. Here is how I construct moveable body:

NxBodyDesc bodyDesc2;bodyDesc2.angularDamping=0;bodyDesc2.linearDamping=0;bodyDesc2.sleepAngularVelocity=0;bodyDesc2.sleepLinearVelocity=0;bodyDesc2.maxAngularVelocity=2000;bodyDesc2.sleepLinearVelocity=2000;bodyDesc2.sleepEnergyThreshold=0;NxBoxShapeDesc boxDesc2;boxDesc2.dimensions.set(1.0,1.0,1.0);NxActorDesc actorDesc2;actorDesc2.shapes.pushBack(&boxDesc2);actorDesc2.body	= &bodyDesc2;actorDesc2.density = 1.0f;actorDesc2.globalPose.t = NxVec3(3,0,0);assert(actorDesc2.isValid());NxActor* box2=gScene->createActor(actorDesc2);	box2->setAngularDamping(0);box2->setLinearDamping(0);box2->setSleepAngularVelocity(0);box2->setSleepLinearVelocity(0);box2->setSleepEnergyThreshold(0);

And still there is significant damping. Maybe PhysX simulate friction on joints like in real world? Below is a graph comparing motion in x axis for revolute and 6dof joint using the same settings for bodies.

[Edited by - keym on December 9, 2010 1:01:32 PM]

##### Share on other sites
You have to remember that the solver is iterative and inexact, with the inevitable errors corrected using non-physical stabilisation forces. I don't think that you can expect perfect behaviour.

Things might improve if you decrease the timestep and increase the number of solver iterations (set on each body). However, decreasing the timestep isn't necessarily going to help, since I've found that solver error appears to be resolved over a fixed number of timesteps - so when the timestep is small that can result in huge velocities!

Depends what you're trying to do, but if you want an accurate simulation, that's not what PhysX was intended for.

##### Share on other sites
Quote:
 Original post by MrRowlYou have to remember that the solver is iterative and inexact, with the inevitable errors corrected using non-physical stabilisation forces. I don't think that you can expect perfect behaviour.Things might improve if you decrease the timestep and increase the number of solver iterations (set on each body). However, decreasing the timestep isn't necessarily going to help, since I've found that solver error appears to be resolved over a fixed number of timesteps - so when the timestep is small that can result in huge velocities!Depends what you're trying to do, but if you want an accurate simulation, that's not what PhysX was intended for.

Exactly my words. The impulse based constraint solvers used by most "physics" engines are very poor at conserving energy. If you want to build a (very near perfect) perpetuum mobile, you'll need to work with forces instead and implement a symplectic (ie. energy conserving) integration algorithm. As an example, you could let David Whysong's 4th, 6th, or 8th order integrators do the job for you. Even the good old 2nd order velocity verlet algorithm does a better job.

Cheers,
Mike

• 37
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631362
• Total Posts
2999563
×