Vehicle model for 3.14

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Vehicle model for 3.14

Postby Julio Jerez » Fri Apr 01, 2016 1:28 pm

as you gotten later?
I still have one more weekend to go, but I was able to drive this morning.
this weekend will do the final adjustment to plug the drive train to the tire.
At the moment the power only flow form engine to tire, but no form tire to engine.
I am very happen with result I am getting. I am capering result with actually engine chard form real Viper.

Any one be patient, one more weekend and you can start beating me over the head.
This vehicle model will be the best that Newton has to offer yet, believe me.

It is going to be inspected by ms Vito, and trust me she knows everything there is to know about cars.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicle model for 3.14

Postby Julio Jerez » Fri Apr 01, 2016 2:21 pm

collerblade wrote:Any progress on this?
I tries engineControl->SetIgnition(true) , but didnt works.
(my vehicle worked a month ago)


Yes I know I am sorry, but I needed to make a big change to the engine drive train.
It is just not possible to simulate very small part component that spins a very high rpm, together with very massive body parts, that move slowly using a reduced coordinate system solver like Newton uses.
The mass matrix mass ration are of the order of several thousands, and the solve just not converge.
So I wrote by hand a generalize coordinate system solver to model the:
Engine/clutch/gear box/differentials/tire drive train of a vehicle.

The newton solver always calculate a smoggy power on the tire regardless of engine torque an gears.
Now the response is quite snappy as it should be if we want( it can do tire burn out in lower gear :mrgreen: ), but it needs adjustment.
What you get is that the engine is not getting the feedback from the tire, because I have no couple that part yet.
I have all completed now, I just need to plug it into the vehicle and see how is works.

I started to do that yesterday, but I do not have much time to work long hours.
A cool thing about this is that is possible to design the engine separate from the car, we can now make for example the engine of a Ferrari and plug it into a ford a monster truck an so on.

anyway in you side all you nee to do is made the change to initialized the new Vehicle engine control class and it would run fine.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicle model for 3.14

Postby Julio Jerez » Sat Apr 02, 2016 8:25 pm

Ok guys now I have a drivable car.
It is no tuned at all, and I still has no plug the tire torque to the tire, but you can see what I mean by having a proper drive train.

Now I will complete the coupling with the collision system and also make so the each vehicle by design is about 5% under steering , but we are getting very, very close now.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicle model for 3.14

Postby Shaderman » Sun Apr 03, 2016 2:22 am

Impressive work Julio, I love it already :)
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: Vehicle model for 3.14

Postby Julio Jerez » Sun Apr 03, 2016 8:06 pm

cool! 8)
glad you like, I now added all the work related to the vehicle drive train, including a working the slip differential. I am very satisfied how is turning out.
It may no seem lie a big deal, but one of the effect of the slip differential and that the vehicle does not loses as much speed when you turns as is does when there is not differential.
people think that the way for fix that is by adding Ackerman angle, but each time I try that I still lose a lot speed, with the differential the lost is much less.

anyway please try again see how does is feel for you now.

I now have to work the tire collision, I have to do a better job there, some time seems to do some random jump.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicle model for 3.14

Postby AntonSynytsia » Sun Apr 03, 2016 8:26 pm

Just tried the demo - quite impressive, Juleo.
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Vehicle model for 3.14

Postby Julio Jerez » Sun Apr 03, 2016 11:30 pm

I just checked in a polishing fix, now when the tires hit the upper suspension stops, they apply the proper impulse to the car body, as opposed to before that they were stopped by a huge spring compression.
Now the car when you hit a large bump at high speed, it can flip over but does it in a familiar way.
The end user can change that by adding forces to prevent role over.
Now I move on to continue getting all the collision problems fixed, but I think we are close to the final now.
After done I see if I can make a monster truck demo.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicle model for 3.14

Postby Shaderman » Sun Apr 03, 2016 11:34 pm

This feels even better now and very realistic IMO. Great job Julio!
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: Vehicle model for 3.14

Postby Julio Jerez » Tue Apr 05, 2016 9:58 am

JoeJ wrote:In other demos if i pick a body and drag it into floor it might jitter, or go through the floor.

But the big 'debris balls' in Compound collision shape demo behave really wired.
Lets say those balls have a diameter of 4 m.
I lift one up 2m.


oh I now see what the problem is Joe. The new improvement to collision system, calculate contact on a local space the is common to both shape, this trick simply the contact calculation a great deal because mu using a common space, the scaling to not have to be convert form one space not the local space of the other shape, so the collision unify for all scaling types, and is also a lot simple to follow, or so I thought.
here is comes the problem. this is not true for compound collision, each child shape of a compound has his own local space.
that should no be a problem until the code hit the contact discrinmation routine.
compound collision can generate hundreds of contacts, but the solver has a hard limit of 16 contact, so some how the contact has to be reduce , and that the problem each time the contact reduction routine is called is mixes contact that are in daren't spaces. that why the contact look out of place

here is a list of the contact when the ball fall on a flat floor at height 0.
    {133.384979, -0.0971130431, 136.648407, 1.00000000}
    {133.707428, -0.149250939, 136.056335, 1.00000000}
    {133.771210, -0.149250984, 136.519318, 1.00000000}
    {133.806702, -0.117204279, 136.190582, 1.00000000
    {134.133011, -0.117204309, 135.945206, 1.00000000}
    {134.492050, -0.0846464038, 138.480392, 1.00000000}
    {134.571793, -0.0846465528, 138.686020, 1.00000000}
    {134.583893, -0.00336754322, 134.047974, 1.00000000}
    {134.857162, -0.000746428967, 133.958084, 1.00000000}
    {135.305237, -0.191960990, 134.790695, 1.00000000}
    ..

those are contacts produce by different sub shapes, and as you can see they all has different height.
buy since I know the high should be zero because the ground is at 0, that contacts list is made of contact that are on different spaces.
I believe that the bug, and explain the jumping behavior.
I do some more test before making that change,
because I want to keep is unified pile line for all collision routines.


I can fix in tow ways.
1- wrap the compound with a transform matrix the make the shape to be on eh same space.
2-move the contact reduction routines to after al contacts are calculated and the do the contact reduction
both option are valid, and I will probable have to do both.
option one I like because is insulated to the compound only.
option tow I also like it because am planning on a better contact reduction routine, the one I am using is OK but I belibe I can write a better one.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicle model for 3.14

Postby JoeJ » Tue Apr 05, 2016 12:06 pm

I still believe it should work to use only one contact between 2 bodies in any case.
In my own engine it worked, but i made my life a bit easy:
Initially i've used only particles with position and mass, together with verlet integration and joints.
Later i added orientation to particles, but still no inertia - the single contact method worked for both cases.
To make a capsule, i connected two particles with a distance joint and gave this line a radius for the capsule collision (that way i've got the effect of inertia as a side effect, without specifying it explicitly).

However - the interesting thing is this:

I was able to simulate a large stable stack of capsules with only one contact between each (no symetric arrangement necessary).
It kept stable when droping additional bodies on top - left, right or center - did not matter.
Worked exactly as well as using two contacts between the capsules (better for me but that's not relevant here.)

The math was, assuming we measure the 2 typical contacts between two capsules:
Find a point to apply seperation force, so that both contacts would have zero intersection at the same time (Resulting in parallel capsules if we think only 2D.),
and generate single contact at this point.

Now back to the stack example, imagine we have a stack of some equally sized capsules in 2D.
The contacts would settle exactly at the vertical line through the center of mass of the bodies.
Now we drop a smaller body on top of the very left side, assuming the stack becomes unstable.
There is more intersection on the left side of the stack after some timesteps.
This causes the contacts to move to the left side too, and the system stabilizes itself at the same rate as a multi contact model.


I'm pretty sure this can be done for a more advanced engine with more physical properties.
(e.g. you could use contact forces instead of intersection for weighting)

I'm not sure if it can handle friction properly - for me it did, but my friction model was wrong in general.

What do you think?

EDIT:
Shortly i realized, the correct position of a single contact point would be the volume center of the intersection volume from two bodies - assuming uniform density but allowing concave shapes with multiple contact regions?
Using intersection distance is an approximization that worked well enough for me.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Vehicle model for 3.14

Postby Julio Jerez » Tue Apr 05, 2016 1:14 pm

single contact? and Verlet? how that come about?
Not I do not want to go back to those days.
The engine should handle multiple contacts, this is a bug that need to be fixed, that's all.
I revisit the compound collision function and the bug does no seem to be there, and the contact reduction is no the guild party.
this seem to be a bug in one of the collision shapes that is use in making the sphere of compound
I will modified the demo, so that the I can test compound of similar shapes until I reproduce the bug.
there seem to be a bug in one of more of the shapes.

I check in a test demo that place sphere around a large spherical compound, the distribution is uniform, so the contact generation should be one may tow or thee, and they pass very close to the center of the compound.
I think that demo is close you what you describe in turn of the contact count.

even that simplified demo reproduce the bug, so there must be some run some where else.
I should be able to find what is going on with this simpler repro demo.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicle model for 3.14

Postby JoeJ » Tue Apr 05, 2016 1:58 pm

What i mean is not related to the actual bug or the integration menthod (i've used verlet bacause it's simplicity).

It is about: If a single contact between any pair of bodies results in the same (or better) simulation,
it would be the ideal contact reduction routine, and also a huge performance win.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Vehicle model for 3.14

Postby Julio Jerez » Tue Apr 05, 2016 2:31 pm

JoeJ wrote:It is about: If a single contact between any pair of bodies results in the same (or better) simulation,


I am confused, how could a single contact make better simulation. Imagine a box landing flat on a plane, in theory a single contact passing thought the center will make stable, but only if the total linear and angular moment is zero.

here is where fundamental of principles of analytical mechanic apply.
for a close system to be stable is need to recover form a small perturbation.

in the case the box and the floor is a close system. The way you define the system by the total energy on the system (kinetic and potential) the sum is call the Lagrangian and is a quadratic function

since this is a quadric function it mean that a system can have an equation point, which is the point at with the derivative become zero.

however the lagrangian can be a parable point up or a parable appoint down.
the lagrangian point up if any perturbation away form the equilibrium point increase the total energy
and it point down if is decrease the energy.

in you example of only one contact. if you apply any notch to the box the box acquire liner and angular keener energy while the potential energy gone down, this mean the all element of the lagrangian are positive and the total energy increases. this is a extreme unstable system.

if you have a set of contact that surround the center of the box, the any notch to the box will make the box pivot around one contact which means the potential energy will decreases,
this mean that as along as the potential energy increase faster than the kinetic energy, the system is stable and will reach equilibrium.
This is why you a sufficient number of contacts to make thee system stable.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicle model for 3.14

Postby JoeJ » Tue Apr 05, 2016 4:58 pm

I was confused too when i saw how good it worked.
Giving an notch to a box would cause the contact point to oszillate over the contact region,
improving stability each step. That's what happened to my stack of capsules, which is a harder testcase than a single box.

Julio Jerez wrote:This is why you a sufficient number of contacts to make thee system stable.

No matter how many contact points you use - it's always possible to calculate a single force and a single point of application that has the same affect, right?
So the question is: Is it possible to calculate this fast and accurate enough to be a win?

Actually, balancing the inverted pendulum is also related. Here the answer to a similar (or equal?) question is the Zero Moment Point, discussed in another thread.
When i hacked Newton to generate my own contact, again i was surprised this worked much better than trying to calculate ankle torque for the same result. Today i know my ankle torque math was not quite right, but i can confirm it is easy to balance a ragdoll with a single contact. It's also easy to bring it to rest, upright - with this single contact *).
And yes, the contact oscillates over a small region until it comes to rest here too.

Beside the volume intersection, also the physical state of the bodies will influence the desired contact point. But if known state from previous step is good enough it should work, improove performance and - in the best case - stabilty too.
(In my case measuring intersection seemed to reflect physical state well enough)

It's just an idea sticking in my head for a long time - maybe you can make some use of it some day 8)


*) The problem with the single contact is: There is no friction preventing rotation around the contact normal. This would require special care - i will try this again for the ragdoll somewhen (awaiting the usere contacts you plan to add).
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Vehicle model for 3.14

Postby Julio Jerez » Tue Apr 05, 2016 5:24 pm

JoeJ wrote:No matter how many contact points you use - it's always possible to calculate a single force and a single point of application that has the same affect, right?
So the question is: Is it possible to calculate this fast and accurate enough to be a win?

no, that statement is incorrect.

it is one thing that the force and torque generated by each contact amount to a net force and at one contact. But that does not account for the trajectory that the rigidly follows.
The trajectories are very different, the one made by a single contact will have common points with the one generate by the proper set for contacts. but will be more wavy.
The idea of using one contact came from the people who are trying to invent brand news laws of physics to be fast, but that has nothing to do with the laws of analytical mechanics.

When i hacked Newton to generate my own contact, again i was surprised this worked much better than trying to calculate ankle torque for the same result.

actually there is a new feature in newton that let you do that, NewtonMaterialSetContactGenerationCallback I use for the vehicle
Code: Select all
   // create a tire material and associate with the material the vehicle new to collide
   for (int i = 0; i < materialCount; i ++) {
      NewtonMaterialSetCallbackUserData (world, m_tireMaterial, materialsList[i], this);
      if (m_tireMaterial != materialsList[i]) {
         NewtonMaterialSetContactGenerationCallback (world, m_tireMaterial, materialsList[i], OnContactGeneration);
      }
      NewtonMaterialSetCollisionCallback(world, m_tireMaterial, materialsList[i], OnTireAABBOverlap, OnTireContactsProcess);
   }

that let you overwrite the function that calculates the actual contact points, you can try that and you do not need to hack the engine. then you can have the best of all world.

The problem with the single contact is: There is no friction preventing rotation around the contact normal. This would require special care - i will try this again for the ragdoll some when (awaiting the usere contacts you plan to add).

yeah that's just one problem and if that was the only one, believe I would try, this is the one issue that make newton slower than other engines.
The most serious one is the stability which has not way to solve it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 14 guests