Joint to move body to specific position and orientation

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Joint to move body to specific position and orientation

Postby pHySiQuE » Thu Jun 01, 2017 6:47 pm

Is there a joint we can use to move a body to an exact position and rotation? I want to use this to control the terminal affector in an IK system, as well as when the player picks up objects with the mouse and moves them around.

The problem with using AddForce() is it causes very energetic collisions.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Joint to move body to specific position and orientation

Postby Shaderman » Thu Jun 01, 2017 11:34 pm

I believe you want to use actuators. Did you see the three dCustom*Actuators?
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: Joint to move body to specific position and orientation

Postby Julio Jerez » Fri Jun 02, 2017 8:55 am

The actuation are fine, but the are more like forward dynamics IK, for Inverse dynamic Ik a bether
joint would be the dCustomKinematicController as end effectors together with hinges joint with frictions as links, it should get a cool Ik robot
I never tried it, you can use that joints at the end effectors of your robot.

Basically this joint connect a body representing the desired location and orientation and drive the effector to that point. Then what you do is that to determine the path from the target location to the end effector and you make segment path that let calculate a next step.

for example. let
p0, q0 be the current position and orientation of end effector.
p1, q1 be the target position and orientation of end effector.

you can either move at constant velocity by dividing the length on equally space segments
of you can do a simple low pass filter

p = p0 + (p1 - p0) * some_fraction.
q = slerp (q1, q0) some_fraction.

you would probably have to do some calibration with friction, but it should work quite nice.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Joint to move body to specific position and orientation

Postby pHySiQuE » Fri Jun 02, 2017 10:55 am

CUSTOM_JOINTS_API void SetTargetRotation (const dQuaternion& rotation);
CUSTOM_JOINTS_API void SetTargetPosit (const dVector& posit);
CUSTOM_JOINTS_API void SetTargetMatrix (const dMatrix& matrix);

Ooooh, this looks like exactly what I need.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Joint to move body to specific position and orientation

Postby pHySiQuE » Fri Jun 02, 2017 12:05 pm

I created a kinematic joint but when I call SetTargetMatrix() nothing happens. The body just sits there.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Joint to move body to specific position and orientation

Postby pHySiQuE » Fri Jun 02, 2017 12:21 pm

Okay, so you use linear and angular friction to control how much force the joint can use, so you can make a joint that only changes position or only changes rotation, or both?
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Joint to move body to specific position and orientation

Postby Julio Jerez » Fri Jun 02, 2017 12:54 pm

As I remember, you do need to play with the amount of friction that you need to apply to drive to that point.

since you are applying friction to the joints on the arm, you will need to apply a friction value to overcome that friction asserted by the other links.
My recommendation is not to go crazy with huge unrealistic values of friction. In fact you sod not use dry friction at all. instead you should use a viscous friction with will make behave that most realistic possible way, in fact so realist that will mirror a real damped arm. and it will also be far faster.
This is a feature I added to newton 3.14, and I strongly recommend you to use it.

The advantage of a viscous friction is that the amount of friction if a function of the relative velocity, while dry friction is a function of the mass, and other forces therefore you nee to adjust each time you make a minor change.

I do no have access to the code now, so I cannot post a code sniped by I will do tonight, if you are willing to try that option.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Joint to move body to specific position and orientation

Postby pHySiQuE » Fri Jun 02, 2017 3:35 pm

Yes, please do.

Here's what I have so far:
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Joint to move body to specific position and orientation

Postby Julio Jerez » Fri Jun 02, 2017 5:30 pm

Ok that's quite impressive for a first pass.

tonight I will post the code that will overload the hinge joint so that you can select between, dry and viscous friction. Better yet it can do it automatically,
viscous friction is nice because is very fast and makes the solver far more stable and do not required recalibration should you change the configuration of your robot. Dry friction is good because it provides static friction force that is needed need to overcome to start moving and after that is not longer needed. These trick makes the system very realistic, and works like those computer controlled heavy objects with hydraulics that that can be operated by a person with a joystick of something.

These are the things I designed the engine for, noticed that we talk with the language of physics for controlling an articulation to do what you want. It is not perfect but is it a model that approximates some aspect of reality.
There are engines out there like vortex, that can do stuff like Newton does but not with the performance and versatility of newton, and there are engines out there like Havok and the others, that can't do that kind of stuff at all out of the box unless they assign an expert engineer to spend from six month to a year and in the process rewriting the laws of physics and coming out with stuff like:
-repeating the same joint from 4 to 32 times,
-setting the order in which the joint is resolved
-adding x position passes, and y velocity passes
-adding some extra long distance constraint
-multiplying the inertia by ten, but not the mass
-and other hacks like that or a combination of then

The exact formulae to tune the hacks is a mystery and only experts like your friend over your website knows how, but apparently is "standard for procedure for fast physics engines" or something that.
No sure how that can be called physics but what do I know, we live in a world of alternated facts now, not just in politics. So his solution is to removed any functionality show joints versatility and stuff from his "show case engine feature tool" who needs features other than speed?

I will write that joint for you, and I think you can use it a tweak it for many other usages.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Joint to move body to specific position and orientation

Postby Julio Jerez » Fri Jun 02, 2017 11:33 pm

ok try this hinge

I did not tested, but I hope you get the idea, you should be able to get to work as you want by tweaking m_dryFrition and m_viscousFrition

Code: Select all
class MyHinge: public dCustomHinge
{
   MyHinge (const dMatrix& pinAndPivotFrame, NewtonBody* const child, NewtonBody* const parent)
      :dCustomHinge (pinAndPivotFrame, child, parent)
      ,m_dryFritionCutoff(0.5)
   {
      // initialize these values here to control the joint
      m_dryFrition = 20.0f;
      m_viscousFrition = 10.0f;

      SetStiffness(0.99f);
   }

   virtual void SubmitConstraints (dFloat timestep, int threadIndex)
   {
      dFloat omega = GetJointOmega();

      if (dAbs (omega) > m_dryFritionCutoff) {
         SetFriction (0.0f);
         SetAsSpringDamper(true, 0.9f, 0.0f, m_viscousFrition);
      } else {
         SetFriction (m_dryFrition);
         SetAsSpringDamper(false, 0.9f, 0.0f, m_viscousFrition);
      }
      dCustomHinge::SubmitConstraints(timestep, threadIndex);
   }

   dFloat m_dryFrition;
   dFloat m_viscousFrition;
   dFloat m_dryFritionCutoff;
};
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Joint to move body to specific position and orientation

Postby pHySiQuE » Sat Jun 03, 2017 1:13 am

Cool, I will try this out tomorrow.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 13 guests

cron