-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor default Civic params #720
Changes from 5 commits
e5328b2
d7e0f25
6f02472
ea8d291
aa498a4
0206f71
44b8d0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,35 @@ | |
|
||
# kg of standard extra cargo to count for drive, gas, etc... | ||
STD_CARGO_KG = 136. | ||
LB_TO_KG = 0.453592 | ||
|
||
# FIXME: hardcoding honda civic 2016 touring params so they can be used to | ||
# scale unknown params for other cars | ||
class CivicParams: | ||
MASS = 2923. * LB_TO_KG + STD_CARGO_KG | ||
WHEELBASE = 2.70 | ||
CENTER_TO_FRONT = WHEELBASE * 0.4 | ||
CENTER_TO_REAR = WHEELBASE - CENTER_TO_FRONT | ||
ROTATIONAL_INERTIA = 2500 | ||
TIRE_STIFFNESS_FRONT = 192150 | ||
TIRE_STIFFNESS_REAR = 202500 | ||
|
||
# TODO: get actual value, for now starting with reasonable value for | ||
# civic and scaling by mass and wheelbase | ||
def scale_rot_inertia(mass, wheelbase): | ||
return CivicParams.ROTATIONAL_INERTIA * mass * wheelbase ** 2 / (CivicParams.MASS * CivicParams.WHEELBASE ** 2) | ||
|
||
# TODO: start from empirically derived lateral slip stiffness for the civic and scale by | ||
# mass and CG position, so all cars will have approximately similar dyn behaviors | ||
def scale_tire_stiffness(mass, wheelbase, center_to_front, tire_stiffness_factor): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tire_stiffness_factor should default to 1, as it's not always necessary (see chrysler) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so the gm, chrysler, and hyundai? seemed odd to me at the time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well,
|
||
center_to_rear = wheelbase - center_to_front | ||
tire_stiffness_front = (CivicParams.TIRE_STIFFNESS_FRONT * tire_stiffness_factor) * mass / CivicParams.MASS * \ | ||
(center_to_rear / wheelbase) / (CivicParams.CENTER_TO_REAR / CivicParams.WHEELBASE) | ||
|
||
tire_stiffness_rear = (CivicParams.TIRE_STIFFNESS_REAR * tire_stiffness_factor) * mass / CivicParams.MASS * \ | ||
(center_to_front / wheelbase) / (CivicParams.CENTER_TO_FRONT / CivicParams.WHEELBASE) | ||
|
||
return tire_stiffness_front, tire_stiffness_rear | ||
|
||
def dbc_dict(pt_dbc, radar_dbc, chassis_dbc=None): | ||
return {'pt': pt_dbc, 'radar': radar_dbc, 'chassis': chassis_dbc} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
from selfdrive.controls.lib.vehicle_model import VehicleModel | ||
from selfdrive.car.chrysler.carstate import CarState, get_can_parser, get_camera_parser | ||
from selfdrive.car.chrysler.values import ECU, check_ecu_msgs, CAR | ||
from selfdrive.car import STD_CARGO_KG | ||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness | ||
|
||
|
||
class CarInterface(object): | ||
|
@@ -51,16 +51,6 @@ def get_params(candidate, fingerprint, vin=""): | |
# pedal | ||
ret.enableCruise = True | ||
|
||
# FIXME: hardcoding honda civic 2016 touring params so they can be used to | ||
# scale unknown params for other cars | ||
mass_civic = 2923. * CV.LB_TO_KG + STD_CARGO_KG | ||
wheelbase_civic = 2.70 | ||
centerToFront_civic = wheelbase_civic * 0.4 | ||
centerToRear_civic = wheelbase_civic - centerToFront_civic | ||
rotationalInertia_civic = 2500 | ||
tireStiffnessFront_civic = 85400 * 2.0 | ||
tireStiffnessRear_civic = 90000 * 2.0 | ||
|
||
# Speed conversion: 20, 45 mph | ||
ret.wheelbase = 3.089 # in meters for Pacifica Hybrid 2017 | ||
ret.steerRatio = 16.2 # Pacifica Hybrid 2017 | ||
|
@@ -70,11 +60,13 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.lateralTuning.pid.kf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 | ||
ret.steerActuatorDelay = 0.1 | ||
ret.steerRateCost = 0.7 | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like this is an unnecessary addition and change? |
||
|
||
if candidate in (CAR.JEEP_CHEROKEE, CAR.JEEP_CHEROKEE_2019): | ||
ret.wheelbase = 2.91 # in meters | ||
ret.steerRatio = 12.7 | ||
ret.steerActuatorDelay = 0.2 # in seconds | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
|
||
ret.centerToFront = ret.wheelbase * 0.44 | ||
|
||
|
@@ -85,20 +77,15 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.minSteerSpeed = 17.5 # m/s 17 on the way up, 13 on the way down once engaged. | ||
# TODO allow 2019 cars to steer down to 13 m/s if already engaged. | ||
|
||
centerToRear = ret.wheelbase - ret.centerToFront | ||
# TODO: get actual value, for now starting with reasonable value for | ||
# civic and scaling by mass and wheelbase | ||
ret.rotationalInertia = rotationalInertia_civic * \ | ||
ret.mass * ret.wheelbase**2 / (mass_civic * wheelbase_civic**2) | ||
ret.rotationalInertia = scale_rot_inertia(mass=ret.mass, wheelbase=ret.wheelbase) | ||
|
||
# TODO: start from empirically derived lateral slip stiffness for the civic and scale by | ||
# mass and CG position, so all cars will have approximately similar dyn behaviors | ||
ret.tireStiffnessFront = tireStiffnessFront_civic * \ | ||
ret.mass / mass_civic * \ | ||
(centerToRear / ret.wheelbase) / (centerToRear_civic / wheelbase_civic) | ||
ret.tireStiffnessRear = tireStiffnessRear_civic * \ | ||
ret.mass / mass_civic * \ | ||
(ret.centerToFront / ret.wheelbase) / (centerToFront_civic / wheelbase_civic) | ||
ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(mass=ret.mass, wheelbase=ret.wheelbase, | ||
center_to_front=ret.centerToFront, | ||
tire_stiffness_factor=tire_stiffness_factor) | ||
|
||
# no rear steering, at least on the listed cars above | ||
ret.steerRatioRear = 0. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from selfdrive.controls.lib.vehicle_model import VehicleModel | ||
from selfdrive.car.ford.carstate import CarState, get_can_parser | ||
from selfdrive.car.ford.values import MAX_ANGLE | ||
from selfdrive.car import STD_CARGO_KG | ||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness | ||
|
||
|
||
class CarInterface(object): | ||
|
@@ -51,16 +51,6 @@ def get_params(candidate, fingerprint, vin=""): | |
# pedal | ||
ret.enableCruise = True | ||
|
||
# FIXME: hardcoding honda civic 2016 touring params so they can be used to | ||
# scale unknown params for other cars | ||
mass_civic = 2923. * CV.LB_TO_KG + STD_CARGO_KG | ||
wheelbase_civic = 2.70 | ||
centerToFront_civic = wheelbase_civic * 0.4 | ||
centerToRear_civic = wheelbase_civic - centerToFront_civic | ||
rotationalInertia_civic = 2500 | ||
tireStiffnessFront_civic = 85400 | ||
tireStiffnessRear_civic = 90000 | ||
|
||
ret.wheelbase = 2.85 | ||
ret.steerRatio = 14.8 | ||
ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG | ||
|
@@ -69,32 +59,22 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.lateralTuning.pid.kf = 1. / MAX_ANGLE # MAX Steer angle to normalize FF | ||
ret.steerActuatorDelay = 0.1 # Default delay, not measured yet | ||
ret.steerRateCost = 1.0 | ||
|
||
f = 1.2 | ||
tireStiffnessFront_civic *= f | ||
tireStiffnessRear_civic *= f | ||
|
||
ret.centerToFront = ret.wheelbase * 0.44 | ||
|
||
tire_stiffness_factor = 0.444 # not optimized | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be 0.53, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah 20% higher. wanted to double check on whether this number was based on a meaningful method, so I defaulted it at the time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. subjective tuning |
||
|
||
# min speed to enable ACC. if car can do stop and go, then set enabling speed | ||
# to a negative value, so it won't matter. | ||
ret.minEnableSpeed = -1. | ||
|
||
centerToRear = ret.wheelbase - ret.centerToFront | ||
# TODO: get actual value, for now starting with reasonable value for | ||
# civic and scaling by mass and wheelbase | ||
ret.rotationalInertia = rotationalInertia_civic * \ | ||
ret.mass * ret.wheelbase**2 / (mass_civic * wheelbase_civic**2) | ||
ret.rotationalInertia = scale_rot_inertia(mass=ret.mass, wheelbase=ret.wheelbase) | ||
|
||
# TODO: start from empirically derived lateral slip stiffness for the civic and scale by | ||
# mass and CG position, so all cars will have approximately similar dyn behaviors | ||
ret.tireStiffnessFront = tireStiffnessFront_civic * \ | ||
ret.mass / mass_civic * \ | ||
(centerToRear / ret.wheelbase) / (centerToRear_civic / wheelbase_civic) | ||
ret.tireStiffnessRear = tireStiffnessRear_civic * \ | ||
ret.mass / mass_civic * \ | ||
(ret.centerToFront / ret.wheelbase) / (centerToFront_civic / wheelbase_civic) | ||
ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(mass=ret.mass, wheelbase=ret.wheelbase, | ||
center_to_front=ret.centerToFront, | ||
tire_stiffness_factor=tire_stiffness_factor) | ||
|
||
# no rear steering, at least on the listed cars above | ||
ret.steerRatioRear = 0. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from selfdrive.car.gm.values import DBC, CAR, STOCK_CONTROL_MSGS, AUDIO_HUD, \ | ||
SUPERCRUISE_CARS, AccState | ||
from selfdrive.car.gm.carstate import CarState, CruiseButtons, get_powertrain_can_parser | ||
from selfdrive.car import STD_CARGO_KG | ||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness | ||
|
||
|
||
class CanBus(object): | ||
|
@@ -70,6 +70,7 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.steerRatio = 15.7 | ||
ret.steerRatioRear = 0. | ||
ret.centerToFront = ret.wheelbase * 0.4 # wild guess | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same value for all cars, we can move it out. |
||
|
||
elif candidate == CAR.MALIBU: | ||
# supports stop and go, but initial engage must be above 18mph (which include conservatism) | ||
|
@@ -80,6 +81,7 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.steerRatio = 15.8 | ||
ret.steerRatioRear = 0. | ||
ret.centerToFront = ret.wheelbase * 0.4 # wild guess | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
|
||
elif candidate == CAR.HOLDEN_ASTRA: | ||
ret.mass = 1363. + STD_CARGO_KG | ||
|
@@ -90,6 +92,7 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.safetyModel = car.CarParams.SafetyModel.gm | ||
ret.steerRatio = 15.7 | ||
ret.steerRatioRear = 0. | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
|
||
elif candidate == CAR.ACADIA: | ||
ret.minEnableSpeed = -1. # engage speed is decided by pcm | ||
|
@@ -99,6 +102,7 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.steerRatio = 14.4 #end to end is 13.46 | ||
ret.steerRatioRear = 0. | ||
ret.centerToFront = ret.wheelbase * 0.4 | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
|
||
elif candidate == CAR.BUICK_REGAL: | ||
ret.minEnableSpeed = 18 * CV.MPH_TO_MS | ||
|
@@ -108,6 +112,7 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.steerRatio = 14.4 # guess for tourx | ||
ret.steerRatioRear = 0. | ||
ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
|
||
elif candidate == CAR.CADILLAC_ATS: | ||
ret.minEnableSpeed = 18 * CV.MPH_TO_MS | ||
|
@@ -117,6 +122,7 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.steerRatio = 15.3 | ||
ret.steerRatioRear = 0. | ||
ret.centerToFront = ret.wheelbase * 0.49 | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
|
||
elif candidate == CAR.CADILLAC_CT6: | ||
# engage speed is decided by pcm | ||
|
@@ -127,32 +133,18 @@ def get_params(candidate, fingerprint, vin=""): | |
ret.steerRatio = 14.6 # it's 16.3 without rear active steering | ||
ret.steerRatioRear = 0. # TODO: there is RAS on this car! | ||
ret.centerToFront = ret.wheelbase * 0.465 | ||
tire_stiffness_factor = 0.444 # not optimized yet | ||
|
||
|
||
# hardcoding honda civic 2016 touring params so they can be used to | ||
# scale unknown params for other cars | ||
mass_civic = 2923. * CV.LB_TO_KG + STD_CARGO_KG | ||
wheelbase_civic = 2.70 | ||
centerToFront_civic = wheelbase_civic * 0.4 | ||
centerToRear_civic = wheelbase_civic - centerToFront_civic | ||
rotationalInertia_civic = 2500 | ||
tireStiffnessFront_civic = 85400 | ||
tireStiffnessRear_civic = 90000 | ||
|
||
centerToRear = ret.wheelbase - ret.centerToFront | ||
# TODO: get actual value, for now starting with reasonable value for | ||
# civic and scaling by mass and wheelbase | ||
ret.rotationalInertia = rotationalInertia_civic * \ | ||
ret.mass * ret.wheelbase**2 / (mass_civic * wheelbase_civic**2) | ||
ret.rotationalInertia = scale_rot_inertia(mass=ret.mass, wheelbase=ret.wheelbase) | ||
|
||
# TODO: start from empirically derived lateral slip stiffness for the civic and scale by | ||
# mass and CG position, so all cars will have approximately similar dyn behaviors | ||
ret.tireStiffnessFront = tireStiffnessFront_civic * \ | ||
ret.mass / mass_civic * \ | ||
(centerToRear / ret.wheelbase) / (centerToRear_civic / wheelbase_civic) | ||
ret.tireStiffnessRear = tireStiffnessRear_civic * \ | ||
ret.mass / mass_civic * \ | ||
(ret.centerToFront / ret.wheelbase) / (centerToFront_civic / wheelbase_civic) | ||
ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(mass=ret.mass, wheelbase=ret.wheelbase, | ||
center_to_front=ret.centerToFront, | ||
tire_stiffness_factor=tire_stiffness_factor) | ||
|
||
# same tuning for Volt and CT6 for now | ||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I mean just put the value in kg :)