Kinematic Joint rotation is very slow

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Kinematic Joint rotation is very slow

Postby JoshKlint » Mon Feb 25, 2019 9:35 pm

Since we updated Newton, the dCustomKinematicController has shown really slow rotation. The linear translation works fine. This happens even if we set m_maxAngularFriction to very high numbers like 100000.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Kinematic Joint rotation is very slow

Postby Julio Jerez » Tue Feb 26, 2019 8:40 am

There was a change on the gyro torque and centrypetal acceleration, that commented out some time ago in favor of a penalty acceleration.
I did not think it was affection motors, but maybe.
I do not have a test like that.
Dave stated he saw the problem too, but I could not find what it was.

Do you have a test I can check?
Julio Jerez
Moderator
Moderator
 
Posts: 10993
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic Joint rotation is very slow

Postby JoshKlint » Tue Feb 26, 2019 11:49 am

Download example here:
https://www.leadwerks.com/files/kinematictest.zip

Press E to pick up a crate.
Press escape to pause the game.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Kinematic Joint rotation is very slow

Postby Julio Jerez » Wed Feb 27, 2019 1:52 am

you have a bug no sure how you get ther but you are passing more than 6 dof
there is an assert there to warn you about that.

Code: Select all
void NewtonUserJoint::AddAngularRowJacobian (const dgVector& dir, dgFloat32 relAngle)
{
   CalculateAngularDerivative (m_rows, *m_param, dir, m_stiffness, relAngle, &m_forceArray[m_rows]);
   m_rows ++;
   dgAssert (m_rows <= dgInt32 (m_maxDOF));
}
Julio Jerez
Moderator
Moderator
 
Posts: 10993
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic Joint rotation is very slow

Postby Julio Jerez » Wed Feb 27, 2019 2:05 am

ok the 6 dof was my bug.
tell one thing I see then bug jitters a lot,
is that how is suppose to work. or are you using an old engine version.
Julio Jerez
Moderator
Moderator
 
Posts: 10993
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic Joint rotation is very slow

Postby Julio Jerez » Wed Feb 27, 2019 2:19 am

I think I found the bug, but before I fix this, I need you to sync the later and tell my if this is how the joint is suppose to work, I see more jitter than normal,

I also fixed the over determine number of dof on the joint actuator, I am not sure how you managed to get that, but an actuator can't be set as a motor. this lead to random crashes tha cant be predicted.

I made sure is disable that from teh base joint.
please check Is this is find before making a new change.
Julio Jerez
Moderator
Moderator
 
Posts: 10993
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic Joint rotation is very slow

Postby Dave Gravel » Wed Feb 27, 2019 4:52 am

I think my reported problem is similar.
In my case i'm not sure if it is a bug or a bad configuration.

Here I have try to get a more stable mouse pick.
When I use the mouse pick with the force method(USE_PICK_BODY_BY_FORCE), I can configure the pick and object mouvement very nicely.
The problem begin when I add joint in the scene and when I try to interacting with the connected objects.
The mouse force method is so much strong and it overpass the joint limits very easy.

With the (dCustomKinematicController) mouse pick method the pick and object movement is not bad but it behaving a bit differently.
This method is the best for use with joint, If you move the mouse normally it don't overpass the joint limits.
The problem with the dCustomKinematicController is when your mouse is set to fast or if you try to move the object faster. The object start to come far from the mouse pointer and it start to rotate in any direction.
The object look like attached to a longue elastic

My mouse have 4 speed and at 3 or 4 it is very easy to broke the joints with both mouse pick method, Or get the elastic effect from the picked object.

I have do some tests with this part of code
Code: Select all
const dFloat angularFritionAccel = 100.0f;
const dFloat linearFrictionAccel = 100.0f * dAbs (dMax (DEMO_GRAVITY, 10.0f));
const dFloat inertia = dMax (Izz, dMax (Ixx, Iyy));

//m_pickJoint = new dCustomKinematicController (body, posit);
m_pickJoint = new DemoCameraPickBodyJoint (body, posit, this);
m_pickJoint->SetPickMode (0);
m_pickJoint->SetMaxLinearFriction(mass * linearFrictionAccel);
m_pickJoint->SetMaxAngularFriction(inertia * angularFritionAccel);


I have try to update the SetMaxLinearFriction and SetMaxAngularFriction in the mouse move section.
My first idea is to generate a speed value and use this value for generate the angularFritionAccel & linearFrictionAccel value.
The trick seen to work good but my error is because I have use the picked object speed as value.
When you have a stack objects it is impossible or very hard to move the object under all others because it have no speed at all or it is very very low.
For fix it I have use a low default speed value + the object speed.
Like I have say it work not so bad.
After have think more about the problem It can surely work better if the speed value is generate from the mouse move speed and not from the picked object speed.
I don't have get time to test to generate the speed from the mouse move.
I'm sure it can give pretty nice result because already by using the object speed I get pretty good result when I change my mouse speed.

The mouse mouve speed can work very good, but it surely need some limits too.
It need to become limited at a lower value than what you need for broke a joint...

This static values is good for a general use but it is not good in all situations.
const dFloat angularFritionAccel = 100.0f;
const dFloat linearFrictionAccel = 100.0f * dAbs (dMax (DEMO_GRAVITY, 10.0f));
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 712
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Kinematic Joint rotation is very slow

Postby Julio Jerez » Wed Feb 27, 2019 8:28 am

remember when I said I fix the angular, so that now calculate the exact gyro and centripetal acceleration instead of using the angular error, and converted into a accelration by using an implicit integration step?
this was the consequence, for joint that is the angle error as the joint force.

it is a very eassy fox that does no add any size effect. Basically is jut overriding the joint accelration afte the contacting is submitted the same way the position error is done.

I asked Josh to check out fixt because he added a super huge friction force and I see lot of jitter, I do not If I add the fix and he doe no revert that, he will still think there is a bug.
But I now see that teh jitter is a camera mismatch error.

The fix is simple this in joint void dCustomKinematicController::SubmitConstraints (dFloat timestep, int threadIndex)

add this, before was doing this
Code: Select all
         dFloat angle = 2.0f * dAcos(dClamp(rotation.m_w, dFloat(-1.0f), dFloat(1.0f)));
         NewtonUserJointAddAngularRow (m_joint, angle, &rot.m_front[0]);
         NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxAngularFriction);
         NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxAngularFriction);


there is leaving teh angle erro to be the correction factor wich is now a small correction since teh joint assume to be numerically exact, so the penalty is doing exactly what is support to do, bring the separation slowly together.

now the joint most indicate that the row is a motor liek this
Code: Select all
         dFloat angle = 2.0f * dAcos(dClamp(rotation.m_w, dFloat(-1.0f), dFloat(1.0f)));

         dFloat speed = omega.DotProduct3(rot[0]);
         dFloat relSpeed = angle * invTimestep - speed;
         dFloat relAccel = relSpeed * invTimestep;
         NewtonUserJointAddAngularRow (m_joint, angle, &rot.m_front[0]);
         NewtonUserJointSetRowAcceleration(m_joint, relAccel);
         NewtonUserJointSetRowMinimumFriction (m_joint, -m_maxAngularFriction);
         NewtonUserJointSetRowMaximumFriction (m_joint,  m_maxAngularFriction);


now the error is converted into a motor velocity that will bring the error to zero proprtinal to the error. I work quiet well even on teh test the Josh gave me.

It is commited now, so if you both sync, it should be working.
can you chek it out again Dave.?
Julio Jerez
Moderator
Moderator
 
Posts: 10993
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic Joint rotation is very slow

Postby Julio Jerez » Wed Feb 27, 2019 8:31 am

I checked again to make sure and I think is in fact far better than using the penealty.
Julio Jerez
Moderator
Moderator
 
Posts: 10993
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic Joint rotation is very slow

Postby JoshKlint » Wed Feb 27, 2019 11:23 am

Works good now, thank you.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Kinematic Joint rotation is very slow

Postby Dave Gravel » Wed Feb 27, 2019 1:20 pm

Hi Julio, The fix don't fix the problem for me.

Here a exemple with my mouse pick modification.
My code modification is very bad and like I have say before it is surely better to get the speed from a other method.
In my code modification I get the picked object velocity,
I'm pretty sure it can work better if I generate the speed from the mouse mouvement.

This video show good the problem that I try to explain.
Video:
https://www.youtube.com/watch?v=uUuO1AvCAcw
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 712
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Kinematic Joint rotation is very slow

Postby Julio Jerez » Wed Feb 27, 2019 2:47 pm

few thing Dave.
first I can't see the editing in the video because the image is blurred.

second the pick object demo use a friction force and acceleration that is 100 time the gravity, which is about 100 time the body weight.
for toque is use 100 the max inertial matrix. so when you move the mouse like that the conversion of eh mouse movement to acceleration chances are is what more that 100 gravities, so it will break the friction limit. 100 g si no realy a extreme acceleration I use because it si abpu the G that can kill a person.
this code is here

Code: Select all
../applications\demosSandbox\sdkDemos\DemoCameraManager.cpp
// change this to make the grab stronger or weaker
   const dFloat gfactor = 100.0f;

               const dFloat angularFritionAccel = gfactor;
               const dFloat linearFrictionAccel = gfactor * dAbs (dMax (DEMO_GRAVITY, 10.0f));
               const dFloat inertia = dMax (Izz, dMax (Ixx, Iyy));

               //m_pickJoint = new dCustomKinematicController (body, posit);
               m_pickJoint = new DemoCameraPickBodyJoint (body, posit, this);
               m_pickJoint->SetPickMode (0);
               m_pickJoint->SetMaxLinearFriction(mass * linearFrictionAccel);
               m_pickJoint->SetMaxAngularFriction(inertia * angularFritionAccel);


the this point is that the joint is set to control the translation only, you make control rotaion you nee to change line283 from m_pickJoint->SetPickMode (0);

to m_pickJoint->SetPickMode (1);

I temporality change the gFactor to 500 and the pick more to full matrix,
can you sync and try again an tell me if this was what you meant?
Julio Jerez
Moderator
Moderator
 
Posts: 10993
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic Joint rotation is very slow

Postby Julio Jerez » Wed Feb 27, 2019 2:52 pm

one of the reason I do not like to use extreme gforce factors is that, remember the contact are solve with an iterative solver, if you pick one body and it is in contact with few other an huge joint farce is calculate exactly but the propagation to the rest of the other body is not, so the residual acceleration is larger, and that translate to jitter.

That the only reason, most people can use a higher values like 500 g and will be fine in most cases, but be aware of the issue. This can be mitigate with more sub steps but is a case by case setup.
Julio Jerez
Moderator
Moderator
 
Posts: 10993
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic Joint rotation is very slow

Postby Dave Gravel » Wed Feb 27, 2019 2:58 pm

Yes Julio the 500 value is what I talking about.
Yes the movement is better with 500, the problem 500 is constante and high for the joint.
With the joint it generate so much force and the joint overpass the limits.

It is why I try to calcul the 500 from the mouse movement speed with some limitations to make sure it don't get too much high values.

I think you can set my video in HD from youtube directly.

edited:
https://sites.google.com/site/oxnewton/ ... _modif.cpp
Like I have say my math is bad, I have surely drink so much wine the night when I have test it lol...
I use the object velocity for generate the speed value, but I think it is better to use the mouse move speed.
The modification is at lines 301 +
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 712
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Kinematic Joint rotation is very slow

Postby Dave Gravel » Wed Feb 27, 2019 4:49 pm

I have give a try with the mouse move speed.
I think I get it a bit better now with this method.
It is not perfect with all situations but it seen to work ok for move fast the object and with the joints too.
--
https://sites.google.com/site/oxnewton/ ... cation.zip
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 712
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest

cron