KinematicController Fix

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

KinematicController Fix

Postby JoeJ » Wed Jul 11, 2012 10:36 am

Julio, recently there was discussion about KinematicController.
I can't find the topic again, but someone have had a problem, I pointed out why, you suggested a fix, i tried it out and it works good.
The problem was: The constraint uses one bodies space to fix linear displacement (unnatural movement).
The fix is: Use Gramm Schmidt to get a space where one axis is aligned with the line of displacement (natural movement now).
It seems you've forgotten to update your code.

Replace from line 165 in CustomKinematicController:

Code: Select all
   // Restrict the movement on the pivot point along all tree orthonormal direction
   NewtonUserJointAddLinearRow (m_joint, &p0[0], &m_targetPosit[0], &matrix0.m_front[0]);
   NewtonUserJointSetRowAcceleration (m_joint, relAccel % matrix0.m_front);
   NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxLinearFriction);
   NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxLinearFriction);

   NewtonUserJointAddLinearRow (m_joint, &p0[0], &m_targetPosit[0], &matrix0.m_up[0]);
   NewtonUserJointSetRowAcceleration (m_joint, relAccel % matrix0.m_up);
   NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxLinearFriction);
   NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxLinearFriction);

   NewtonUserJointAddLinearRow (m_joint, &p0[0], &m_targetPosit[0], &matrix0.m_right[0]);
   NewtonUserJointSetRowAcceleration (m_joint, relAccel % matrix0.m_right);
   NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxLinearFriction);
   NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxLinearFriction);


with that:

Code: Select all

      dMatrix matrixCS;
      if ((relPosit % relPosit) < 0.000001) matrixCS = GetIdentityMatrix();
      else matrixCS = dgGrammSchmidt(relPosit);

      // Restrict the movement on the pivot point along all tree orthonormal direction
      NewtonUserJointAddLinearRow (m_joint, &p0[0], &m_targetPosit[0], &matrixCS.m_front[0]);
      NewtonUserJointSetRowAcceleration (m_joint, relAccel % matrixCS.m_front);
      NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxLinearFriction);
      NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxLinearFriction);

      NewtonUserJointAddLinearRow (m_joint, &p0[0], &m_targetPosit[0], &matrixCS.m_up[0]);
      NewtonUserJointSetRowAcceleration (m_joint, relAccel % matrixCS.m_up);
      NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxLinearFriction);
      NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxLinearFriction);

      NewtonUserJointAddLinearRow (m_joint, &p0[0], &m_targetPosit[0], &matrixCS.m_right[0]);
      NewtonUserJointSetRowAcceleration (m_joint, relAccel % matrixCS.m_right);
      NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxLinearFriction);
      NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxLinearFriction);


But pleas take a look if i've done right ;)
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: KinematicController Fix

Postby Julio Jerez » Wed Jul 11, 2012 11:35 am

I am going to work on the after I get the boolean out fo the way. right now I do not want to lose focus.
It si quiet tricky to resolve riudn of errors, and it is eassy to forget teh conditions that expose soem bugs.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 12 guests

cron