unequal universal joint - "manual" mass ratio in joints?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Wed Feb 07, 2018 3:05 pm

I'm having brainstorming ideas again :)

Is it possible to set up a joint as such, that it is not as respectful to mass of objects?

For example, i wish to set up 2 bodies with equal mass of 2000 - a truck and a trailer, but i wish that truck would be able to pull the trailer as if it has no mass - without any effect by the trailer on main body - so moving the trailer would rotate, but not affect the truck (but would rotate around the pivot)

I use a ball and socket joint currently for this, but the mass is causing me a lot of difficulties because the increased total mass causes a lot of problems in my vehicle math behavior, it would be a lot more easier to just attach trailer in such a manner, is this feasible, or there is a better solution maybe?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1525
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Wed Feb 07, 2018 3:42 pm

yes, you can.
but there aren't any joint the does now.

you can't not make zero effect but it perfectly possible to make like 10 time, in fact once you have tow link 4 or five time heavier, it act ass if the other is no even there.

It is actually quite simple to do it, if you want I can make it tonight.
to clarify you want a ball joint that is like a pulley or a level?
Julio Jerez
Moderator
Moderator
 
Posts: 11122
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Wed Feb 07, 2018 4:20 pm

Yeah like that, basically ball and socket, the joint has angle constraints tho, and the main body must effortless-ly pull the pulled body, something simple like this?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1525
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Thu Dec 12, 2019 5:53 am

I am again thinking about this, but NewtonUserJointAddLinearRow does not differentiate between bodies, so how could this be done? that one body is completely hanging on pivot point and other body effortlessly pulls it regardless of their masses?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1525
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Thu Dec 12, 2019 7:46 am

I later will post a class that you can use as an example.
Julio Jerez
Moderator
Moderator
 
Posts: 11122
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Thu Dec 12, 2019 4:00 pm

Thank you, i think this will make trailers feel much better :)
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1525
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Fri Dec 13, 2019 11:02 am

ok I commite a joint in the demo, is in in demo
..\applications\demosSandbox\sdkDemos\demos\UsingNewtonMeshTool.cpp

the class name is class dPulleyBallSocket: public dCustomJoint

I did no added to teh custom joint library because thsi joint has very little use from anything other than what you wnat to do, and even them we do not knwo if that will really work.

anyway, whet you can do to decide the gear game , is to set to the mass ratio as

gearGain = M / m
M = big mass
m = small mass

I did not tested but I thin is works. try it out see what happens
Julio Jerez
Moderator
Moderator
 
Posts: 11122
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Fri Dec 13, 2019 3:20 pm

ok you can check it out now.
I connected the two boxes with the joint so that you can see how it works.
you can play with the gain and the mass if the boxes, toy see if it work correctly,
but I think is hard to see because the mouse picking is all might powerful and cancel any effect.
but in your game should make a big positive difference.
Julio Jerez
Moderator
Moderator
 
Posts: 11122
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Mon Dec 16, 2019 9:04 am

I did my translation of it, hopefully correct (i had some vector4 class issues but i think i sorted it out)

I've tried the correct formula for gear ratio and also 1.0 as input - variouud method of setting it up, and the joint behaved strange and eventually it crashed when calling NewtonUserJointSetRowAcceleration.

This is my translation:

Code: Select all
      NewtonBodyGetMatrix(FBody0, @matrix0);
      NewtonBodyGetMatrix(FBody1, @matrix1);
      NewtonBodyGetCentreOfMass(fbody0, @com0);
      NewtonBodyGetCentreOfMass(fbody1, @com1);

      com0.w:= 1.0;
      com1.w:= 1.0;

        com0:= MatrixTransformVector44(com0, matrix0);
        com1:= MatrixTransformVector44(com1, matrix1);

      CalculateGlobalMatrix(matrix0, matrix1, matrix0, matrix1);

      r0:= (matrix0.position - com0);
      r1:= (matrix1.position - com1);

        error:= (matrix1.vectors[3] - matrix0.vectors[3]);
        //error.w:= 0.0;

      NewtonBodyGetOmega(FBody0, @omega0);
      NewtonBodyGetOmega(FBody1, @omega1);
      NewtonBodyGetVelocity(FBody0, @veloc0);
      NewtonBodyGetVelocity(FBody1, @veloc1);

      for i:= 0 to 3 do begin
         dir0:= (matrix1.vectors[i].nScale(m_gearRatio));
         dir1:= (matrix1.vectors[i].nScale(-1.0));

         r0CrossDir0:= (r0.CrossProduct(dir0));
         r1CrossDir1:= (r1.CrossProduct(dir1));

         jacobian0[0] := dir0.components[0];
         jacobian0[1] := dir0.components[1];
         jacobian0[2] := dir0.components[2];
         jacobian0[3] := r0CrossDir0.components[0];
         jacobian0[4] := r0CrossDir0.components[1];
         jacobian0[5] := r0CrossDir0.components[2];

         jacobian1[0] := dir1.components[0];
         jacobian1[1] := dir1.components[1];
         jacobian1[2] := dir1.components[2];
         jacobian1[3] := r1CrossDir1.components[0];
         jacobian1[4] := r1CrossDir1.components[1];
         jacobian1[5] := r1CrossDir1.components[2];

         NewtonUserJointAddGeneralRow(FJoint, jacobian0, jacobian1);

         speed:= dir0 * veloc0 + r0CrossDir0 * omega0 + dir1 * veloc1 + r1CrossDir1 * omega1;

         stopAccel := -0.25 * (speed.x + speed.y + speed.z);
         postError := 0.1 * ClampFlt2 (matrix1.vectors[i].DotProduct3(error), -0.25, 0.25);
         NewtonUserJointSetRowAcceleration(FJoint, (stopAccel + postError / timestep) / timestep);

      end;
           


It is nearly identical, and operator overloadings are set up identically, i checked that vector.scale does multiply and not divide, etc.. most of work was changing how matrix addressing worked as in pascal you need to specificy exact member of struct of union by name.

This is how it looks like, it crashed when video ended.
https://www.youtube.com/watch?v=VCaM3kj-A2U

Mass of truck is 2500 and trailer mass is 500.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1525
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Mon Dec 16, 2019 3:51 pm

you can do two things
1- set the mass and the gain in the SDK demo, and see if is works.
2- set the masses equal and the gain to one, to see if the transnational is right and reproduces when goes on in the demo

I just did check one and there is a bug in the joint, it does something similar to what happen in the video. I will check it out tonight
Julio Jerez
Moderator
Moderator
 
Posts: 11122
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Tue Dec 17, 2019 6:13 am

Ok, let me know when it is fixed and i should retest
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1525
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Tue Dec 17, 2019 12:20 pm

I see what is wrong, the joint is not going to work using the pulley method, because the pulley method can not handle of com force or torques.
This feature is a function of the solver that apply on per joint bases not per row.
it is already supported but not exposed to the joint interface.
I will later add the interface and modified the joint.
Julio Jerez
Moderator
Moderator
 
Posts: 11122
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Wed Dec 18, 2019 9:58 am

ok you can try now. you do no nee to make a new joint, just use the dCustomBallAndSocket and afte you created it, call function SetBodyMassScale. I hope you are using the Joint Library,
look at the demo UsingNewtonMeshTool.cpp again
Code: Select all
   dCustomBallAndSocket* const joint = new dCustomBallAndSocket(pinAndPivotFrame, body0, body1);
   joint->SetBodyMassScale(5.0f, 1.0f);


the scale can not be lower than 1.0, and there is no check for that. and there is a catch
this option removes the joint from the exact solver.

the reason is that this option is very different than a pulley where both the Row and the Transposed of the row are scaled by the scale factor.
in this option only the transpose is, so that the force is scaled instead for the Mass.
this makes the big matrix of the system Non Symmetric and can not be factored like the joint solver expect the matrix to be. so the only way to deal with this is with the the general Jacobi solver used for contacts.
the point I am making is that this feature is just for very special cases like you are trying to do.
I tested and seems to work very well even better that I was expecting.

sync and try again please.
Julio Jerez
Moderator
Moderator
 
Posts: 11122
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Thu Dec 19, 2019 7:49 am

I do not use joint library as it's not exposed with a c / dll interface, but i can use NewtonUserJointMassScale, i will try that with my implementation of ballandsocket joint.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1525
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Dave Gravel » Thu Dec 19, 2019 10:37 am

Hi JernejL,
Here in pascal I create my dll for export the dCustomJoints to pascal.
I can't share the dll because it is mix with many c++ stuff, But if you need help for make a similar dll for only the custom joint let's me know.
It is easy to create and you can use all joints and you can export only what you need.
My method is easy to use it work very similar to the newton dll.

It is possible to use the dCustomJoints directly too but the implementation is complex and when the joint code is updated, It is not always easy to maintained.
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: 722
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests