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 JoshKlint » Sat Dec 22, 2018 4:54 pm

...
Last edited by JoshKlint on Sat Dec 22, 2018 8:55 pm, edited 1 time in total.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Tires popping up on flat terrain

Postby Julio Jerez » Sat Dec 22, 2018 6:24 pm

read the pose before meltingPlastic in this thread
viewtopic.php?f=9&t=9352&p=63692#p63692
Julio Jerez
Moderator
Moderator
 
Posts: 10973
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Dave Gravel » Sat Dec 22, 2018 6:26 pm

The tires at high speed in this video don't have the TireProjection, You need to add this part of code in your implementation.

Edited:
Or you need to use the spherical inertia like Julio explain in the post.
I don't have test for this one again.
I comeback to my vehicle implementation soon.
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: 702
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Tires popping up on flat terrain

Postby JoshKlint » Sat Dec 22, 2018 6:56 pm

Thank you so much, that fixed it! I've got it up to 90 MPH now with no wobbling. I think this is doable.



I would like to create a standalone vehicle and player controller to share with everyone in the future.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Tires popping up on flat terrain

Postby Julio Jerez » Sat Dec 22, 2018 9:50 pm

oh cool, How did yo udo it are you projection the tire or did you make the tire inertia spherical.

Dave method, is one that I was suing in the pass, but I Dave can do it because he has more experience in teh physics than the normal using, however that method as simple a sit is has the problem that the user has need a deep knowledge of the engine and demand they made unreadable customization form them.
I do no knwo if you are using a special joint of just normal hinges, and double hinges, etc.
becaus of that I will am adding a funtionality that generalize the error projection, that doe no required the use to have tha knowledge but this function will available as an option to improve the overall quality of teh simulation.
however the vehicle should be reasonable reliable because we start adding that kind of correction.

my following questions are:
1- did you get the special collision using the convex cast for the upper tire hub?
2- are you wrapped you vehicle in a Listener, this is very important for that secund thing I talk before.
3- are you calculation suspension like is in the demo or are you using the slider spring property

these questions are important for having a high quality physic simulation and no a box in four wheel that can be drive around like a toy car. you do no need then right away, but I suggest you make plan for adding them or else your user will come back with many complain.

car are a difficult thing to simulation because all the extreme properties, high mass ration high angual velocities, bodies scraping the ground intead of discrete collsion, and goes on, and on.

anyway afte you get something stable I suggest that, you pay attention to those othe issue and do no do like you always do, leave and then come back when something else goes wrong.

JoshKlint wrote:I would like to create a standalone vehicle and player controller to share with everyone in the future.

I do not know what that means, but I can see you are excited, with the partial result, please pay attention to those othe issue afte the excitement wears out.

the good part is that in the end you will get a vehicle that is fully physically simulated, none of those trick are hacks, these is call physic modeling.
you can argue that even real vehicle do that, jsut drive a car with a heavily misload tire, and check you steering gear vibration. In fact wide tires for race and sport cars have spherical or near spherical inertia because the Gyro torque are a very series problem for the structural design of the car chassis than need to be lightweight.
Julio Jerez
Moderator
Moderator
 
Posts: 10973
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby JoshKlint » Sat Dec 22, 2018 10:42 pm

I have the contacts generation callback sort of working now, but I don't understand the concept of what I am trying to do here.
Last edited by JoshKlint on Sat Dec 22, 2018 11:07 pm, edited 1 time in total.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Tires popping up on flat terrain

Postby Julio Jerez » Sat Dec 22, 2018 10:51 pm

you have to make a material for the tire and terrain, teh in the material you set the callback to overload the engine function, is in the demo
Julio Jerez
Moderator
Moderator
 
Posts: 10973
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby JoshKlint » Sat Dec 22, 2018 11:08 pm

Julio Jerez wrote:you have to make a material for the tire and terrain, teh in the material you set the callback to overload the engine function, is in the demo

I did this. I just don't understand what I am supposed to do in the callback. I have the convex pick working, but what exactly do I do with that? It is producing very bumpy movement.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Tires popping up on flat terrain

Postby Julio Jerez » Sat Dec 22, 2018 11:34 pm

if the function is called from the collision system, then that function calculate the contact point between the tire and the ground. you just set up the way is set in the demo and should work.

the function just make sure that when ethe tire is airborne by a small amount that there is still a continue contact, whi is what case the tire to have tow velocities.
Julio Jerez
Moderator
Moderator
 
Posts: 10973
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby JoshKlint » Sun Dec 23, 2018 2:45 am

This is about the best I can get it right now. When the car drives on concrete the default collision is used. You can see around 20 meters per second it starts to get pretty bouncy. Then it is more bouncy on the terrain. At the end when the car falls on its side, a crash occurs in the Newton DLL:
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Tires popping up on flat terrain

Postby Julio Jerez » Sun Dec 23, 2018 9:07 am

the first thing is to determine of the bumpiness is does to the constrains violations or do to depp penetration.
need to test one at a time.
1-make a larg float floor that is just a simpel square polygon, thsi will rule out the mesh problem for the moement but still let you test the overloaded discrete collision wi the convex cast.

2-make sure the collsion callback is been made, and make the way it is in the demo. notice thet he collsion has a parameter D_MULTIBODY_TIRE_MAX_ELASTIC_DEFORMATION, that is subtacted from the penetartion to gurantee simulate wh aths call tire effective tire radius, or thre tire bristlers
you can see here https://www.youtube.com/watch?v=AOEJaWaM-bs
or any other video or paper.
I se the value to aproximatily 0.05 whi is aproximatly two inched. thi sis important

make sure that working as is should.

3-tell me from the bodies to the tire hwo are you make the model? what joint are you using?
Julio Jerez
Moderator
Moderator
 
Posts: 10973
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby JoshKlint » Sun Dec 23, 2018 12:17 pm

1. I did. It's one big box made of triangles. The custom callback is not being used on the concrete, it is only being used on the dirt / terrain.
  • Chassis mass is 100.
  • Tire mass is 10 each.
  • Dummy body mass is 10 each.
  • Spring value is 2000.
  • Spring relaxation is 0.1.
  • Spring damping is 50.

If I use the contact generation override on the concrete box the behavior is identical. So it would appear to be a problem with using four spring sliders for suspension.

2. Trying to add this code makes my vehicle sink into the ground.
3. The vehicle uses a slider with a spring for the shock absorber, connected to a dummy body (no collision) that is connected to the wheel (chamfer cylinder) with a hinge actuator. The actuator code is modified so the default hinge code is used, since it is not powered. In the case of a steering wheel, an additional dummy body is inserted between the shock body and the wheel with a motorized hinge actuator.

Here's the Newton 2.0 vehicle system from nine years ago. It was so good back then! Why was such a useful feature removed? The behavior here is just perfect, and so stable:



Support for vehicles has just gotten progressively worse. The switch to the convex raycast vehicle created exploding forces and a requirement to box-in the tires to protect the sides, which none of my users understood how to do, and now even that has been dropped and we have no working vehicle for two years. I've been promising people vehicle support in Leadwerks 4.6, and I already missed my Christmas deadline, and this new system I am working on has so many problems that people would laugh at it. I can't even put out an email saying "Hey, check out the upcoming new features" because I am not confident this will work, so I am losing out on the whole Christmas saies season this year.

Code: Select all
static int OnTireContactGeneration(const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonCollision* const collision0, const NewtonBody* const body1, const NewtonCollision* const collision1, NewtonUserContactPoint* const contactBuffer, int maxCount, int threadIndex)
{
   int id0 = NewtonCollisionGetUserID(collision0);

   //const NewtonBody* const tire = (id0 == D_MULTIBODY_TIRE_ID) ? body0 : body1;
   const NewtonCollision* const tireCollision = (id0 == D_MULTIBODY_TIRE_ID) ? collision0 : collision1;

   const NewtonBody* const terrain = (id0 == D_MULTIBODY_TIRE_ID) ? body1 : body0;
   const NewtonCollision* const terrainCollision = (id0 == D_MULTIBODY_TIRE_ID) ? collision1 : collision0;

   // get the joint information form the collision user data
   NewtonCollisionMaterial collisionMaterial;
   NewtonCollisionGetMaterial(tireCollision, &collisionMaterial);
   dAssert(collisionMaterial.m_userId == D_MULTIBODY_TIRE_ID);

   dCustomTireSpringDG* const tireJoint = (dCustomTireSpringDG*)collisionMaterial.m_userData;
   dAssert(tireJoint->GetBody1() == ((id0 == D_MULTIBODY_TIRE_ID) ? body0 : body1));

   dMatrix tireMatrix;
   dMatrix tireHarpointMatrix;
   tireJoint->CalculateGlobalMatrix(tireHarpointMatrix, tireMatrix);

   // here I need the suspension length, for now assume 1 meter
   dFloat suspensionSpan = 1.0f;
   tireHarpointMatrix.m_posit += tireHarpointMatrix.m_up.Scale(suspensionSpan);

   //dVector veloc0(tireHarpointMatrix.m_up.Scale(-m_info.m_suspensionLength));
   dVector veloc0(tireHarpointMatrix.m_up.Scale(-suspensionSpan));
   dVector tmp(0.0f);
   dVector contact(0.0f);
   dVector normal(0.0f);
   dFloat penetration(0.0f);

   dFloat position = tireHarpointMatrix.m_up.DotProduct3(tireHarpointMatrix.m_posit - tireMatrix.m_posit);
   dFloat param = position / suspensionSpan;

   dMatrix matrixB;
   dLong attributeA;
   dLong attributeB;
   dFloat impactParam;

   NewtonWorld* const world = NewtonBodyGetWorld(terrain);
   NewtonBodyGetMatrix(terrain, &matrixB[0][0]);

   int count = NewtonCollisionCollideContinue(world, 1, 1.0f,
      tireCollision, &tireHarpointMatrix[0][0], &veloc0[0], &tmp[0],
      terrainCollision, &matrixB[0][0], &tmp[0], &tmp[0],
      &impactParam, &contact[0], &normal[0], &penetration,
      &attributeA, &attributeB, 0);

   int contactCount = 0;
   if (count) {
      // calculate tire penetration
      dFloat dist = (param - impactParam) * suspensionSpan;

      if (dist > -D_MULTIBODY_TIRE_MAX_ELASTIC_DEFORMATION) {

         normal.m_w = 0.0f;
         penetration = normal.DotProduct3(tireHarpointMatrix.m_up.Scale(dist));

         dVector longitudinalDir(normal.CrossProduct(tireMatrix.m_front));
         if (longitudinalDir.DotProduct3(longitudinalDir) < 0.1f) {
            longitudinalDir = normal.CrossProduct(tireMatrix.m_up.CrossProduct(normal));
            dAssert(longitudinalDir.DotProduct3(longitudinalDir) > 0.1f);
         }
         longitudinalDir = longitudinalDir.Normalize();
         contact -= tireMatrix.m_up.Scale(dist);

         contactBuffer[contactCount].m_point[0] = contact.m_x;
         contactBuffer[contactCount].m_point[1] = contact.m_y;
         contactBuffer[contactCount].m_point[2] = contact.m_z;
         contactBuffer[contactCount].m_point[3] = 1.0f;
         contactBuffer[contactCount].m_normal[0] = normal.m_x;
         contactBuffer[contactCount].m_normal[1] = normal.m_y;
         contactBuffer[contactCount].m_normal[2] = normal.m_z;
         contactBuffer[contactCount].m_normal[3] = 0.0f;
         contactBuffer[contactCount].m_shapeId0 = collisionMaterial.m_userId;
         contactBuffer[contactCount].m_shapeId1 = NewtonCollisionGetUserID(terrainCollision);
         contactBuffer[contactCount].m_penetration = dClamp(penetration, dFloat(-D_MULTIBODY_TIRE_MAX_ELASTIC_DEFORMATION), dFloat(D_MULTIBODY_TIRE_MAX_ELASTIC_DEFORMATION));
         contactCount++;
      }
   }

   return contactCount;
}
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Tires popping up on flat terrain

Postby Julio Jerez » Sun Dec 23, 2018 7:41 pm

if all the questions that I asked the answer is that is if working as expected, then teh last problem that you have is the biggest of all, that can only be solve in one way, faster simulation rate.

basically when you travel at high speed the vehicle which is already a stiff system is now taking a very large step at each simulation time. to solve that you can do this.

you can initialize the engine like this.
Code: Select all
NewtonSetNumberOfSubsteps (m_world, 2);

and that reduce the error by a factor of four, since you can is close to be stable that might just do it.
try that and see how it goes.
this should not change anything else in the rest of your code.

also of teh vehicle in 2.0 been better, no that's simply incorrect. that vehicle was a convex cast car just like the method I am telling you to use.
All vehicles in the engines has used that funtionality, I just exposed in after 1.53 when we went open source but is a feature not one has used expect Walaber whe he made hi vehicle game.

The crash I do not knwo what that is, and I do not what box are you talking about, the convex cast will simple calculate an contact over the a triangular mesh, when the tire is sideway, the contact will be somewhere on the carcass, it should no crash unless ther information pass back is incorrect.

but even if it did sayin it crash does no explain anythong where did it crash?
Julio Jerez
Moderator
Moderator
 
Posts: 10973
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby Julio Jerez » Sun Dec 23, 2018 7:53 pm

also teh spring value of 2000, since too high, that's may be teh reason for the vibrations.
Julio Jerez
Moderator
Moderator
 
Posts: 10973
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Tires popping up on flat terrain

Postby JoshKlint » Sun Dec 23, 2018 8:16 pm

The old vehicle system from ten years ago was perfectly stable at 75 MPH, and it was updating at 60 hz. You can see the speed in the first video. I believe this was using Newton 2.0.

JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron