questions regarding suitability of newton dynamics

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: questions regarding suitability of newton dynamics

Postby Julio Jerez » Thu Jun 22, 2017 1:18 pm

But what is dGrammSchmidt(dVector(0.0f, -1.0f, 0.0f, 0.0f))?
I am not that brushed up in maths, but this creates not a rotation matrix but a matrix containing a coordinate system (ie. the upper three rows are axis vectors)? with the first axis specified in the first three components of the dVector as the pin axis?

yes that is correct, dGrammSchmidt is a simple orthonormalization process that allows to make coordinate system out of a set of vector.

In general all joints in the dCustom joint library use a standard inoput parameters.
a matrix that specify the joint axis, and the pivot of the joint axis.

in you example a ballandsocket joint need three axis of rotation, and a pivot, so all member of the matrix are4 used.

a hinge for example, is a joint that only used one axis of rotation and a pivot, for this
the first row of the matrix is the pivot and the position is the pivot,
similarly a joint that uses two axis then first and second row at joint pin and so on and so forth.

so joint have alternate constructors, like a ball an socket may take two joint parameter in the local space for the two related bodies.
these constructor as handy for case like the one misho is saying, say you want to save a contraction,
of joint then you want to load them at a later time, by some object may come out of order like he say, so there will be a small gap at the joint.

however by using the constructor that take two matrices, then when the joint is created, the solve will eliminate the error introduced by the lag

Misho has you try that? it may solve the problem.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: questions regarding suitability of newton dynamics

Postby JoeJ » Thu Jun 22, 2017 1:25 pm

Edit: Written at the same time as Julios similar response.

dGrammSchmidt is used in cases where you have a direction and want two arbitary axis to build an orthonormal orientation (e.g. because the joint intarnally needs them to be stable).

Note that dCustomJoints library is built on top Newtons built in UserJoint. It is easy to create your own joints - extremely powerful feature.
The library is good to learn how to do this, the SubmitConstraints method is the interersting bit, Newton calls this as callback.

Here are the most important functions from Newton.h (which is maybe enough for documentation after some time):

Code: Select all
// create joint and
   NEWTON_API NewtonJoint* NewtonConstraintCreateUserJoint (const NewtonWorld* const newtonWorld, int maxDOF, NewtonUserBilateralCallback callback, NewtonUserBilateralGetInfoCallback getInfo, const NewtonBody* const childBody, const NewtonBody* const parentBody) ;

// from within the callbacks use these:

// to limit position / orientation:
   NEWTON_API void NewtonUserJointAddLinearRow (const NewtonJoint* const joint, const dFloat* const pivot0, const dFloat* const pivot1, const dFloat* const dir);
   NEWTON_API void NewtonUserJointAddAngularRow (const NewtonJoint* const joint, dFloat relativeAngle, const dFloat* const dir);   
// if you call this after adding the row you can generate a motor:
   NEWTON_API void NewtonUserJointSetRowAcceleration (const NewtonJoint* const joint, dFloat acceleration);
// to limit the maximum force/torque used by limits or motors:   
   NEWTON_API void NewtonUserJointSetRowMinimumFriction (const NewtonJoint* const joint, dFloat friction);
   NEWTON_API void NewtonUserJointSetRowMaximumFriction (const NewtonJoint* const joint, dFloat friction);


To build your own ball socket between two dynamic bodies, the steps would be like this:
Create the user joint with a number of 3 solver rows, and within the callback do this:
Get current world space matrices for both bodies, multiply each with a localy offset matrix to get the points that should stay together (pin position, e.g. the corners of two cubes).
Use the orientation of one body to get 3 orthonormal directions.
Add 3 linear rows to keep the pin points together using 3 planes built from those 3 directions and one pin position.

So typically you solve a simple geometric problem and Newton calculates the forces.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: questions regarding suitability of newton dynamics

Postby misho » Thu Jun 22, 2017 1:48 pm

Julio Jerez wrote:these constructor as handy for case like the one misho is saying, say you want to save a contraction,
of joint then you want to load them at a later time, by some object may come out of order like he say, so there will be a small gap at the joint.

however by using the constructor that take two matrices, then when the joint is created, the solve will eliminate the error introduced by the lag

Misho has you try that? it may solve the problem.


Hi Julio, I haven't tried that but I think my problem is much more simple - it is the fact that I re-load objects not at the same time, but with small time gaps which make already loaded objects "run ahead" of them. Just to note, my objects have very high (orbital) speeds, so even a few milliseconds translates to tens of meters of gap. I know what I have to do - basically, load all my objects into intermediate structure, and when that's finished, construct them all at once and add them to Newton.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: questions regarding suitability of newton dynamics

Postby misho » Thu Jun 22, 2017 2:03 pm

eabbink wrote:Is your newton object created on visual object load? in that case I understand your problem, you are providing a position at time = 0 from file for that object which is not in sync anymore with the already existing objects and simulation which are at time = some t.

If the above is correct, a possible solution could be to decouple newton and visual objects. Ie. create all (meta)objects which are present at time = 0 including newton objects, and add the visual objects to their (meta)objects (which contain reference to newton and visual object) when they become available. However, this implies knowing which objects need to exist at time = 0, which may not be the case if object presence/creation is triggered by the graphics engine loading a scene file with unknown object contents.. Having a state file should eliminate that issue though?


That is correct - it's like trying to add train cars to a moving train. You know where it is supposed to go, but by the time you add it to that location, the rest of the train moved up ahead :mrgreen:

So yeah, basically what I am doing is, reading in all my objects into an intermediate structure, and when all the visual objects are loaded, construct the structure in one sweep. I haven't had a chance to finish this yet (due to my day job :roll: ) but I think that should resolve my issue.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: questions regarding suitability of newton dynamics

Postby Julio Jerez » Thu Jun 22, 2017 3:02 pm

I have a question for eabbink
you mentioned that your team have their own vehicle simulator, and that you want to use a general physics solver in order to improve joint accuracy and other things.

my questions are:
-is your vehicle system constraint based?
-if so, it is using a reduced coordinate system like Newton or is a generalized coordinate system?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: questions regarding suitability of newton dynamics

Postby eabbink » Thu Jun 22, 2017 6:27 pm

The current model is very specifically written and has no joint support at all, at least not in a 'normal physics engine' way. Tire forces are modelled using pacejka with an empirical brush model to combine lateral and longitudinal forces. Suspension model supports a wide range of geometries and includes things like jacking forces, instant roll centres etc but does not consist of a generic joint/body/constraint system. The integration method used is outdated (most of it should be implicit euler afaik), which causes several problems. Still, the model can produce quite good results.

For a current project however we need to do an articulated vehicle, which is something the model does not support at all. So either we extend our model in that regard, or we adapt and use something of quality already available. As there are likely to be many more projects where some kind of articulation or other interaction is needed it did not make sense to start to develop our own physics engine.

I've looked at ODE, PhysX, Bullet, and others. First tried DART as it should have some important qualities for us. But I got stuck after getting some initial tests to work because of some things that seem weird (probably aren't, just that I don't understand) like querying linear velocity and getting a 6 dimensional result with no explanation what the other 3 values are. As I could not find any documentation explaining more, no forum, no easy way to contact anyone I decided against proceeding with that due to too little support possibilities, now and future.

The key points attracting us to Newton are: focus on accuracy, reputed stability of solver, determinism

From the forum I have seen that Newton possesses a more detailed vehicle model as well. For now I am just implementing the rigid body of our model with a newton body so I can add joints. After that, it should be interesting to see where using Newton creates new possibilities to perhaps improve our model in other areas. Modelling the entire chassis and suspension components with bodies and joints however, is probably still a bridge too far.. :mrgreen:

Added some screenshots of debugging/tuning views (please disregard the graphics quality, these are quite _old_). Note that I had to scale them down quite a bit to be below 256KB for the forum.

vehiclemodel1s.jpg
vehiclemodel1s.jpg (187.61 KiB) Viewed 7219 times

vehiclemodel2s.jpg
vehiclemodel2s.jpg (194.09 KiB) Viewed 7219 times

vehiclemodel3s.jpg
vehiclemodel3s.jpg (208.16 KiB) Viewed 7219 times
eabbink
 
Posts: 21
Joined: Wed Jun 21, 2017 6:32 am

Re: questions regarding suitability of newton dynamics

Postby eabbink » Thu Jun 22, 2017 6:28 pm

vehiclemodel4s.jpg
vehiclemodel4s.jpg (186.25 KiB) Viewed 7219 times
eabbink
 
Posts: 21
Joined: Wed Jun 21, 2017 6:32 am

Re: questions regarding suitability of newton dynamics

Postby Julio Jerez » Thu Jun 22, 2017 7:58 pm

oh I see, since your vehicle is a simple body model, you should be able to convert it straight to the engine as a first test.
then form ether you can start experimentation with joints. like making tire actual joints, and extending the model.

one thing you will find out as you elaborate your model is that some equation do change, and the physics start changing from an applying effect to a emerging behaviors, for example when you vehicle is a simple body, your code is in charge to calculate the force pushing the car, by when the body is articulated, you nee to rely of the joint toque to generate that force fore your. similarly you can have a tire and apply a torque and when you add a engine with mass and inertia with a differential the you not longer apply tire torque, instead the engine generate the torque and so, on. you can then start adding stuff like rigid axels, rigs, trailers and moving parts.
here is a example of how people play around with joint to put together simple vehicles, and they do not even apply the equation of vehicle dynamics.


The vehicle model in newton is one that implement those thing. It models engine, differential, gear box, clutch, suspension and all those thing emerge from the kinematic of the articulate body.

Anyway you can check out how the custom joint implement the vehicle manager, as an example of how to get start with you implementation. I can set up a demo for you that you can take as you skeleton to start build form there, many of the newton demos seem to no make since because they are the result of some sand box of some projects.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: questions regarding suitability of newton dynamics

Postby eabbink » Fri Jun 23, 2017 12:04 pm

Yes, exactly.

Our model already contains things like engine, transmission, driveline, clutch, differential etc and support for 2wd, 4wd and other configurations with more than 4 wheels. Just not using joints ;) But there are several areas where I see room for improvement so I am interested to see what benefits Newton can provide :)
eabbink
 
Posts: 21
Joined: Wed Jun 21, 2017 6:32 am

Re: questions regarding suitability of newton dynamics

Postby Julio Jerez » Fri Jun 23, 2017 2:02 pm

Oh yes I am sure you guys have all those things and that they works to satisfaction :D and that'S the beauty, because you have a system to use as the standard to measurer against, until the new version surpasses it, if it ever does.

what I was trying to say is that in the new system, you can start by porting your to newton verbatim, basically the vehicle is one rigid body and you calculate a forces and torque generate form each of these components. After these system is all working like your identical or better to you system.

the you move to improvements, by adding component in a modular way.
in the new system each one of these parts are in fact rigid bodies attach to the chassis of other part with a joint, and the joint is the device that does the calculations.

to give you an idea of what I am talking, if you play the vehicle that come in the demos, if you lip the vehicle upside down and you spin one tire with the mouse, if the engine is in gear, you will see that the other tire actually spins the opposite direction. these effects comes out as emerging from the kinematic relation of the differential joint.

so in you case after you get the basics system going, you can assay let of now make the tires actual bodies connected to the chassis with a joint.
That joint can be a motor joint that take a joint acceleration or a free joint that take an external force either way works, but the motor is the most correct, the you move to line the tire with a differential and so on.

what I am going to do this weekend is that I will add the GetAcceleration function, and I will add a bank demo that implement a listener, so that you can use it to get start in your system.

the we can use that to share information either public or private, until you are familiar and you can move on by yourself.

please tell me is this is acceptable to you.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: questions regarding suitability of newton dynamics

Postby eabbink » Sun Jun 25, 2017 10:10 am

Yes, that is precisely how I am going to proceed. Having the acceleration being added on that short notice would be great. And I am good with discussing here, as long as we are talking Newton and just generics perhaps it helps others as well.
eabbink
 
Posts: 21
Joined: Wed Jun 21, 2017 6:32 am

Re: questions regarding suitability of newton dynamics

Postby Julio Jerez » Sun Jun 25, 2017 2:12 pm

ok I added those functions, in fact there were still the legacy NewtonBodyGetForceAcc pair
here is the prototype, you use the same way GetVelocity is used.

    NEWTON_API void NewtonBodyGetAlpha(const NewtonBody* const body, dFloat* const vector);
    NEWTON_API void NewtonBodyGetAcceleration(const NewtonBody* const body, dFloat* const vector);
    // NEWTON_API void NewtonBodyGetForceAcc(const NewtonBody* const body, dFloat* const vector);
    // NEWTON_API void NewtonBodyGetTorqueAcc(const NewtonBody* const body, dFloat* const vector);

like I said before, setting acceleration is not really an option so there is not interface for that.
so those function are for the client app to read acceleration an angular acceleration after each integration step in case it needs it to make some specific calculation.

also I still can't imagine what physical system can have a parameter that is a function of the acceleration, acceleration is a very erratic parameter, take for example a box in free fall, the acceleration is gravity, but the moment it collides or get in contact with anything you will get a very different values, and not smooth at all.
but I could be mistaken.

anyway I was going to add the listener by I see that this is already in the demos. you can look at
class ..\newton-dynamics\applications\demosSandbox\sdkDemos\DemoListenerBase.h

this is a base class the implement the creation of a listener, you cn ause as a model for yours and port you implementing of you vehicle system in function.

Code: Select all
virtual void PreUpdate (const NewtonWorld* const world, dFloat timestep) = 0; 


which is call each newton update
you can keep all you vehicles in your own container,
and you can iterate over all of them do the vehicle you own vehicle physics and adding all the forces and torque you want to the each vehicle body.

I hope this helps.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: questions regarding suitability of newton dynamics

Postby JoeJ » Wed Jun 28, 2017 3:35 pm

Julio Jerez wrote:also I still can't imagine what physical system can have a parameter that is a function of the acceleration,


Hehe, yep. I've spent quite some time to update my stuff to have the new acceleration data available, only to figure out at the end that my controller uses only velocity, not acceleration - i've had remembered this just wrong. :roll:

But i found out i can now mix body velocity and predicted controller velocity by a ratio of 1:10 - this did not work well with the old joints but now it does. Should be enough to prevent things from drifting apart. :D
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: questions regarding suitability of newton dynamics

Postby eabbink » Tue Jul 04, 2017 5:47 pm

Hi Julio,

yes, that certainly helps! I have been busy with too much other stuff to get much progress, but I have already got the basics working. Having the PreUpdate is nice as well, and will allow me to do things a little more cleanly ;)
eabbink
 
Posts: 21
Joined: Wed Jun 21, 2017 6:32 am

Re: questions regarding suitability of newton dynamics

Postby JoeJ » Wed Jul 05, 2017 11:44 am

I found good use for getting acceleration now as well.
My controller finally works with real velocity instead of predicted velocity from the previous step.
Adding something like 50% accelartion to velocity has the nice effect to compensate lag issues i'm always struggling with - seems dirty but it works quite well.
IP can now swing forth and back very close to the theortical max speed :)


Julio Jerez wrote:anyway I was going to add the listener by I see that this is already in the demos. you can look at
class ..\newton-dynamics\applications\demosSandbox\sdkDemos\DemoListenerBase.h

this is a base class the implement the creation of a listener, you cn ause as a model for yours and port you implementing of you vehicle system in function.

Code: Select all
virtual void PreUpdate (const NewtonWorld* const world, dFloat timestep) = 0;



which is call each newton update
you can keep all you vehicles in your own container,
and you can iterate over all of them do the vehicle you own vehicle physics and adding all the forces and torque you want to the each vehicle body.


I still wonder about the listener stuff and have no clue what it could be good for.
Is this just another way than using force/torque callback, or does it open other possibilities i'm not aware of?
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron