Vehicles third pass

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Vehicles third pass

Postby pHySiQuE » Tue Sep 26, 2017 5:37 am

I tried to implement the new vehicles and failed. There are so many values to set and my resulting car woulld fly around in the air unpredictably. We have projects right now that are waiting to upgrade to the latest version of Leadwerks because of this:
http://www.indiedb.com/games/border-recon

Vehicles are part of our API and do not presently work:
https://www.leadwerks.com/learn?page=AP ... ct_Vehicle

People are asking about it:
https://www.leadwerks.com/community/pro ... ype=status

I had to upgrade Newton to get some bug fixes, otherwise I would have stayed back on the old version.

If the file loading uses serialization, I can't use it, since it will keep changing and invalidating old serialized files, something that caused a lot of problems back in Leadwerks 2.3.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Vehicles third pass

Postby Julio Jerez » Tue Sep 26, 2017 10:35 am

who said the file load uses serialization? I said the opposite.

I said I am adding a file save and load in ascii, so that people can tweak parameters by editing the text file. But that has not work because saving the file is simple but loading breaks too easily, specially for something that is changing, so I will write a different loader that parses the file instead of just de serializing it.

On vehicle setup, I do not know what to say, the super car demo is quite straightforward to set, the function void BuildWheelCar (const CarDefinition& definition) is not more than 100 lines of code, and that build all different type of four wheels vehicles.

last time you said that the problem was that the tire had a 90 degree rotation offset, and that was fixed. The driving state machine is now part of the vehicle so you only need implement method

void UpdateDriverInput(dCustomVehicleController* const vehicle, dFloat timestep)
there fill in the data structure dVehicleDriverInput with the input values
and call vehicle->ApplyDefualtDriver(driverInput, timestep);

the entire super car demo is less than 1200 lines of code with lot of spaces and that include the debug code, the AI for other cars, the setup for the scene and even build a simple track on one spline line.
I don't get why you can not get this working, the thing you said that where inconvenient for you engine were changed.
and like I sad before what is missing has nothing to do with interface, rather with improving the handling at high speed.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicles third pass

Postby pHySiQuE » Tue Sep 26, 2017 2:19 pm

Maybe I did something dumb but I have a thousand other things on my mind than vehicles. I will take another look when I get a chance.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Vehicles third pass

Postby Julio Jerez » Tue Sep 26, 2017 2:41 pm

this weekend I will do the last dynamics part, and see if I can complete the text file loader.
I stop the loader because of the changes I am making, but it does work if the classes aren't modifies.
Then I will enable the simple car, which is extremely simple, since all it does is load the supercar.

that demo is about 350 lines of code, and that include comments, debug code and setup up the scene.
I do not think you will find any engine with a simple vehicle system to set up. Believe me.

Maybe that demo will be easier for you to get start, the text file is like a template that you can use to
initialized the parameters. The basics car is in fact the saved super car now.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicles third pass

Postby godlike » Wed Sep 27, 2017 2:48 am

I've taken a peek at the vehicle code. You are using the dCustomJointSaveLoad class to load the vehicle configuration. Is that correct? That class requires a FILE*. How will that work if an engine doesn't use a conventional filesystem based on FILE?
User avatar
godlike
 
Posts: 58
Joined: Sun Mar 16, 2014 3:48 am

Re: Vehicles third pass

Postby Sweenie » Wed Sep 27, 2017 7:35 am

Maybe the vehiclemanager could have some kind of parameter list/map that the user would have to setup with correct values?
Then there could be a function to validate that the necessary parameters are set or maybe just fall back to default values.
Julio could also add new parameters this way which falls back to default values if the user haven't set the values.
That way it would be up to the user to either pass these parameters from a file, database or whatever data store they use.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Vehicles third pass

Postby Julio Jerez » Wed Sep 27, 2017 2:41 pm

good point godlike,
tow classes where added recently to the engine

class dCustomJoint::dDebugDisplay
class dCustomJointSaveLoad: public dCustomAlloc

this are interfaces to doing that kind of stuff for a high level is a abstract way
dCustomJoint::dDebugDisplay
is clear and is ease to see how a higher level can override the funtion to draw the debug info.
This is the solution I came with to displat joint and model debug info, because there are no like collision shapes and bodies that are well define,

so far only Joe has made use of it and over wrote a really cool joint display function tha
virtual void SetColor(const dVector& color) = 0;
virtual void DrawLine(const dVector& p0, const dVector& p1) = 0;
that I stole from him to make for some joints.

The second since is still a work in progress
The constructor take a FILE* and parameter, but is should take a function pointer

This weekend I will try to complete the stability part of the vehicle and the complete the file loader.
there are a bigger issues that have to be solve which is that sequential de serialization is a too fragile method for loading text files. There are too prompt to brake down, even by a strange character in the file can throw off the loader.
so maybe next week I will revisit that again.

if any one have ideas how to go about, there are all welcome, they only one that I will no do is the reading form and archive, like loading xml files and fetch data from it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicles third pass

Postby Julio Jerez » Wed Sep 27, 2017 2:51 pm

Sweenie wrote:Maybe the vehiclemanager could have some kind of parameter list/map that the user would have to setup with correct values?
...

can you elaborate more on this, I am familiar with system that are build on top of Scheme, why is like adding type checking to xml files
https://en.wikipedia.org/wiki/XML_schema

but in 20 years I have never seen a tool build on schema that anyone understand just few days after the original idea. the system become like want happen when I use Wxwidget, Boost or Collada, or you end up with hundred of thousand source code file or other dependency library that make you demo to be either several gigabytes in side, or a nightmare to install to get to even compile.
now is a library is not stand alone I will no use it.

Notice that newton is a stand alone library, it use tiny xml and imgui, but those are only for the demos. and they are zlib licenses that let use distribute them and very lightweight in size.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicles third pass

Postby Sweenie » Thu Sep 28, 2017 2:52 am

no no, i didn't mean some complex xml loader or anything like that.

I meant some kind of dictionary object to pass parameters to the vehicle manager.

Something like this...

VehicleParams params;

params.SetFloat("MAX_TORQUE", 3000.0f);
params.SetFloat("IDLE_TORQUE", 150.0f);

something like that.

Then you could verify that necessary params are set before creating the vehicle...

if(!param.HasValue("MAX_TORQUE"))
{ throw exception...}

Just thought it would make it easier to add new parameters that way and the file loader wouldn't need to be too advanced either. Also the the file wouldn't "break" if new parameters were introduced unless groundbreaking changes were made.

Kind of like a ParameterObject but more dynamic.

But maybe I have misunderstood the problem. :)
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Vehicles third pass

Postby Julio Jerez » Thu Sep 28, 2017 2:28 pm

Sweenie wrote:I meant some kind of dictionary object to pass parameters to the vehicle manager.


yes that's what I meant when I was saying that writing a loader by de-serializing a text file that was generated from a serialization, is not very stable, basically the file had to be loaded to some archive and the loader queried the data as it need it, other wise is a futile exercise.

we will deal with the that later, this weekend I want to focus on the body centered simulation.
I have many sample and I added a hacky one, but I want to really write the final one that we use as the base and we can refine later if we want.

I will write some help tutorial on how to do physic modeling using linear algebra and a physic engine. I am surprised how little is in the literature about that, maybe a blog or something like that.
There was a FAQ in the forum but I do not find it anymore.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicles third pass

Postby pHySiQuE » Sat Oct 21, 2017 10:54 am

I have started working on vehicles again.
Julio Jerez wrote:last time you said that the problem was that the tire had a 90 degree rotation offset, and that was fixed.

That does not appear to be the case. The vehicleFrame parameter seems to be ignored and the car always has its tires mounted sideways.

I think the reason my cars were flying was because I was calling BodySetMatrix() on the tires to try to fix their orientation.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Vehicles third pass

Postby pHySiQuE » Sun Oct 22, 2017 4:51 am

I have found two other issues.

If the tires fall asleep, they will not wake up by accelerating the car. The tires have to be turned before they will wake.

If the car goes forward and then reverse, the following assert is triggered:
Code: Select all
dFloat dEngineController::IntepolateTorque(dFloat rpm) const
{
   dAssert (rpm >= -0.1f);


I have not implemented the driver input method yet, so maybe that is causing the problem.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Vehicles third pass

Postby Julio Jerez » Mon Oct 23, 2017 1:42 pm

The body part can't go to sleep independent of each other, it is an all or nothing.
and yes the whole vehicle will go to sleep if no action happens on any body part.

because the vehicle is control by controller that apply signal to jkoints, if the vehicle is slepping then will no move at all, this is why the function
void dCustomVehicleController::PreUpdate(dFloat timestep, int threadIndex)
calls ControlStateChanged()

I am no sure why you is not moving,
set a break point at line 3282 in file
../dCustomJoints\dCustomVehicleControllerManager.cpp

see if ControlStateChanged() is returning true.
My guess is that if you did not implemnet drive input the it may be that the controller input aren't changing and the function is returning zero.

di you get over the chassis alignment problem.
In the version there is no Frame matrix, I realized that most game engine already has scene graph, and is quite easy to just the a model and added parent it from a node that does the 90 rotation.

basically to make a node, and add dommy child with a 90 rotaion, the you make the vehicle a child of that node, and it should work fine.

and for the engine asserting because going is reverse, yes the engine si no support to spinning in reverse. how are you moving the vehicle?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vehicles third pass

Postby pHySiQuE » Tue Oct 24, 2017 9:27 am

Let's assume those bugs are due to me not implementing the input method yet.

I will have to fix the vehicle code so that the X and Z axes are swapped. I do not want my users to have to work around a problem when I have been teaching people for years that+Z is the forward direction. I will post my modified code if I am able to figure it out.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Vehicles third pass

Postby Julio Jerez » Tue Oct 24, 2017 2:21 pm

the vehicle principal axis of motion is its x local axis as it is for all functionality of the engine.
but is no just me, this is close to the convention in all literature on vehicle dynamics I have seen.
https://www.google.com/search?q=vehicle+dynamics+center+axis&rlz=1C1GGRV_enUS751US751&tbm=isch&source=iu&pf=m&ictx=1&fir=7rHRfEdBO9hCVM%253A%252CGsijbAXkhDI5cM%252C_&usg=__Sl3oopo8v8ODpgadkrGXrKrmsao%3D&sa=X&ved=0ahUKEwiJvrr47onXAhVK4WMKHQfiAHoQ9QEIOjAD#imgrc=7rHRfEdBO9hCVM:
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 9 guests

cron