RayCast Vehicle Problem

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: RayCast Vehicle Problem

Postby Stucuk » Mon Apr 19, 2010 3:10 am

I decided to see what would happen if i introduced a Heightmap. Car rolls down the heightmap(Made it like a ramp). But if i use DGRaycastVehicleSetCustomTireTorque on the tires i can make the car climb the heightmap. So it makes no sense to me why the raycast car uses the DGRaycastVehicleSetCustomTireTorque's force when the car is sliding down a hill, but when its stationary it seems to ignore it.

Demo:
- RayCastCar_Climbs.rar ( Once running click on "Add Car", then on "Un Pause".)

EDIT: Ok this is truely wierd.... If i drop a sphere on the car when its on flat ground, it then begins to move. Before the sphere dropping on it, it won't move. Once the car is moving it doesn't stop.

- RayCastCar_NoMove.rar ( Once running click on "Add Car", then on "Un Pause". Then click "Add Sphere")
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: RayCast Vehicle Problem

Postby Dave Gravel » Mon Apr 19, 2010 4:38 pm

You don't have forget to set your chassis to unfreeze mode ?
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: 801
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: RayCast Vehicle Problem

Postby Stucuk » Mon Apr 19, 2010 4:57 pm

Note: Car.Body is what is sent to DGRaycastVehicleCreate.

Render Loop:
if Assigned(Car) then
begin
DGRaycastVehicleSetCustomTireTorque(Car.DGCar,0,-500);
DGRaycastVehicleSetCustomTireTorque(Car.DGCar,1,-500);
DGRaycastVehicleSetCustomTireTorque(Car.DGCar,2,-500);
DGRaycastVehicleSetCustomTireTorque(Car.DGCar,3,-500);

NewtonBodySetFreezeState(Car.Body,0);
end;
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: RayCast Vehicle Problem

Postby Julio Jerez » Mon May 03, 2010 9:50 am

Ok I will check this out, and see what it is.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: RayCast Vehicle Problem

Postby Julio Jerez » Mon May 03, 2010 10:01 am

Stucuk wrote:I decided to see what would happen if i introduced a Heightmap. Car rolls down the heightmap(Made it like a ramp). But if i use DGRaycastVehicleSetCustomTireTorque on the tires i can make the car climb the heightmap. So it makes no sense to me why the raycast car uses the DGRaycastVehicleSetCustomTireTorque's force when the car is sliding down a hill, but when its stationary it seems to ignore it.
- RayCastCar_Climbs.rar ( Once running click on "Add Car", then on "Un Pause".)


Ok I got this demo, when I clip add car, a rectangular Box pop in the air, when I click unpause, it drop and start to roll slowtly.
what I am support to do?

I did not get you comment about the DGRaycastVehicleSetCustomTireTorque's, are you saying that the you are adding torque but the car does not move?
Can I drive it, I am at lost with the demo. Maybe you can clarify more for me.

In the mean tiem I did find a crash Bug. I will see what is that all about.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: RayCast Vehicle Problem

Postby Julio Jerez » Mon May 03, 2010 10:31 am

Stucuk are you running Newton is a Separate thread, whne teh Game crash I cna no debug it because I get a confuse stack tha aways point to teh Netwon Update.
When I drop a Ball and then a Car it aways crash but I cna not get teh funtion where it crashes.

Anyway I still do not know what the problem is, if you can explain
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: RayCast Vehicle Problem

Postby Stucuk » Mon May 03, 2010 3:36 pm

Everything is running in a Single Thread. The "Box" is the car and you can't control it. The car climbing one was showing that the car works on hills.

are you saying that the you are adding torque but the car does not move?


When the car is on a flat plane, it doesn't move when torque is sent using DGRaycastVehicleSetCustomTireTorque (I re-enabled it in the Joint Library my app uses). But when its on a slope, it works fine. It only moves on a flat plane when an object hits it.

When I drop a Ball and then a Car it aways crash but I cna not get teh funtion where it crashes.


"Access violation at address 10062D2D in moduel 'Newton.dll'. Read of address 0000009B" is what Delphi's Debugger is returning. Only happens with a Heightfield, using a cube instead doesn't give any violation. Oddly the application just crashes without reporting any error... (Normally Delphi Applications would display the message). I don't know if This will help, its the CPU Stack thingy(I never use it) in Delphi showing the memory location.



Try the following demo. You just need to click on "Add Car". Then wait and press "Add Sphere". Until the Sphere hits the car it won't move on the flat plane.

- RayCastCar_Test.rar
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: RayCast Vehicle Problem

Postby Julio Jerez » Mon May 03, 2010 4:29 pm

Oh so when teh car is spawn it is suppost to have a torque applied to it.
Ok I see now. I will check tonight.

also the Crash is very estrange I do no get any stack trace either, only a bunh of windows calls.
I have to be a memory over run that is trachin teh stak in the Hieght field.
was that like that before, or is this new?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: RayCast Vehicle Problem

Postby Stucuk » Mon May 03, 2010 5:19 pm

Julio Jerez wrote:Oh so when teh car is spawn it is suppost to have a torque applied to it.

Yes. All 4 wheels are applied Torque each frame. Tho if you spawn more than one, only the latest car will have torque applied.

Julio Jerez wrote:I have to be a memory over run that is trachin teh stak in the Hieght field.
was that like that before, or is this new?


I have never used the Newton Height Field before this so i wouldn't know. Its the same in both 2.18 and 2.19 . I havn't tried 2.20 but afaik you have only optimised the Collision Tree's in 2.20 .
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: RayCast Vehicle Problem

Postby bleubleu » Tue May 04, 2010 9:10 pm

Ok, found the problem, it is pretty simple.

Julio recently added piecewise linear curves for the tires, longitudinal force curve is initialized as:

Code: Select all
dFloat normalizedLongitudinalForce[] = {0.0f, 1.0f, 0.9f, 0.7f};


Later on, if the speed of the car falls real close to zero, the param of the curve is set to zero. So f(0) = 0. This is why, when the sphere hits your car, the speed gets > 0.001 and it starts moving.

Code: Select all
slipRatioCoef = (dAbs (axelLinealSpeed) > 1.e-3f) ? ((-tireRotationSpeed - axelLinealSpeed) / dAbs (axelLinealSpeed)) : 0.0f;

// calculate the formal longitudinal force the tire apply to the chassis
longitudinalForceMag = m_normalizedLongitudinalForce.GetValue (slipRatioCoef) * tire.m_tireLoad * tire.m_groundFriction;


The fix is to avoid zeros in that curve

Code: Select all
dFloat normalizedLongitudinalForce[] = {0.01f, 1.0f, 0.9f, 0.7f};


Julio, does that make any sense? I am no physics expert...

-Mat
bleubleu
 
Posts: 17
Joined: Sat Apr 21, 2007 5:51 pm
Location: Montreal, Canada

Re: RayCast Vehicle Problem

Postby Julio Jerez » Tue May 04, 2010 9:19 pm

Oh I see, the force when the value is zero is also zero, so if the car stop it will never start because the tire model is only defined for tire that are already spinning.
I see the problem. that's the consecuence of an empirical tire model breaking down at low speed.

I think your solution is good, there should be some residual force at zero that is canceled by some internal engine force or brake force.
I think your solution is excelenet solution, also bear in mind the the curve is meant to be filled by the end user, so that they can have different tire models for different cars.
I am making another pass at the car and see if I can make more refinements.

aside from those problems, is the car joint woking for you? do you think you can make usefull by buyild up soem fun driving arcaidy vehicles?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: RayCast Vehicle Problem

Postby bleubleu » Tue May 04, 2010 9:30 pm

I just started migrating the physics engine of my driving simulator from Newton 1.53 -> 2.20 last week, I will let you know what I find in the process. So far, everything is going smoothly. In my book, this seriously looks like the best car joint (and physics engine) available for free! I wouldnt be surprised that newton is better than some of the commercial products available too. Good work.

-Mat
bleubleu
 
Posts: 17
Joined: Sat Apr 21, 2007 5:51 pm
Location: Montreal, Canada

Re: RayCast Vehicle Problem

Postby Stucuk » Wed May 05, 2010 3:47 am

@bleubleu: Your fix defiantly makes the car move without needing a Sphere. Thanks!
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: RayCast Vehicle Problem

Postby bleubleu » Thu May 06, 2010 7:02 pm

Im trying to fix the problem without modify the CustomDGRayCastCar.cpp file. The normalized force curves are meant to be supplied by the user, but the CustomDGRayCastCar::NormalizeForceCurve struct is not exported, so when I call the InitalizeCurve() method, I get a linking error.

Code: Select all
1>SimEngineUnity.obj : error LNK2001: unresolved external symbol "public: void __thiscall CustomDGRayCastCar::NormalizeForceCurve::InitalizeCurve(int,float * const,float * const)" (?InitalizeCurve@NormalizeForceCurve@CustomDGRayCastCar@@QAEXHQAM0@Z)
1>C:\Users\Mat\Sim\SimUdeS\Src\\..\Bin\Release\SimEngine.dll : fatal error LNK1120: 1 unresolved externals


I get the dllexport (JOINTLIBRARY_API) does not apply to nested classes/structs.

Any ideas?

-Mat
bleubleu
 
Posts: 17
Joined: Sat Apr 21, 2007 5:51 pm
Location: Montreal, Canada

Re: RayCast Vehicle Problem

Postby Julio Jerez » Thu May 06, 2010 7:10 pm

I see,
You have three options.
1- change the table and and recompiled the joint library
2-add a function the joint library to expose the force table.
3-wait until this weekend when I do 1 and 2 and release 2.21
Julio Jerez
Moderator
Moderator
 
Posts: 12426
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 1 guest