Request: Add NewtonUserJointSetRowForce

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Request: Add NewtonUserJointSetRowForce

Postby AntonSynytsia » Sun Feb 14, 2016 8:32 pm

So there is a function, like NewtonUserJointGetRowForce. Is it possible to have an additional function to set/modify row force, like NewtonUserJointSetRowForce. I might find it useful, for instance to make joint stiffer by multiplying the calculated force by 10 for example. Thank you
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Request: Add NewtonUserJointSetRowForce

Postby Julio Jerez » Sun Feb 14, 2016 8:50 pm

that's actually a really bad idea. are you in Newton 3.14?

Because for newton 3.14 there is a way to make the joints super strong if you can configure your articulated bodies like a skeleton.
This is actually how most package allow the user to make models, basically each a node can have many children by only one parent.
Then the usually have a special kind of connection for when two children are linked together, in max this is called constraint.
for example say you have a character and the character will have a two handed weapon. when the do is the attack the weapon to one hand and the point that connect the other hand to the weapon is and IK constraint. Is actually very powerful and flexible,

Even when the model has loops, you can always find a way to set most joint like a skeleton by breaking the loop and then adding the other joint as not articulation.
check out the 3.14 demos, all the joint in the standard joint, the rag dolls, and the vehicle use that new feature.
if you play the standard joints demo you can try peaking some of the sample and you will see how strong the are.
what are you doing? maybe I can give you some pointer how to set it up.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Request: Add NewtonUserJointSetRowForce

Postby AntonSynytsia » Mon Feb 15, 2016 2:07 am

Juleo,

First of all, thank you for maintaining the physics engine.

I updated to the latest 3.14 and the joints are quite stiff. The reason I am interested in the function above is because it seems that joint stiffness is greatly affected by the difference in mass between parent and child bodies.

Consider the following case presented in the video:
https://drive.google.com/open?id=0B3qg8 ... XgwQTUza00

It would be nice if mass of bodies linked by other joints didn't affect the stiffness of a joint. I am wondering if multiplying force of every row by the mass of linked bodies would make the joints more robust, making joint stiffness independent from the mass of other connected bodies. I will implement the skeleton container into my wrapper as suggested and see if it is useful for such case.

Anton
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Request: Add NewtonUserJointSetRowForce

Postby Julio Jerez » Mon Feb 15, 2016 7:13 am

Oh that a good example, to show precisely what I mentioned, if you apply the skeleton to all three of those arrangement, the all three will be equally stiff.

for each one you create a skeleton with the fix objet at the root
then you add each link as child,
and you close the skeleton.
and that all you need to do.

please try that and let me know again.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Request: Add NewtonUserJointSetRowForce

Postby JoeJ » Mon Feb 15, 2016 7:24 am

It's possible to add all joints in random order, like this code (i think this is not shown in demoSandbox):

Code: Select all
newtonSkeletonContainer = NewtonSkeletonContainerCreate (world, bodies[HIP], 0);
      NewtonSkeletonSetSolverMode (newtonSkeletonContainer, 1);
      
      int jointCount = 0;
      NewtonJoint *jointArray[NUM_JOINTS];
      for (int i=0; i<myJoints.size(); i++)
            jointArray[jointCount++] = myJoints[i]->joint;
   
      NewtonSkeletonContainerAttachJointArray (newtonSkeletonContainer, jointCount, jointArray);

      //and after all the bone are added, the call
      NewtonSkeletonContainerFinalize (newtonSkeletonContainer);


That way you don't need to care about the tree structure and Newton figures out itself.
However, you still need to make shure there are no loop situations i guess.


The video looks great and is a very nice test. You should post on YouTube after the update :)
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Request: Add NewtonUserJointSetRowForce

Postby Julio Jerez » Tue Feb 16, 2016 6:53 pm

hey AntonSynytsia did you get the skeleton going? I am curios to see if it fix the problem.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Request: Add NewtonUserJointSetRowForce

Postby AntonSynytsia » Tue Feb 16, 2016 7:46 pm

I did. I wasn't quite successful to getting it to work properly, but it could be related my improper usage/imppementation of the skelton container. l will investigate your demos in depth and see if there is something that I implemted wrong and then I will post a debriefed feedback about skeelton cpntainers.
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Request: Add NewtonUserJointSetRowForce

Postby AntonSynytsia » Thu Feb 18, 2016 3:32 am

Hello Juleo,

In the previous post I wrote that I couldn't get the skeleton container to work properly. The problem was that hinge joints were not rotatable when enchanted with the skeleton container. The reason to unrotatable joints is that my joints used the deceleration technique for damping:
Code: Select all
NewtonUserJointAddAngularRow(joint, 0.0f, &matrix0.m_front[0]);
NewtonUserJointSetRowStiffness(joint, joint_data->stiffness * Joint::STIFFNESS_RATIO);
dFloat rel_omega = (omega0 - omega1) % matrix0.m_front;
dFloat rel_accel = -cj_data->damp * rel_omega;
NewtonUserJointSetRowAcceleration(joint, rel_accel);

When I switched the damping code to use the min/max friction technique, the joints became rotatable:
Code: Select all
NewtonUserJointAddAngularRow(joint, 0.0f, &matrix0.m_front[0]);
NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);
NewtonUserJointSetRowMinimumFriction(joint, -cj_data->damp);
NewtonUserJointSetRowMaximumFriction(joint, cj_data->damp);

It would be nice however if the hinge joints were rotatable when controlled with my original damping technique.

Anyway, after changing the damping technique, the skeleton container did indeed improve joint stiffness. Here is the demonstration:
https://drive.google.com/open?id=0B3qg8 ... 09mR0VBc1U

Regardless of the chain of mass, joints don't tilt downward as they did in the previous video, which resembles excellent results of the skeleton container. There is one problem however. It's easy to stretch joints with low mass, but quite uneasy to stretch joints with higher mass. From the observation, it seems that the skeleton container is only stiffening the angular rows, but not the linear rows.

Another problem comes in when the root body of the skeleton container is connected by a parent joint: https://drive.google.com/open?id=0B3qg8 ... zdtN2Z6dnc It seems that the skeleton container doesn't consider if the root body is connected by a parent joint.

The problems, presented in the cases above could of course be easily manipulated. For instance, problem one could be resolved by increasing mass to improve linear row stiffness. Problem two could be also resolved by adding a parent body to the root joint, making the parent body static, and making that new parent body as the root body of the skeleton container. I'm just presenting these little problem cases to inspect the usability of the skeleton container because in other cases these problems with skeleton container might be unsolvable. I think that the skeleton container needs to be developed a little further to be functional more cases. Other than that, skeleton container is a very great feature of Newton and it impresses me quite much.
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Request: Add NewtonUserJointSetRowForce

Postby Julio Jerez » Thu Feb 18, 2016 8:41 am

ha much better. :D
AntonSynytsia wrote:The problem was that hinge joints were not rotatable when enchanted with the skeleton container. The reason to unrotatable joints is that my joints used the deceleration technique for damping:
When I switched the damping code to use the min/max friction technique, the joints became rotatable:
It would be nice however if the hinge joints were rotatable when controlled with my original damping technique.


ha there is also an option for that, the skeleton also have a solver mode. The default is the simplest, that does not consider joint limits, but if some joint have limits them you can call function
Code: Select all
void NewtonSkeletonSetSolverMode(NewtonSkeletonContainer* const skeletonPtr, int hardJointMotors)

and that will handle that problem. please see if that works.

Regardless of the chain of mass, joints don't tilt downward as they did in the previous video, which resembles excellent results of the skeleton container. There is one problem however. It's easy to stretch joints with low mass, but quite uneasy to stretch joints with higher mass. From the observation, it seems that the skeleton container is only stiffening the angular rows, but not the linear rows.

nit it stiffen everything, I did noticed that in some cases and it seems ether is a bug the way the stiffness is working for linear rows, one of the problem is that the Skelton joint is not a well numerically numerical stable solver, It is exact but is has to deal with extreme conditions numbers, more so that a regular pivot method.
I will check that out, but recreating a demo that let reproduce it in eh sand box.
all I need to know is how you produce the pulling force.


Another problem comes in when the root body of the skeleton container is connected by a parent It seems that the skeleton container doesn't consider if the root body is connected by a parent joint....
Problem two could be also resolved by adding a parent body to the root joint, making the parent body static, and making that new parent body as the root body of the skeleton container

yes that's how the skeleton deal with problem. In newton when a joint is connected to a NULL object, internally is connected to sentinel, which is a dummy static body common to the entire world. Skeletons need a unique object root to store intermediate information so the root can not be the common sentinel, I tried to handle automatically, but it adds unnecessary complexity.
for example the root will no longer be the root that the user specified,
there will be not way to separate two different skeletons if the were connected to the same sentinel.
I could add a automatic sentinel creation that add a sentinel manager to the engine, and is goes on an on.
instead let the end use add a static dummy as root solve all those problem and the application know how to deal with non colidable invisible object already.

so of all the problems the biggest one is the dismembering of the first change of links, is you tell my how you make the pulling force I can recreate it is the sand box and see what I can do.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Request: Add NewtonUserJointSetRowForce

Postby AntonSynytsia » Thu Feb 18, 2016 2:12 pm

The pulling force is based upon your CalculatePickForceAndTorque function from physics utils. Of course, however, rather than pulling the object vertically, the object is pulled horizontally. The case can be easily reproduced with the Demos Sandbox. For instance, try pulling hinged doors horizontally in the Standard Joints demo of the Demos Sandbox. Based upon the current build, it won't take much effort to stretch the linear rows of the joints. Then, increase/decrease the mass of these doors, recompile Demos Sandbox, and pulls the doors horizontally once again. You should see the difference in linear stretching.
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Request: Add NewtonUserJointSetRowForce

Postby Julio Jerez » Thu Feb 18, 2016 5:43 pm

AntonSynytsia wrote:The pulling force is based upon your CalculatePickForceAndTorque function from physics utils.

Ha I was suspecting that. that function is horrible.
basically that function take the mouse location and converted it to a force to push the object form it location to the desire mouse position. It generates force of hundred of millions of newton forces.
and at that level numerical and euler and iterative solve can resolve the error.
It is like you are adding an objet the size of a air craft carrier or an island to the end.
The force you are applying there are will never happen on any realistic simulation.

I would not worry about that, I should probable add some limits to the pick force, it is too strong
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Request: Add NewtonUserJointSetRowForce

Postby AntonSynytsia » Thu Feb 18, 2016 7:53 pm

Will double precision (that you're going to implement) eliminate such effect without limiting the pick and drag force and torque?

Regardless, I still think that the linear row is not as strong as the angular row when enchanted with the skelton container. I will two tests that suggest that.
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Request: Add NewtonUserJointSetRowForce

Postby Julio Jerez » Thu Feb 18, 2016 10:38 pm

double precision will make it better but will not fix it.
But maybe you are right, an the linear row is no as strong, which is strange because traditionally linar row we stronger. I will verify there is not a bug there.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Request: Add NewtonUserJointSetRowForce

Postby AntonSynytsia » Fri Feb 19, 2016 5:29 am

Hello, Juleo. Here is the test demonstrating that linear rows enchanted by the skeleton container are not as strong as the angular rows: https://drive.google.com/open?id=0B3qg8 ... DU5SEhtTlE
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Request: Add NewtonUserJointSetRowForce

Postby Julio Jerez » Fri Feb 19, 2016 10:05 am

Oh I see, the test to expose the linear row weakness apply the gravity horizontally, good idea.
I will recreate that test in the standard joints demo, and do see why is that. you have might found a bad bug.

for what I see in the video, the gravity seem to be 100 m/s ^2, or is that just a force applied to the heavy body
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron