Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to damp the swing in the Freight Lifter scenario?
#1
I am interested in doing something along the lines of your existing Freight Lift demo, where there's a number of ropes holding a mass like a pendulum.

In my situation though, the cables are much longer.  I have the bounciness under control but now would like to reduce or damp the amount of pendulum swing when the top of the freight crane moves.  Real physics is cool, and all, but this is a game and I don't want to make users cry with trying to stabilize the load quite that much.

What is the best way to do this?  I am thinking of measuring the deflection and applying a counter force to the load/platform objects pinned at the bottom of the ropes.  Is there a specific Obi API or should I just apply it with regular Physics.AddForce()?  Or is there an alternative?


(As an aside, with the Freight Lift demo, I noticed that if I change the rope density below about 0.25 to help reduce the distance constraint workload, the simulation refuses to lengthen/shorten the ropes.  I didn't see anything in the docs about a valid range here.)
Reply
#2
(22-01-2023, 07:11 PM)hariedo Wrote: I am interested in doing something along the lines of your existing Freight Lift demo, where there's a number of ropes holding a mass like a pendulum.

In my situation though, the cables are much longer.  I have the bounciness under control but now would like to reduce or damp the amount of pendulum swing when the top of the freight crane moves.  Real physics is cool, and all, but this is a game and I don't want to make users cry with trying to stabilize the load quite that much.

What is the best way to do this?  I am thinking of measuring the deflection and applying a counter force to the load/platform objects pinned at the bottom of the ropes.  Is there a specific Obi API or should I just apply it with regular Physics.AddForce()?  Or is there an alternative?


Hi there!

You specifically mention the pendulum/load instead of the rope, rigidbodies in Unity have a specific setting for this: drag. This erodes linear velocity away to make the object come to a rest position faster. There's also an angular/rotational version of it, that will cause objects to stop rotating faster. Check the manual for details: https://docs.unity3d.com/Manual/class-Rigidbody.html

If you want to damp rope movement too (or instead), Obi has a similar setting called damping, that you can find in the ObiSolver component.



(22-01-2023, 07:11 PM)hariedo Wrote: (As an aside, with the Freight Lift demo, I noticed that if I change the rope density below about 0.25 to help reduce the distance constraint workload, the simulation refuses to lengthen/shorten the ropes.  I didn't see anything in the docs about a valid range here.)

Less resolution -> less constraints -> faster convergence -> everything becomes more rigid. This is a basic consequence of how all iterative physics engines works, and position-based ones in particular. The manual contains an in-depth explanation of how iterations/substeps/constraints work: http://obi.virtualmethodstudio.com/manua...gence.html

Also, less resolution results in less particles and hence less bending points for the rope, so from a purely geometrical perspective the rope will have a much harder time crumpling / compressing. At minimum resolution, a rope is made of only 2 particles and a single distance constraint, so the rope is  completely unable to bend since it's just a straight line passing trough 2 points in space.

So there isn't a "valid" resolution range, it all depends on what you want to do. Think of the rope as a chain: the more links it has and the smaller they are, the more detailed its movement. As links become larger and there's less of them, the chain's freedom of movement becomes limited. At the extreme setting of only 1 link, it won't be able to bend at all and unless the links themselves are elastic, it won't be able to compress or stretch either.

If you want to explicitly make distance constraints compressible, they have a "Max compression" setting that can be used to specify the percentage of compression allowed: http://obi.virtualmethodstudio.com/manua...aints.html

And if you want to make them elastic, increase stretch compliance.

kind regards
Reply
#3
(23-01-2023, 10:31 AM)josemendez Wrote: You specifically mention the pendulum/load instead of the rope, rigidbodies in Unity have a specific setting for this: drag. This erodes linear velocity away to make the object come to a rest position faster. There's also an angular/rotational version of it, that will cause objects to stop rotating faster. Check the manual for details: https://docs.unity3d.com/Manual/class-Rigidbody.html

If you want to damp rope movement too (or instead), Obi has a similar setting called damping, that you can find in the ObiSolver component.

Yep, I found the Obi Solver's damping for the ropes themselves.  I do like the effect of a small amount of it.

As for the Rigidbody drag, that would make sway worse on the start of crane motion.  I am kinda looking for the best way to fake/cheese the simulation to reduce sway deflection on start AND end of a crane motion.  Artificially adding a little movement to the platform when the top of the crane moves, so they stay more in sync vertically, rather than having the platform "catch up" and then overshoot.  I don't want to completely fake it by kinematically moving the platform in unison with the crane and letting the pinned ropes just wiggle, but I might have to do that.
Reply
#4
So, I made one cheesy workaround.  It's not ideal from a realistic physics perspective, but it's workable from a casual game effect.

In the crane, I have 4 long visible steel ropes from the top winch to the load platform.  I also have an invisible secondary lower object that follows the top winch but positioned much closer to the load platform, and 4 short invisible rubber ropes to basically strangle the sway from the load platform.  With a little more tuning, this might work pretty well for my purposes.
Reply
#5
(23-01-2023, 05:38 PM)hariedo Wrote: As for the Rigidbody drag, that would make sway worse on the start of crane motion.  I am kinda looking for the best way to fake/cheese the simulation to reduce sway deflection on start AND end of a crane motion.  Artificially adding a little movement to the platform when the top of the crane moves, so they stay more in sync vertically, rather than having the platform "catch up" and then overshoot.  I don't want to completely fake it by kinematically moving the platform in unison with the crane and letting the pinned ropes just wiggle, but I might have to do that.

Yes, drag basically tries to get a rigidbody to stop moving so when you start moving the crane, the rigidbody would not start moving right away and this would increase the initial swing.

Probably the simplest, most controllable way to achieve what you want is to calculate the crane's acceleration and then apply a percentage of that acceleration to the load.

Pseudocode for calculating acceleration:

Code:
Vector3 oldPos;
Vector3 oldVel;
Vector3 accel;
float percentage = 0.5f;

Update()
{
Vector3 vel = (crane.transform.position - oldPos) / Time.deltaTime;
accel = (vel - oldVel) / Time.deltaTime;
oldPos = crane.transform.position;
oldVel = vel;
}

FixedUpdate()
{
load.velocity += accel * Time.fixedDeltaTime * percentage;
}
Reply