A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by demon386 » Mon Mar 15, 2010 10:08 am
I'm a undergradaute student from China, and I'm doing my project with Ogre(1.7)+NewtonSDK(2.18)+OgreNewt. I successfully display my car on the screen, and I empower the car by functions SetTireTorque and SetTireSteerAngleForce. But I find the car doesn't stop, which means friction of the ground doesn't work. I have set the value of m_groundFriction to 0.1 when startup. I don't know why, it would be very kind for you to do me a favor.
-
demon386
-
- Posts: 6
- Joined: Mon Mar 15, 2010 9:55 am
by Julio Jerez » Mon Mar 15, 2010 10:26 am
The breaks and the torque are indepndent, are you using the function.
void CustomDGRayCastCar::SetTireBrake (int index, dFloat torque)
if is not expose you can just look at teh code in teh base call and expose it. That should do it
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by demon386 » Mon Mar 15, 2010 10:46 pm
Thanks for your help. But I don't mean brake, I mean the friction between ground and tires doesn't work.
-
demon386
-
- Posts: 6
- Joined: Mon Mar 15, 2010 9:55 am
by Julio Jerez » Tue Mar 16, 2010 12:03 am
If you look at the joint and you see the function
void CustomDGRayCastCar::SubmitConstraints (dFloat timestep, int threadIndex)
you can see that whe the tire torque is set tha function submit a friction row. The code fragmennt tah calculate the brack force is this
- Code: Select all
// Apply brake, need some little fix here.
// The fix is need to generate axial force when the brake is apply when the vehicle turn from the steer or on sliding.
if ( tire.m_breakForce > 1.0e-3f ) {
// save the row err this constrain force is save for later determine the dynamic state of this tire
tire.m_isBrakingForceIndex = constraintIndex;
constraintIndex ++;
frictionCircleMag = tire.m_tireLoad * tire.m_groundFriction;
if (tire.m_breakForce > frictionCircleMag) {
tire.m_breakForce = frictionCircleMag;
}
//NewtonUserJointAddLinearRow ( m_joint, &tire.m_tireAxelPosit[0], &tire.m_tireAxelPosit[0], &chassisMatrix.m_front.m_x );
NewtonUserJointAddLinearRow (m_joint, &tire.m_tireAxelPosit[0], &tire.m_tireAxelPosit[0], &tire.m_longitudinalPin.m_x);
NewtonUserJointSetRowMaximumFriction( m_joint, tire.m_breakForce);
NewtonUserJointSetRowMinimumFriction( m_joint, -tire.m_breakForce);
// there is a longituninal force that will reduce the lateral force, we ned to recalculate the lateral force
tireForceMag = lateralFrictionForceMag * lateralFrictionForceMag + tire.m_breakForce * tire.m_breakForce;
if (tireForceMag > (frictionCircleMag * frictionCircleMag)) {
lateralFrictionForceMag *= 0.25f * frictionCircleMag / dSqrt (tireForceMag);
}
}
You can set a break point on like
- Code: Select all
frictionCircleMag = tire.m_tireLoad * tire.m_groundFriction;
if (tire.m_breakForce > frictionCircleMag) {
tire.m_breakForce = frictionCircleMag;
}
And check that
tire.m_tireLoad, tire.m_groundFriction and tire.m_breakForce, are not zero
if those value set the force to top the cat body in these lines
- Code: Select all
NewtonUserJointAddLinearRow (m_joint, &tire.m_tireAxelPosit[0], &tire.m_tireAxelPosit[0], &tire.m_longitudinalPin.m_x);
NewtonUserJointSetRowMaximumFriction( m_joint, tire.m_breakForce);
NewtonUserJointSetRowMinimumFriction( m_joint, -tire.m_breakForce);
My guess is that soem how, one of thso evalue is too low and tire.m_breakForce is too small to stop the car.
you can add Trace or break point and see which one is wrong
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by demon386 » Tue Mar 16, 2010 1:39 am
OK. I think I get it. I thought the car would slow down naturally without brake, because ground friction will do that, but It seems that in CustomDGRayCastCar I have to set brake to make it slow down anyway.
Thank you very much.
-
demon386
-
- Posts: 6
- Joined: Mon Mar 15, 2010 9:55 am
by Julio Jerez » Tue Mar 16, 2010 8:34 am
ground fritcion do no slowdown a vehicle,
what slow down fritcion is what peopel call rolling resistance, and wind drag.
rolling resistance is a fition values the is generated but the intanal engine and tranmistion friction. you can emulate tha by setting eth break frintion to a minimun value
something like.
m_brake = RollingResistance + PedalValueBrake value.
so when the engine is on idle or Gear the values of the Rolling friction is some small quantity that will slow down the car gradually until it stos,
for example when teh car is in newtral gear the value is the smallest, when in first Gear is the highest if no torque is applied ot the engine
I hope to get teh idea.
with some tweaking it clound be very nice.
The force is the Drag tah limit eh car max speed, an deh I veleiev you cna fidn lot of information how to added to teh car body.
those are the thing that goes into the client application and I rather let the people do it themself.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by demon386 » Wed Mar 17, 2010 5:05 am
Thanks. I will try it. I wonder how do you get experience&knowledge about building this realistic car? I'm reading the source code of CustomDGRayCastCar and even if I have some knowledge about physics in game development, there are still many codes I don't quite understand, and don't know how to fill this knowledge gap.
-
demon386
-
- Posts: 6
- Joined: Mon Mar 15, 2010 9:55 am
by Julio Jerez » Wed Mar 17, 2010 7:54 am
the thing tay contrary to Lagragian constrained Dynamics whne ther si a Theretical framework to work out solutions,
car and player controller logic is part of modeling, there are not mathematicaa or physics framework that say these are the step to make a car.
this is because all laws are empircal and not theoretical, so every one is free to do the way it shuses.
the more practices you have the better result you get.
you do not really have worry too much about not getting what is writing in that code or any code you find on the Net open source or not,
most of the stuff have very little theoretical value beyond what was in the mind of the person who wrote it.
In time you learn to do your own stuff and you will see that you can do the same too.
I try to provide a good solution that people can plug in stuff in, a move from there.
By enlarge most part of the Raycast car were writen by David Gravel which I found very good but difficul to tune.
so I added the part that uses the Tire curves to make setting it up more in tune with realistic Car values.
In newer version of newton I will make more finish so people do get to start with a better car model that there is now.
for example I will add the Engine resistance Drag the way I explained you as a parameter.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by demon386 » Thu Mar 18, 2010 8:42 am
I find the car can be easily sliding when running.
I use SetTireToruqe to acclerate, and SetTireSteerAngleForce to make turning. Am I doing anything wrong? Can you give me a example of using CustomDGRayCastCar?
-
demon386
-
- Posts: 6
- Joined: Mon Mar 15, 2010 9:55 am
by demon386 » Thu Mar 18, 2010 9:13 am
I reduced the quantity of applied torque and angle, it becomes stable, but not as stable as I expected, especially when it acclerates and turning at the same time.
-
demon386
-
- Posts: 6
- Joined: Mon Mar 15, 2010 9:55 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 0 guests