CustomHingeActuator Instability

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

CustomHingeActuator Instability

Postby jamesm6162 » Thu Aug 20, 2015 5:01 am

Hi

There is quite a noticeable amount of shaking/instability in the CustomHingeActuator joint, when trying to hold a target angle against gravity.

This can be seen quite easily in your sandbox demos when running the articulated joints demo.
View the tracked vehicle from the side and you will see the crane lift boom going up and down intermittently.

I played around a little with the CustomHingeActuator::SubmitConstraintsFreeDof function and believe I improved the stability.

I suspect similar changes might be needed for the other joints like slider actuator etc. as they have the same implementation for solving the actuator, although I haven't come across an obvious case where the other joints show the same behaviour.

Below is the diff for the changes I needed to make, if you are interested. (I can't see an obvious place to submit the patch). But obviously you might know how better to fix it.

Regards

James

Code: Select all
 packages/dCustomJoints/CustomHingeActuator.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/packages/dCustomJoints/CustomHingeActuator.cpp b/packages/dCustomJoints/CustomHingeActuator.cpp
index 7a141e6..6c08750 100644
--- a/packages/dCustomJoints/CustomHingeActuator.cpp
+++ b/packages/dCustomJoints/CustomHingeActuator.cpp
@@ -135,9 +135,10 @@ void CustomHingeActuator::SubmitConstraintsFreeDof (dFloat timestep, const dMatr
       dFloat relAngle = jointangle - m_angle;
       NewtonUserJointAddAngularRow (m_joint, relAngle, &matrix0.m_front[0]);
 
-      dFloat step = m_angularRate * timestep;
-      if (dAbs (relAngle) > 2.0f * dAbs (step)) {
-         dFloat desiredSpeed = -dSign(relAngle) * m_angularRate;
+      {
+         //dFloat desiredSpeed = -dSign(relAngle) * m_angularRate;
+         dFloat errorFactor = 0.2f;
+         dFloat desiredSpeed = -dSign(relAngle) * dMin(m_angularRate,errorFactor*dAbs(relAngle)/timestep);         
          dFloat currentSpeed = GetJointOmega ();
          dFloat accel = (desiredSpeed - currentSpeed) / timestep;
          NewtonUserJointSetRowAcceleration (m_joint, accel);
jamesm6162
 
Posts: 49
Joined: Wed Aug 12, 2015 8:50 am

Re: CustomHingeActuator Instability

Postby Julio Jerez » Thu Aug 20, 2015 9:05 am

Yes I suspected that there was some bug in the joint actuator, I have on my list of thing to fix,
The area could be two place the joint, or the the solver, or both
I was work the solver first, this is not the current solver, rather the newton solver for hierarchical joints configuration.
The joint was stable but I recently made change so the parameter are consistent from joint to joint, I may have added the bug at that time.

can you just point the code, with out the + and - line that is for a merge program, but not for human read?
It will be easier if you just post the code and I make the change.
I will be awesome If that pat was improved or fixed it. :mrgreen:
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CustomHingeActuator Instability

Postby Julio Jerez » Thu Aug 20, 2015 2:37 pm

Oh I see you are damping the acceleration when is close to the target: dFloat errorFactor = 0.2f;

this is telling me that the bug is in eh solvers, ideally should be not damping at all,
in practice maybe a small amount due to rounding numerical error.

this is why I turned my attention of the solver, you should know that the tank is a test case to test the new solver, if I disable the new solver I believe joint work, of procures the solve is no accurate enough to keep the vehicle together.
hopefully what I fix the bug with the bug with the joint will go away, or may need some tweaking.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CustomHingeActuator Instability

Postby jamesm6162 » Fri Aug 21, 2015 3:16 am

Hi Julio

Yes the damping helps but the biggest problem was the that the acceleration wasn't actually applied unless the condition:
Code: Select all
dFloat step = m_angularRate * timestep;
if (dAbs (relAngle) > 2.0f * dAbs (step)) {

was true.

That meant that the hinge kept dropping until it was at least 2x angular correction distance down, before actually correcting itself.

Even with an errorfactor = 1.0f it is already much better, with only a bit of shaking.

But yes, ideally one shouldn't need damping at all.

I'm looking forward to the completion of the new solver. Is there an easy way to quickly switch to the old solver in the code just to check the difference?
jamesm6162
 
Posts: 49
Joined: Wed Aug 12, 2015 8:50 am

Re: CustomHingeActuator Instability

Postby Julio Jerez » Fri Aug 21, 2015 9:02 am

oh, I see so there is a bug then, yes you are correct that does explain the jerk motion.
That explain why when I move the boom out that the jerk is more pronounced. as the boom moves out the torque is bigger and the joint let go more violent, that was a goo catch. :mrgreen:

can you copy the whole function?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CustomHingeActuator Instability

Postby Julio Jerez » Fri Aug 21, 2015 2:53 pm

ok I see the bug now, here is the fixed function
Code: Select all
void CustomHingeActuator::SubmitConstraintsFreeDof (dFloat timestep, const dMatrix& matrix0, const dMatrix& matrix1)
{
   if (m_flag) {
//      dMatrix matrix0;
//      dMatrix matrix1;

//      CalculateGlobalMatrix (matrix0, matrix1);
      dFloat jointangle = GetActuatorAngle();
      dFloat relAngle = jointangle - m_angle;

// the is the real bug, whe the joint error angel is small the joint will reduce to zero,
// by is shoud cancle the negative of the error angle
      NewtonUserJointAddAngularRow (m_joint, -relAngle, &matrix0.m_front[0]);

      dFloat step = m_angularRate * timestep;
      if (dAbs (relAngle) > 2.0f * dAbs (step)) {
         dFloat desiredSpeed = -dSign(relAngle) * m_angularRate;
         dFloat currentSpeed = GetJointOmega ();
         dFloat accel = (desiredSpeed - currentSpeed) / timestep;
         NewtonUserJointSetRowAcceleration (m_joint, accel);
      }
        NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxForce);
        NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxForce);
      NewtonUserJointSetRowStiffness (m_joint, 1.0f);
   } else {
      CustomHinge::SubmitConstraintsFreeDof (timestep, matrix0, matrix1);
   }
}


I will fix the all the bug was that I change the code so that the parameter are consistent for all joints, but I did changed the sign of the, your observation pointed me to the right director.
I will commit the fix for all joints tonight. Very impressive for such a new user. awesome.
Thank,
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CustomHingeActuator Instability

Postby jamesm6162 » Mon Aug 24, 2015 2:34 am

Hi

You're welcome, and thanks for the fix.

Regards

James
jamesm6162
 
Posts: 49
Joined: Wed Aug 12, 2015 8:50 am


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 9 guests