diff --git a/FullVehicleSim/Mech/steering.py b/FullVehicleSim/Mech/steering.py index be30430..11e1394 100644 --- a/FullVehicleSim/Mech/steering.py +++ b/FullVehicleSim/Mech/steering.py @@ -57,6 +57,19 @@ def calculateVirtualSlipAngle(parameters): # # return (Fy / CF) * (1 + term1Num/Term1Denom + term2Num/term2Denom + term3) +# Returns a tuple with (in, out) steering angle +def calculateAckermann(steerAngle, aPercent): + # We can assume that front and rear slip angles evolve identically in the small step steer so delta = l/r + wheelBase = params["wheelBase"] + turnRadius = wheelBase / steerAngle + + innerRadiusWheel = np.arctan(wheelBase/(turnRadius - params["trackWidthAvg"])) + outerRadiusWheel = np.arctan(wheelBase/(turnRadius + params["trackWidthAvg"])) + + return (np.degrees(innerRadiusWheel), np.degrees(outerRadiusWheel)) + + + def calculateYawRate(currYawRate, speed, stepSteerInput, timeSinceLastSteer, frontCorneringStiffnessDeg_, rearCorneringStiffnessDeg_, parameters): # This model is based on Performance Vehicle Dynamics # It is a pretty meh model which uses euler's method to approximate transient behavior diff --git a/FullVehicleSim/params.json b/FullVehicleSim/params.json index 2348565..4e8e229 100644 --- a/FullVehicleSim/params.json +++ b/FullVehicleSim/params.json @@ -14,7 +14,8 @@ "tractiveIMax": 300, "Mass": 300, - "wheelBase": 1.65471, + "wheelBase": 1.5898989, + "trackWidthAvg": 1210.004, "a": 0.853506, "frontWeightDist": 46.46, "CoG-height": 0.999628, diff --git a/VDCalculators/README.md b/VDCalculators/README.md index 3274aca..5c92de9 100644 --- a/VDCalculators/README.md +++ b/VDCalculators/README.md @@ -1 +1,4 @@ Calculators that are not to be integrated into the full Vehicle Dynamics model. + +# Ackermann optimizer +This calculator aims to optimize the ackermann percentages of FS4 diff --git a/VDCalculators/ackermannOptimizer.py b/VDCalculators/ackermannOptimizer.py new file mode 100644 index 0000000..5ed2435 --- /dev/null +++ b/VDCalculators/ackermannOptimizer.py @@ -0,0 +1,14 @@ +import os +import sys +import json +sys.path.append("../FullVehicleSim/Mech") +from steering import * + +import json +magic:dict +parameters:dict +with open('../FullVehicleSim/params.json', 'r') as file: + params = json.load(file) + Magic = params["Magic"] + Parameters = params["Parameters"] + del params