Tires popping up on flat terrain

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Tires popping up on flat terrain

Postby Julio Jerez » Thu Dec 13, 2018 2:54 pm

Joe let us open a new thread for animation, I have been working a little more on eh balancing characters, no sure if you saw it.

I move all the code from the SDK to the utility library so that is can be use as immediate physics solve for both full invers and forward dynamics.
I have no remove the low lever solver, I will probably keep it for future reference, but if having the solve exposed offers lots more flexibility. can you check it out ?
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Julio Jerez » Thu Dec 13, 2018 3:02 pm

Ok for people interesting on the vehicle,
O just fixe the bug and move the implementation of the callback to outside the classes so that Is more clear how is use.
Later I will clean up David demo, I see he use my old style of subclassing the DemoEntity, wheiu is good if you are making yor own project but is no good as pedagogical teaching tool.

anyway I replaced the flat plane with a rolling terrain and I drive around a little, I di not see any glitches, but it need more testing for sure.

David can you check it out and see if you understand it?

what I am going to do is that I will delete the old vehicle manage and build this one up, because is simpler.

The I will elabodarete on the single vehicle because that one will be a realism high quality and high performance in both is simulation time and dynamics quality. and that's hard to get wit the generic solver.

anyway before we move on, I will wait until you get this and dive some feed back.
them I will add the tricks I learned that makes the simulation better one at a time.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Dave Gravel » Thu Dec 13, 2018 4:32 pm

Your modification seen to work very good over terrain.
I see the change and it look easy to use.

In the Joint Controller class I use some inherited parts that is not needed at all.
I have seen it only later when I have re-add my vehicle in my android code.
This inherited parts can become removed to make the code more clean and easy to read.

This vehicle can look very good with a better setup.
In this demo I don't have implement the engine + gears for torque because my old code about this part is a mess and it is mix with many things.
With the engine + gear + steer rotate speed limite, You can get very nice vehicle simulation.

Take a look too in the tire projection, I use a hack about the tire omega.
tireOmegaCorrection, I use this for fix a rotational problem with joint.
I use this for fix a problem similar to MeltingPlastic post about [Motor Joint Issue]
Maybe it can become fixed from a better way.

The tire projection help a lot for let's the tire in good direction at high speed and for fix the joint error at high speed too.
Maybe the tire projection need some fix too, Because it add some undesired force & torque on the vehicle frame body.

If you have a mesh model like the loop in my demo or stair, Try the vehicle over it.
It is a other major problem with multibody vehicle, The tire do penetration on mesh edge corner and it can stay gluted on the edge for some secs.

Sorry about my bad explanation again, my english is limited.
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: Tires popping up on flat terrain

Postby Dave Gravel » Thu Dec 13, 2018 5:23 pm

If you like to really see what my hack omega correction fixing.

Go in the TireProjection comment out this lines.
//tireOmegaCorrection = (tireOmegaCorrection * mTireOmegaCorrection);
//NewtonBodySetOmega(tire, &tireOmegaCorrection[0]);

Start the demo, place the vehicle on top side and add some acceleration on tire.
You can see the tire can start to spin in any directions.

This seen to happen only when the tire is in the air and don't colliding.
I use this omega hack for avoid this problem.
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: Tires popping up on flat terrain

Postby Julio Jerez » Thu Dec 13, 2018 6:31 pm

those are all very good points David, and they al be corrected, from easier to hardest.
first what I will do is the cleanup and simplify the demo and make the official basic car.
I will delete the vehicle in the dJoint since there is no nee for that anymore.
I am going to minimize the amount of physic modeling and focus more in the physic engine and making simple generic demos.
you demo is very good and I will add the basic trick to make more stable and robust.

Dave Gravel wrote:Take a look too in the tire projection, I use a hack about the tire omega.
tireOmegaCorrection, I use this for fix a rotational problem with joint.
I use this for fix a problem similar to MeltingPlastic post about [Motor Joint Issue]
Maybe it can become fixed from a better way.

The tire projection help a lot for let's the tire in good direction at high speed and for fix the joint error at high speed too.
Maybe the tire projection need some fix too, Because it add some undesired force & torque on the vehicle frame body.

there will be a generic solution for this. but it will be the last trick because before that I want to add all the basics trick that make the vehicle more stable.
I will just say there will be not cheats and no hackly project, and yes the vehicle will be able to make the loop the loop.
however I expect it to be behave generally good under normal driving conditions
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Julio Jerez » Thu Dec 13, 2018 11:16 pm

Ok David, I start refactoring your vehicle demo, I't like you to follow with me so that you learn some of the trick I apply but that does not brake the physics.
I committed set it to the new refactor version.

he is trick number one.

I see that you apply the suspension force as external forces the same way I used to do, with is very good.
you use the function NewtonCalculateSpringDamperAcceleration which convert the relative acceleration between the two body the the actual spring force, this is not bad it is the right way, but there is a problem.

Since that function is only for a single joint, it require a solver to caculte the coupling influence form one suspension to the others.
I see you use a factor frameTorqueAffective torque effective. but in reality that's what many text book call sprung mass, which is the fraction of the mass of the vehicle that is supported by the tire suspension. here is the problem the book do not say.
That factor of 0.25 or what ever the value the book uses, is based of what is called steady state.

basically what the book does is that they do the calculation of the vehicle when the vehicle is at rest and then by using partial derivatives of the state equation they can estimate the behavior of the vehicle under small deviation of from that state.
that does not work for a simulation where nee to calculate the value as if eacht state is a steady state.
for that I have the code in tow places.

I want you to check the function virtual void PreUpdate(dFloat timestep, int threadIndex)

because right now is the way you have it set up later I will change it to the more accurate method.

This goes for other people interested as well.
These are the thing that make the simulation different that the stuff people have but that the car never act like a realist car.

consider this lesson 1;
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Dave Gravel » Thu Dec 13, 2018 11:40 pm

I'm following and i'm not far.
Thanks Julio.
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: Tires popping up on flat terrain

Postby Julio Jerez » Fri Dec 14, 2018 10:38 am

ok I committed the demo with the new function to calculate the suspension forces.
void ApplyTireSuspensionForces (dFloat timestep)
the old one is called void ApplyTireSuspensionForcesOld (dFloat timestep)

we can leave ther as futre reference.

Thsi funtion does no require the effective mass, the proper name in authomotive dynamics is "Sprung Mass", but remember teh value is no a contant, it just hapen to be 0.25 for a perfectly balance four wheel vehicle in equilibrium, it does not account for correct weigh transfer when the vehicle chassis has relative accelerated, teh way is calcualet in the book is by limirizing the equation whi give a first order aproximation for small motions.

the new funtion calcuate the correct value for all case and all configuation of wheels, and we can use real Spring and Damps value for data sheets.

anyway check it out.

for the people reading, you can use the spring funtion of teh hinge, but that no really correct. it is upto any one to use the method in the demo, does no make much different.

is you are going to use thie method. thsi are the steps.

1-implement a listener to encapsule the speciali update you what to apply to teh phsyics model.
by physical model I mean the collision if bodies and joint the represent your complete model.

this is different than the force and torque callback in that you get the comple model not one body at a time. It also provide other functionality for the high lever like
it will work in paraller when the engine is in paraller, and this is imprtant because modeling is more than just the physic solver, it will add more sofisticated specialize funtionality that are har to add to the generic physics and collision solver.
it take care of the sleeping stuff an all the logistic.
It provide the high level for a way to pos process the model afte teh simulation, for example you cna add stuff like animate parts that are attach to the model, steering wheel an animate driver, and so on

2- you create the model and assorite witeh the controller then that will provide the callbacl to funtions PreUpdate and PostUpdate, you cn athink of these as force and trque callbacl for full constracions of bodies and joints.

3-It is in the preupdate that all funtionality that apply to teh entire model is applied.
in the case of these example we apply the suspension force as a local mini solver.
later we will also apply aerodynamci drag and finaly teh joint correction error that David was taking about.
Joint correct will be the last thing because teh vehicel souel work at moderate speed without it.
but correct is a fundemental part of it and in thsi case is not a cheat.

what I say in this case is not a cheat I am not claming special pleading. meaning I complete all engine cheat when teh tak about position pass and velocity pass and all tha mombo jumbo.

I say in our case is no a cheat for the following reasons.

our solve is exact to with in numerical machine precision.
but teh solver only calcuate the raction or teh moror forces specific by the joints.
after that we need to integrate the body individually.

The Integration is a numerical simimplicit method and as we all know all numerical integration have a numerical error that accumulate over time.
to deal wit that the engione add a small penalty error to thr joint to add some small extra erro correction.
for small moving object the methos work very well, because as long ad the correction forces added but the joint are stronger that the integration error, then teh system is stable.

these can be actully demotarted by calcualtion the Q and R decompsition of any mass matric and cheack the eigen values of every row is less that 1.0
this is how I know if a system will be stable or not.

here is the problem, a vehicle the tire spin really fast, the make that the integration will generate a very large visible error at high speed, but even when going a low speed the error is large enough that accumulate over time.

so for the case of thing liek vehicle, rag doll and oeth articualet bodies that can be expresed in a hiercahy will well pos procces the simulation after in teh postupdate call back with the immodiate solver that will eliminate the position and velocity error afte every step.

so the result now is that teh vehicle will have an erro that will be bounf to one integation step as oposed to the generic method that leave the erro to be deal by teh low lever joint system and what can not be dealt with act as a random small perturvation disrupting the simulation.

anyway I hope this is clear because it is important.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Julio Jerez » Fri Dec 14, 2018 11:45 am

here is lesson two, and this one is not so much for David but for the othe people.
I know it is very tenting to use cylinder or even convex hull shape for tires.
but this is a huge mistake for multiple reasons.
reason one, all macro tire model are base of a tire having a contact point and a contact patch.
It is not until you get to finite element analysis that a tire contact path is model by using few solid pieces in contact with the ground but that is no what we do.

any tire model is base of the following assumption.
1-The tire contact the ground at one point.
2- the tire form a contact patch with the ground that ground the point
3-experiment show that teh side and the pressure on teh pat is proportional to the tire load.
4-It is assume the as the tire start to move some point remain in contact with the ground while some lose the contact.
5- a density distribution is assume teh load over each tire point in teh patch and in the simple brush model is assume to be uniform,
6- the integration of this density determine the ration of point that lose contact to teh point that ar still in contact yeild the tire sleep expression
longSleep = (wr - v)/v and side sleep = vx / vy

with this expression teh tire capacity for longitudinal, lateral and aligning torque can be derive and there are several model for this.

teh secund reason is that say you use a cylinder becaus you think is more accurate, what you get is contact that in most case do no pass but the center of mass of the tire but that instead will be an offset for the tire origin. the will generate an off torque of the vehicle that will add zero contribution to the vehicle vahavior, it will put a lot of stress of the solver for calculate such small offset in teh present of mostly large forces.
and if you do not believe just think what happen when you have misaligned tire in your car, you car steer to one side, teh tire vibrate, and you tire get worm more that they nee to.
well this is the effect that off torque does if you use a shape thet produce off contacts all the time

for that in newton we have the ChamferCylinder, this shape resemble the way old tire were made, they look like a toroid, just look it up in google.

thsi shape give all the benefic of a cylindrical tire and also allow to get the single contact for the tore model whi is based on a single contact point, tire load and friction coeficent.


the secund part is that with an arbitrary with and radius is has to make a change cylinder tire to look good. it is even possible that teh dimensions do not define a shape.

for that what I do is that I made a unit tore shape, and them I apply a no uniform scale that map it to the desired size and width, and sine ther is no a signofoca penalty fo non uniform scale in newton, this work quiet well.
her is the code snipe to do that.

Code: Select all
      // lesson two use a unit CreateChamferCylinder and scale it instead of a variable size one.
      //NewtonCollision* const collision = NewtonCreateChamferCylinder(world, tireRad, tireHeight, 0, NULL);
      NewtonCollision* const collision = NewtonCreateChamferCylinder(world, 0.5f, 1.0f, 0, NULL);
      NewtonCollisionSetScale(collision, 2.0f * tireHeight, 2.0f * tireRad, 2.0f * tireRad);



again this are just optimal best practices, but I do recommended you follow them because vehicle are stiff systems that are hard to keep stable and it is eassy to get over impresses with preliminary result and teh moment you try to drive you get the disappointment.
so the last you wnat to do is adding the possibility of bad force that get amplified out of control with high speed.

In Dave demo I commiet that secudn change in funtion crate tire.

nwo I will move to teh next step to complete the model.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Julio Jerez » Fri Dec 14, 2018 6:00 pm

here is the third trick.

when making the tire for a car or a vehicle that does not need gyro torque to stay up, is better to make the inertia of the tire spherical. this is the will make the last term in the equation
I * a = T - w x (I *w)

w x (I *w) to be zero by design, so that will not produce torque that disrupt the simulation.

Melting Plastic this will apply to you and will go a long way to fix the bending wheel bug.

this is not a cheat, real vehicles that do not drive a high speed can have tires with large radio and non spherical inertia because when w is small, the turn w x (I *w) is small enough that the effect of the vehicle is negligible. vehicles that can travel at medium to high speed deal with the issue by having tires with small radio or tires in which the mass is concentrated in the outer ring so that the inertia is almost spherical. vehicles that drive at high speed like sport cars deal with that by having wide tires that are also almost spherical.
the moral is that for vehicles, try to avoid thin tires, or if you have to have then thin for visual appeal, apply this trick done in the demo
Code: Select all
      // lesson tree make tire inertia spherical to avoid bad gyro torques
      dFloat mass;
      dFloat Ixx;
      dFloat Iyy;
      dFloat Izz;
      NewtonBodyGetMass(tireBody, &mass, &Ixx, &Iyy, &Izz);
      Ixx = dMax(dMax(Ixx, Iyy), Izz);
      NewtonBodySetMassMatrix(tireBody, mass, Ixx, Ixx, Ixx);


with the this I can now complete the game play before moving to the joint error correction part.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby MeltingPlastic » Fri Dec 14, 2018 7:10 pm

Ah ok interesting! I have set the inertia to spherical and that does fix the issue!
MeltingPlastic
 
Posts: 221
Joined: Fri Feb 07, 2014 11:30 pm

Re: Tires popping up on flat terrain

Postby Julio Jerez » Fri Dec 14, 2018 7:50 pm

you see, what the trick does is that it moves the problem to a different domain.
if you have a system that can solve every problem them, that system solve nothing at all.
that's called falsification.

we will do that error projection, but we are going to do for a justifiable reason which is to keep numerical integration error bound not to prevent bad constrain violations.
In the court of public opinion those two thing are equivocated. Even worse people who know these are different things, never correct the equivocation, which to me is the most dishonest position you get from some developers.

every time you hear these expert talking about number on position passes you can just dismiss it because position correction may give fast engine but is not physics,
it you are just try to make a make believe engine, that's another story.

Unfortunally in the court of public opinion, being fast and having lot of money to maintaing a large team, make up for everything.


Try to check out the customer tire collision, see if that fixes the edge bug when going fast over terrain.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Dave Gravel » Fri Dec 14, 2018 9:09 pm

also try to check out the customer tire collision see if that fixed the edge bug when going fast over terrain.


In ut the popping over terrain is present as well too.
You can try to fix it with many configurations but it is always present.
In many cases you can get more problems by trying to setup the world and the scene for get better vehicle physics behavior in ut.
I talk about multibody vehicle tested under ut physics.
I'm not talking about the vehicle manager in ut this one is totally hack full.
The hack full vehicle behave a bit strange but for some game types it is ok.
The good thing from this one it can work with multiplayer.
This manager is surely a sort of raycast vehicle, It behave pretty similar to raycast simulation.
The worse thing the physics in ut have touble to idle good collision for tire shape.
You need to use cylinder or sphere both behaving very strange and you need to deal with it.
I have try to use high quality collision and it don't reacting good at all.

I'm not a expert, ut and the editor is pretty nice in my opinion but i'm not so impressed by the physics.
The nice graphics and effects help a lot to hide many things or make it look more normal.
I love the newton collision result, I don't say all is bad from the other physics systems but from my personal experience newton is very special.
Many physics troubles under ut physics remember me my old experience with the old ode collision result.

I don't try to gain any bonus points by saying this, I have nothing to do with any competitions. :lol:
All of what I do is only for my pleasure.
Any games I playing I become lazy by finding bugs or bad physics result.
I prefer play with newton and my demos and testing physics, It is my global passtime.
Sorry for the off-topic parts... :oops:
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: Tires popping up on flat terrain

Postby Julio Jerez » Fri Dec 14, 2018 10:56 pm

ok David I added a little more control, so far only the throttle, but I do no underhand how the function works

the control in implement in function
virtual void PreUpdate(dFloat timestep, int threadIndex)

it reads the input,
It apply the suspension forces,
the try to apply the input controls (toque, brake and steering)

since you know better how you set it up, maybe you can complete that part while I do the error projection. you can pretend that the error is always zero, do no worry if it fail because it will get it fix. now what we need I the controls, and it should drive even without the projection.

the original code is still there under an #if 0
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Dave Gravel » Fri Dec 14, 2018 11:11 pm

You need to enable the torque on the tire.

After have create the tires joints.
Call SetUseTorque(true); on the tire that you like to have torque.
Same about break and the steer you need to enable it on the tire that you need it.
I have try and it work but it need some tweaks about the torque value.
If the vehicle don't move add more torque or lift it in the air you can see the torque working when you enable it.

Edited:
Currectly because the tireprojection is disabled.
The tire can start to go in any direction at high spin.
Or exemple if the vehicle go fast and you try to turn,
The tire can start to become slowly on the side and wobbling.
Or if you move fast the vehicle in the air with mouse,
The tire can explode or go far of the vehicle body.
The projection is use for fix this in my demo.
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.

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 8 guests