Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Filo - Calculating weight on cable point
#8
(20-03-2020, 12:05 PM)josemendez Wrote: Negate the impulse magnitude. My original code simply divided by a negative scalar value, but once you deal with vectors signs become important. Keep in mind that the jacobian points from the first link to the second link in the cable. So while the impulse magnitude applied to the first link has the same sign as the jacobian (towards the second link), the impulse magnitude applied to the second link goes in the opposite direction (towards the first link).

Also you're projecting the gravity vector, then calculating its length. This is both unnecessary and can be slightly off: when you perform a dot product with a unit length vector (such as the jacobian), the result is the projection length, and it has the correct sign depending on the relative directions both vectors are pointing.

The dot product is all you really need, because the jacobian has unit length:

Code:
//Last joint where the weight is attached
CableJoint joint = cable.Joints[0];

// Calculate force by diving Impulse with Time
float force = -joint.ImpulseMagnitude / Time.fixedDeltaTime;

//Calculate the weight by dividing the force by the "amount" of gravity along the constraint gradient:
float weight = force / Vector3.Dot(Physics.gravity, joint.Jacobian);


Can't reproduce, the mass reported is pretty stable and accurate for me. Edit: try calculating the mass in LateUpdate() instead of FixedUpdate(). FixedUpdate is called a variable amount of times each frame, might not even be called at all. Joints will always report the last impulse data they applied, so reading it in LateUpdate() is safe.

This method calculates the mass "seen" by the cable. If the cable has to pull the load to move it against gravity, the mass reported by this method will be higher than the actual mass of the load. Also, if the cable has some slack, it will report 0 mass. Also, mass can be slightly off due to non-perfect convergence. If the timestep is large or the amount of iterations not high enough, the reported mass will be higher because the cables are slightly overstretched.

I have been trying fiddling with it and placed the functionality in LateUpdate() but the weight still seem to fluctuate quiet a lot when the cranes are moving. We are talking about +/- 50% fluctuations from the rest position. I have found another solution that works reasonable, where I simply Lerp the weight over time which makes it less apparent.

However, if possible I would like to have it resolved anyway.

I have drawn this diagram:
[Image: QGWXwDv.png]

Each crane can move independently. The upper attachment inside the crane is used to hoist or lower the hook attached on the rigidbody. Even when moving all four cranes simultaneously and with the same speed the weight fluctuates.
Reply


Messages In This Thread
RE: Filo - Calculating weight on cable point - by MarcPilgaard - 23-03-2020, 12:35 PM