Vehicle with CustomJoint.

Share with us how are you using the powerrrr of the force

Moderator: Alain

Postby DarthPhysics » Tue Mar 25, 2008 10:05 am

cool demo :D
the tires grip alot !! , and suspension are like real ....
And as you say it's ''cheap'' , i'm impatient to see the ''costly'' :wink:

cya :D
The theory is when we know all but nothing work.
The practice is when everything work but no one know why. <- that is me :) without the 'everything work'
User avatar
DarthPhysics
 
Posts: 44
Joined: Sun Apr 23, 2006 8:57 pm
Location: Boulay-Moselle , France

Postby Dave Gravel » Tue Mar 25, 2008 11:55 am

Julio Jerez

The wheel are so big and heavy than when turning the distance that a wheel in one side of the axel travel in very different that the distance that the wheel in the other side travel, that is why they react funny when turning.

Yes the slip can help.

I think I can help to fix this problem by adding more parts on the black compound base.
Exemple currently the wheels is connected to the compound black shaft.
This shaft have 15 degre and the wheels connection is not 100% right because this 15 degre and the shaft scale.
I'm not sure if i'm right because I don't have test,
I think If I add exemple a compound box on the end of this shaft without degree and if I connect the wheel on this box part.
I think the wheel can reacting better and come more solide.

Thanks DarthPhysics.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Postby Dave Gravel » Tue Mar 25, 2008 12:02 pm

You can see with this screenshot.
The little red box inside the wheel is the slider spring with the wheel joint.
Now I can see it have some distance surely the distance don't help so much.
I think If I add a box without degre on the end where the wheel connecting it can surely help more.
And If I remove the distance too.

http://orionx3d.googlepages.com/exemplwhl.jpg
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Postby Julio Jerez » Tue Mar 25, 2008 1:02 pm

so those boxes are connected to the truck chassis, and the wheel are connected to the box.
If you check the tank demo in the SDK, it implements a sliding contact joint.
That joint allow for sliding and rotations.
Is has upto 7 dog if both bummer hi the stops. rut is only used 5 dog when free rolling and sliding.
If you use that joint you can save one joint per axle and have a more realistic model of a monster truck.

I am very excited about this. :D
I will take a page form Master K00m model and map the current car joint in 1.53 to his implementations.

So what is coll about is that people will have the code, and features like axles and more suspension setups will be possible. Also flat tire and car damage will be very easy to implement.

This will be in the house in next beta along wit teh finish ray cast car.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby Dave Gravel » Tue Mar 25, 2008 1:05 pm

If you have times Julio take a look on this demo.
http://orionx3d.googlepages.com/Basic_MonsterTruck2.zip

I have change the debug lines mode and you can see more how it working.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Postby Julio Jerez » Fri Mar 28, 2008 12:21 am

Master K00m this post is to let it you know that I was playing the subaru demo.
And I have to say that I am extremely impressed.
This is with out a doubt that more realistic car simulation I have ever seen with a physic engine.
I do not think that the car joint in 1.53 can come even close.
I recommend every one trying driving and stay in the row, I think is can gor really fast, the handliying feels wonderfully at very high speed.
I was experting to become unstable but it does not but any mean.
This is awesome

you going to have to tell me what is you secrect.
hwo do you se the material an dteh frition at the tires, because this is too good to let it go.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby Dave Gravel » Fri Mar 28, 2008 12:50 am

This demo have nothing special.
In the demo code I set material on all wheels but it is not take in concideration.
Because in my dll it is not actived for this demo.

This demo use only the manager material surface and the friction is set to 1.6, 1.6.
If you reverse the car on the top you can see the 1.6, 1.6 friction is really effective on the body and the wheels use this value too.
Now I have rework a new wheels system and now I can control material surface on all parts.
The subaru demo don't have this update and it is set to 1.6, 1.6 on all.

The only secret that I have is the engine framerate is set to 100 hz but it is not really a secret, with the 1.53 I need to use similar value at high speed.

In the subaru demo i'm not happy about the acceleration and about the break system, and I have set the suspension so smooth.
The track too have some triangles problem in some curves it don't help the vehicle to go good.
I don't really have get the time to work on it because I have work a lot on my real job.
Now my new wheels system is finish I think to finish the acceleration system this week-end.
I can remake the subaru demo with the new system this week-end to see if it working better.
If you like I can write this demo with some comments in the code to explain all value in use...
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Postby Leadwerks » Fri Mar 28, 2008 2:43 am

Julio, if you want to send him my monster truck, go ahead. Just put something in a text file whenever you distribute it saying it is property of Leadwerks Software.

The tires grip really well, and it feels more realistic than the buggies I made with Newton 1.53.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Postby Julio Jerez » Fri Mar 28, 2008 11:35 am

Ok Master K00m now I am the apprentice and you are the Master.

I am writing the implementation if the car joint in 1.53 as a custom joint
This is what OI have so far,

Code: Select all
class CustomMultiBodyTire;
#define MULTI_BODY_VEHICLE_MAX_TIRES   16

class JOINTLIBRARY_API CustomMultiBodyVehicle: public NewtonCustomJoint 
{
   
   public:
   CustomMultiBodyVehicle(const dMatrix& chassisMatrix, const NewtonBody* carBody);
   virtual ~CustomMultiBodyVehicle(void);


   void AddSingleSuspensionTire (void* userData, const dVector& localPosition,
                          dFloat mass, dFloat radius, dFloat with,
                          dFloat suspensionLength, dFloat springConst, dFloat springDamper);

   int GetTiresCount() const ;
   const NewtonBody* GetTireBody(int tireIndex) const;

   dFloat GetSpeed() const;
   virtual void SetTorque (dFloat torque);
   virtual void SetSteering (dFloat angle);


   protected:

   virtual void SubmitConstrainst (dFloat timestep);
   virtual void GetInfo (NewtonJointRecord* info) const;


   int m_tiresCount;
   CustomMultiBodyTire* m_tires[MULTI_BODY_VEHICLE_MAX_TIRES];

   dMatrix m_localFrame;
};

Here is the code


Code: Select all
#define MIN_JOINT_PIN_LENGTH   50.0f
class CustomMultiBodyTire: public NewtonCustomJoint 
{

   public:
   CustomMultiBodyTire(const NewtonBody* hubBody, const NewtonBody* tire)
      :NewtonCustomJoint(5, hubBody, tire)
   {
      dMatrix pinAndPivotFrame;
      NewtonBodyGetMatrix(tire, &pinAndPivotFrame[0][0]);
      CalculateLocalMatrix (pinAndPivotFrame, m_localMatrix0, m_localMatrix1);
   }

   ~CustomMultiBodyTire(void)
   {
   }

   void GetInfo (NewtonJointRecord* info) const
   {

   }

   void SubmitConstrainst (dFloat timestep)
   {
      dMatrix matrix0;
      dMatrix matrix1;

      // calculate the position of the pivot point and the Jacobian direction vectors, in global space.
      CalculateGlobalMatrix (m_localMatrix0, m_localMatrix1, matrix0, matrix1);

      // Restrict the movement on the pivot point along all tree orthonormal direction
      NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix0.m_front[0]);
      NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix0.m_up[0]);
      NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix0.m_right[0]);

      // get a point along the pin axis at some reasonable large distance from the pivot
      dVector q0 (matrix0.m_posit + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH));
      dVector q1 (matrix1.m_posit + matrix1.m_front.Scale(MIN_JOINT_PIN_LENGTH));

      // two constraints row perpendicular to the pin vector
      NewtonUserJointAddLinearRow (m_joint, &q0[0], &q1[0], &matrix0.m_up[0]);
      NewtonUserJointAddLinearRow (m_joint, &q0[0], &q1[0], &matrix0.m_right[0]);
   }

   dMatrix m_localMatrix0;
   dMatrix m_localMatrix1;
};




CustomMultiBodyVehicle::CustomMultiBodyVehicle(const dMatrix& cordenateSytem, const NewtonBody* carBody)
   :NewtonCustomJoint(3, carBody, NULL)
{
   dMatrix tmp;
   dVector com;

   m_tiresCount = 0;

   NewtonBodyGetCentreOfMass(m_body0, &com[0]);
   com.m_w = 1.0f;

   // set the joint reference point at the center of mass of the body
   dMatrix chassisMatrix (cordenateSytem);
   chassisMatrix.m_posit += chassisMatrix.RotateVector(com);

   CalculateLocalMatrix (chassisMatrix, m_localFrame, tmp);

}

CustomMultiBodyVehicle::~CustomMultiBodyVehicle(void)
{
   // the joint do not need to be destroyed because the joint destructor takes care of that

   m_tiresCount = 0;
}


void CustomMultiBodyVehicle::SubmitConstrainst (dFloat timestep)
{

}

void CustomMultiBodyVehicle::GetInfo (NewtonJointRecord* info) const
{

}


void CustomMultiBodyVehicle::SetTorque (dFloat torque)
{
}

void CustomMultiBodyVehicle::SetSteering (dFloat angle)
{

}

int CustomMultiBodyVehicle::GetTiresCount() const
{
   return m_tiresCount;
}

const NewtonBody* CustomMultiBodyVehicle::GetTireBody(int tireIndex) const
{
   return m_tires[tireIndex]->GetBody1();
}


void CustomMultiBodyVehicle::AddSingleSuspensionTire (
   void* userData,
   const dVector& localPosition,
   dFloat mass,
   dFloat radius,
   dFloat width,
   dFloat suspensionLength,
   dFloat springConst,
   dFloat springDamper)
{
   dFloat Ixx;
   dFloat Iyy;
   dFloat Izz;
   dMatrix carMatrix;
   NewtonBody* tire;
   NewtonWorld* world;
   NewtonCollision *collision;

   world = NewtonBodyGetWorld(GetBody0());

   // create the tire RogidBody
   collision = NewtonCreateChamferCylinder(world, radius, width, NULL);

   //create the rigid body
   tire = NewtonCreateBody (world, collision);

   // release the collision
   NewtonReleaseCollision (world, collision);   

   // save the user data
   NewtonBodySetUserData (tire, userData);

   // set the material group id for vehicle
   NewtonBodySetMaterialGroupID (tire, 0);
//   NewtonBodySetMaterialGroupID (tire, woodID);

   // set the force and torque call back function
   NewtonBodySetForceAndTorqueCallback (tire, NewtonBodyGetForceAndTorqueCallback (GetBody0()));

   // body part do not collision
   NewtonBodySetJointRecursiveCollision (tire, 0);

   // calculate the moment of inertia and the relative center of mass of the solid
   dVector origin;
   dVector inertia;
   NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);   
   Ixx = mass * inertia[0];
   Iyy = mass * inertia[1];
   Izz = mass * inertia[2];

   // set the mass matrix
   NewtonBodySetMassMatrix (tire, mass, Ixx, Iyy, Izz);

   // calculate the tire local base pose matrix
   dMatrix tireMatrix;
   tireMatrix.m_front = m_localFrame.m_right;
   tireMatrix.m_up = m_localFrame.m_up;
   tireMatrix.m_right = tireMatrix.m_front * tireMatrix.m_up;
   tireMatrix.m_posit = localPosition;
   NewtonBodyGetMatrix(GetBody0(), &carMatrix[0][0]);
   tireMatrix = tireMatrix * carMatrix;

   // set the matrix for both the rigid body and the graphic body
   NewtonBodySetMatrix (tire, &tireMatrix[0][0]);


   m_tires[m_tiresCount] = new CustomMultiBodyTire (GetBody0(), tire);
   m_tiresCount ++;
}


As you can see it is a hierarchy of rigid joint, and is contain the rigid body if the tire in an array.
I have not porter the code for the Car joint callback yet, but basically what that does is to correct any matrix miss alignments of the tire, but you did do that so let us see if we can make with new Newton without any correction.

I will complete these a little more and I will send it to you so that you do you magic, on it.
I all add the ability to have axels, and differentials, for car like big wheel.

Ha I am using the Leadwerk Monster Truck, so you will get that as well.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby Dave Gravel » Fri Mar 28, 2008 1:42 pm

In the day I can just read the code.
Tonight I try it.
In 4 or 5 hours I try to make something with it and I let's you know.
Thanks you too to share this part of code.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Postby Julio Jerez » Fri Mar 28, 2008 1:59 pm

It is not rush, in fact wait for the next SDK. I still have to add few
features.
I am dying to add a feature I promosed in 1.53 but that I never did.
wheel single axels.

I will have the SDK ready tomorrow, and you can check it out.
This feature will be very good for many people making advance car simulations with complex suspensions.

It is amasing how simpler is to make the car like that than using the Raycast.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby Dave Gravel » Fri Mar 28, 2008 2:17 pm

Yes I have think to some idea like this about raycast and solver 1.
The only place where I coming jammed is with the wheels collision and make it behav correctly.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Postby Julio Jerez » Fri Mar 28, 2008 2:45 pm

I was playing the subaru demo with the linear solver, and it is quite solid.
The problem is that the front tires do not turn eassy because joint motor are not as reponsive in teh lieanr solver as they are with teh exact solver. But thist is a small problem is the joint code that I need to fix.

If I fix that that then cars will be fun to drive in both modes, linear an exact.
I beleive that in linear solver maybe running at 120 or 160 fps will make up fo the sof joints.
there is a lot of fabric to work on this. so this is very good.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby Dave Gravel » Fri Mar 28, 2008 3:15 pm

I have make some personal test in the pass about it (: hehe
I'm able to make the front wheels more solide with solver 1.
In my test I have remove the steer angular row and I have cheat with apply omega value directly.
It working pretty good and better but the problem the rear wheels coming wrong and it is not able to follow and stay at good position.
When the vehicle turn the rear wheel get big angular error.
Surely with solver 1 the best stay raycast solution.
In solver 1 the suspension working pretty good, it is more smooth but working not bad.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Postby Julio Jerez » Fri Mar 28, 2008 3:41 pm

k00m wrote:I'm able to make the front wheels more solide with solver 1.
In my test I have remove the steer angular row and I have cheat with apply omega value directly.

That is quite legal in new newton, It was not in 1.53 because the velocities where cached before the solver, so setting velocity from a call back had not effect because the integration will overrid then after the solver.
now they are kept in the body and they is not caching. so setting velocity, force and position is fine in Archemedia, but you need to know what you are doing to get meaninful results.

k00m wrote:the problem the rear wheels coming wrong and it is not able to follow and stay at good position.
When the vehicle turn the rear wheel get big angular error.


that is what the car joint does, it posprocces the tires after the solver phce to make sure the the velocities and position error are removed after the solver face.
with the custom joints this can be fixed very eassitly after each simulation step. It can be done conditinally like this

if (linearsolvemode) {
applyPostcorrection ().
}

for that the new joint inteface have thsi funtion

NewtonUserJointSetFeedbackCollectorCallback (const NewtonJoint* joint, NewtonUserBilateralCallBack getFeedback);
that we can use to do the correction

But let us not worrie to much now and let me get the framework working
The importan thing is that it is suffiently robust that, that small that we can make work by using small adjustments.
I was expecting to be completly usesless so I am happy.

In teh end teh engine wuill have both solutions
RaycastCar and MutibodyCar

what is good about this is that making the Muttibody car I can get pointers to finish the raycast car. an dwe can see where ther are similar and where they are different.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to User Gallery

Who is online

Users browsing this forum: No registered users and 16 guests

cron