Closed OpenTireMaster closed 4 years ago
You should be able to add the following two methods to your TireModelBase class to serialize your tire parameters to a JSON file.
I haven't tested this because your testEnv.py function is not importing correctly for me and looks like you're missing something on line 44 and 53. I don't have time to track this down at the moment, but should be relatively easy to implement.
def savejson(self, filepath):
"""Output Parameters to JSON file"""
with open(filepath, "w") as outfile:
json.dump(self.Coefficients, outfile)
def loadjson(self, filepath):
"""Load parameters from JSON file"""
with open(filepath, "r") as infile:
self.Coefficients = json.load(infile)
and add:
import json
to the top of the file.
Thanks for the feedback @kriswehage!
I'll definitely look into to adding JSON save/load in the manner you described - it would be quite handy when implementing new model definitions. You'll see that save/load of the .TIR file format is implemented, .TIR is the de facto industry standard for tire model parameters.
Yes I saw that, very nice! I am programming the Pacejka model in C and your code has been very helpful. I would be interested to contribute to OpenTire later, although I don't have much spare time at the moment. I should have a little more time in 6 months. I will continue to follow updates on your project until then.
The Parameters object inside each TireModel is a dictionary (key:pair). This makes it really flexible when adding a new model, because the objects inside the dictionary could be simple numbers (float) which is suitable for basic coefficients. But you could also imagine to store other data types (arrays, etc.) to represents lookup tables or spline configurations.
It would be quite useful to have save/load functionality that enables saving the Parameters dictionary to a human readable file. This could perhaps be done somehow using JSON/XML serialization.