Velocity damping

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
lidgren
Posts: 5
Joined: Mon May 27, 2019 6:28 pm

Velocity damping

Post by lidgren » Sat Jun 15, 2019 2:20 pm

Hi! I'm trying to add a (very heavy) velocity damping to a constrained object; basically it's a door on a hinge and I don't want it to be so well oiled.
I guess it could be achieved by adding and every frame calculate values for a OneBodyLinearMotor; but that seems like a roundabout way to do it. I started creating a VelocityDampingMotor constraint but a lot of the concepts (presteps, projections, warmup) are kind of lost on me.
Are any of these ways a good idea or am I missing a much simpler solution perhaps?
--micahel

Norbo
Site Admin
Posts: 4753
Joined: Tue Jul 04, 2006 4:45 am

Re: Velocity damping

Post by Norbo » Sat Jun 15, 2019 5:50 pm

OneBodyAngularMotor with a target velocity of zero sounds like it would do the trick. Notably, the "softness" parameter in MotorSettings is equivalent to the inverse damping constant. For cases where the door is attached to another body and you want the damping forces to correctly propagate, the AngularMotor would serve the same purpose.

If most objects need some form of customizable damping without strong robustness requirements demanding solved constraints, using something like the DemoPoseIntegratorCallbacks that looks up per-body damping values could work too.

lidgren
Posts: 5
Joined: Mon May 27, 2019 6:28 pm

Re: Velocity damping

Post by lidgren » Mon Jun 17, 2019 12:26 pm

Works like a charm, thanks! General question - is it fair to say that a motor is something that a motor is something that applies force over time until a velocity is reached; and a servo is something that applies force until an absolute value (position/orientation) is reached?

Norbo
Site Admin
Posts: 4753
Joined: Tue Jul 04, 2006 4:45 am

Re: Velocity damping

Post by Norbo » Mon Jun 17, 2019 9:55 pm

Yup, that's exactly right.

Notably, the only distinction by convention between a 'normal' constraint like BallSocket (which has a position goal) and a 'servo' is that servo types tend to also have a ServoSettings value that offers more control. Constraints like BallSocket omit that parameter as an optimization given their most frequent use cases.

Darkon76
Posts: 23
Joined: Mon Mar 27, 2017 12:33 pm

Re: Velocity damping

Post by Darkon76 » Thu Jun 20, 2019 5:00 pm

Hi,

So if I have few objects that use velocity damping. Is it better to use an OneBodyLinearMotor for the damping that changing the PoseintegratorCallbacks-IntegrateVelocity?

Norbo
Site Admin
Posts: 4753
Joined: Tue Jul 04, 2006 4:45 am

Re: Velocity damping

Post by Norbo » Thu Jun 20, 2019 8:44 pm

Constraints are useful when you want a high level of robustness during interactions with other constraints and collisions. A heavy door with a very rusty hinge that requires a large amount of force to overcome is a good use case, since the hinge's resistance is large enough to meaningfully interact with collisions.

For very light damping, like basic aerodynamic drag simulation that only removes a fraction of momentum per second, the robustness offered by a constraint usually isn't necessary. For performance reasons, you might choose to then use a direct velocity modification (like a pose integrator damping implementation).

If very few objects have damping applied, then it doesn't make as much sense to use the pose integrator since it touches every single active body. It would be faster to directly modify the velocity of the handful of objects instead.

Post Reply