Skip to content

Commit

Permalink
Merge pull request commaai#591 from netadvanced/vw-skoda
Browse files Browse the repository at this point in the history
VW skoda
  • Loading branch information
arne182 authored Mar 29, 2020
2 parents c997772 + 4b49df3 commit 8bace0e
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 40 deletions.
105 changes: 68 additions & 37 deletions selfdrive/car/volkswagen/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,74 @@ def compute_gb(accel, speed):
def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, car_fw=[]):
ret = CarInterfaceBase.get_std_params(candidate, fingerprint, has_relay)

if candidate == CAR.GOLF:
# Set common MQB parameters that will apply globally
ret.carName = "volkswagen"
ret.radarOffCan = True
ret.safetyModel = car.CarParams.SafetyModel.volkswagen

# Additional common MQB parameters that may be overridden per-vehicle
ret.steerRateCost = 0.5
ret.steerActuatorDelay = 0.05 # Hopefully all MQB racks are similar here
ret.steerLimitTimer = 0.4

# As a starting point for speed-adjusted lateral tuning, use the example
# map speed breakpoints from a VW Tiguan (SSP 399 page 9). It's unclear
# whether the driver assist map breakpoints have any direct bearing on
# HCA assist torque, but if they're good breakpoints for the driver,
# they're probably good breakpoints for HCA as well. OP won't be driving
# 250kph/155mph but it provides interpolation scaling above 100kmh/62mph.
ret.lateralTuning.pid.kpBP = [0., 15 * CV.KPH_TO_MS, 50 * CV.KPH_TO_MS]
ret.lateralTuning.pid.kiBP = [0., 15 * CV.KPH_TO_MS, 50 * CV.KPH_TO_MS]

# FIXME: Per-vehicle parameters need to be reintegrated.
# For the time being, per-vehicle stuff is being archived since we
# can't auto-detect very well yet. Now that tuning is figured out,
# averaged params should work reasonably on a range of cars. Owners
# can tweak here, as needed, until we have car type auto-detection.
# Applies to all models for now
# if candidate in (CAR.VW_GOLF, CAR.SKODA_SUPERB_B8, CAR.VW_TOURAN):

# Set common MQB parameters that will apply globally
ret.carName = "volkswagen"
ret.radarOffCan = True
ret.safetyModel = car.CarParams.SafetyModel.volkswagen

# Additional common MQB parameters that may be overridden per-vehicle
ret.steerRateCost = 1.0
ret.steerActuatorDelay = 0.05 # Hopefully all MQB racks are similar here
ret.steerLimitTimer = 0.4

ret.steerMaxBP = [0.] # m/s
ret.steerMaxV = [1.]

ret.mass = 1700 + STD_CARGO_KG
ret.wheelbase = 2.75
ret.centerToFront = ret.wheelbase * 0.45
ret.steerRatio = 15.6
ret.lateralTuning.pid.kf = 0.00006
ret.lateralTuning.pid.kpV = [0.15, 0.25, 0.60]
ret.lateralTuning.pid.kiV = [0.05, 0.05, 0.05]
tire_stiffness_factor = 0.6

# ret.lateralTuning.pid.kpBP = [0., 15 * CV.KPH_TO_MS, 50 * CV.KPH_TO_MS]
# ret.lateralTuning.pid.kiBP = [0., 15 * CV.KPH_TO_MS, 50 * CV.KPH_TO_MS]
# ret.lateralTuning.pid.kpV = [0.15, 0.25, 0.60]
# ret.lateralTuning.pid.kiV = [0.05, 0.05, 0.05]

ret.centerToFront = ret.wheelbase * 0.45
ret.steerRatio = 15.6
ret.steerRatioRear = 0.

ret.lateralTuning.pid.kf = 0.00006
ret.lateralTuning.pid.kpBP = [0.]
ret.lateralTuning.pid.kiBP = [0.]
ret.lateralTuning.pid.kpV = [0.6]
ret.lateralTuning.pid.kiV = [0.2]

ret.enableCamera = True # Stock camera detection doesn't apply to VW
ret.transmissionType = car.CarParams.TransmissionType.automatic
# ret.enableCruise = True # Stock ACC still controls acceleration and braking
# ret.openpilotLongitudinalControl = False
# ret.steerControlType = car.CarParams.SteerControlType.torque

# Define default values across the MQB range,
# redefined per model bellow.
# Commented our for now as we don't allow unknown models for now.

# ret.mass = 1500 + STD_CARGO_KG
# ret.wheelbase = 2.64
# tire_stiffness_factor = 1.0

# Refine parameters for each vehicle.
if candidate == CAR.GOLF:

ret.mass = 1500 + STD_CARGO_KG
ret.wheelbase = 2.64
tire_stiffness_factor = 1.0

elif candidate == CAR.VW_TOURAN:

ret.mass = 1650 + STD_CARGO_KG
ret.wheelbase = 2.79
tire_stiffness_factor = 0.8

elif candidate == CAR.SKODA_SUPERB_B8:

ret.mass = 1700 + STD_CARGO_KG
ret.wheelbase = 2.85
tire_stiffness_factor = 0.8

# Not sure if I should simply exit or raise an error
else:
raise ValueError("Unsupported car %s" % candidate)

# TODO: get actual value, for now starting with reasonable value for
# civic and scaling by mass and wheelbase
Expand Down Expand Up @@ -138,9 +169,9 @@ def update(self, c, can_strings):

def apply(self, c):
can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators,
c.hudControl.visualAlert,
c.hudControl.audibleAlert,
c.hudControl.leftLaneVisible,
c.hudControl.rightLaneVisible)
c.hudControl.visualAlert,
c.hudControl.audibleAlert,
c.hudControl.leftLaneVisible,
c.hudControl.rightLaneVisible)
self.frame += 1
return can_sends
18 changes: 15 additions & 3 deletions selfdrive/car/volkswagen/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,26 @@ class CANBUS:

class CAR:
GOLF = "Volkswagen Golf"
SKODA_SUPERB_B8 = "Skoda Superb B8"
VW_TOURAN = "Volkswagen Touran 2017"


FINGERPRINTS = {
CAR.GOLF: [
# 76b83eb0245de90e|2019-10-21--17-40-42 - jyoung8607 car
{64: 8, 134: 8, 159: 8, 173: 8, 178: 8, 253: 8, 257: 8, 260: 8, 262: 8, 264: 8, 278: 8, 279: 8, 283: 8, 286: 8, 288: 8, 289: 8, 290: 8, 294: 8, 299: 8, 302: 8, 346: 8, 385: 8, 418: 8, 427: 8, 668: 8, 679: 8, 681: 8, 695: 8, 779: 8, 780: 8, 783: 8, 792: 8, 795: 8, 804: 8, 806: 8, 807: 8, 808: 8, 809: 8, 870: 8, 896: 8, 897: 8, 898: 8, 901: 8, 917: 8, 919: 8, 949: 8, 958: 8, 960: 4, 981: 8, 987: 8, 988: 8, 991: 8, 997: 8, 1000: 8, 1019: 8, 1120: 8, 1122: 8, 1123: 8, 1124: 8, 1153: 8, 1162: 8, 1175: 8, 1312: 8, 1385: 8, 1413: 8, 1440: 5, 1514: 8, 1515: 8, 1520: 8, 1600: 8, 1601: 8, 1603: 8, 1605: 8, 1624: 8, 1626: 8, 1629: 8, 1631: 8, 1646: 8, 1648: 8, 1712: 6, 1714: 8, 1716: 8, 1717: 8, 1719: 8, 1720: 8, 1721: 8
}],
# 76b83eb0245de90e|2019-10-21--17-40-42 - jyoung8607 car
{64: 8, 134: 8, 159: 8, 173: 8, 178: 8, 253: 8, 257: 8, 260: 8, 262: 8, 264: 8, 278: 8, 279: 8, 283: 8, 286: 8, 288: 8, 289: 8, 290: 8, 294: 8, 299: 8, 302: 8, 346: 8, 385: 8, 418: 8, 427: 8, 668: 8, 679: 8, 681: 8, 695: 8, 779: 8, 780: 8, 783: 8, 792: 8, 795: 8, 804: 8, 806: 8, 807: 8, 808: 8, 809: 8, 870: 8, 896: 8, 897: 8, 898: 8, 901: 8, 917: 8, 919: 8, 949: 8, 958: 8, 960: 4, 981: 8, 987: 8, 988: 8, 991: 8, 997: 8, 1000: 8, 1019: 8, 1120: 8, 1122: 8, 1123: 8, 1124: 8, 1153: 8, 1162: 8, 1175: 8, 1312: 8, 1385: 8, 1413: 8, 1440: 5, 1514: 8, 1515: 8, 1520: 8, 1600: 8, 1601: 8, 1603: 8, 1605: 8, 1624: 8, 1626: 8, 1629: 8, 1631: 8, 1646: 8, 1648: 8, 1712: 6, 1714: 8, 1716: 8, 1717: 8, 1719: 8, 1720: 8, 1721: 8},
],
CAR.SKODA_SUPERB_B8: [
# 972bfa9500dd3189|2020-02-24--12-34-56 - netadvanced
{64: 8, 134: 8, 159: 8, 173: 8, 178: 8, 253: 8, 257: 8, 260: 8, 262: 8, 264: 8, 278: 8, 279: 8, 283: 8, 286: 8, 288: 8, 289: 8, 290: 8, 294: 8, 295: 8, 299: 8, 302: 8, 346: 8, 385: 8, 427: 8, 668: 8, 679: 8, 681: 8, 695: 8, 779: 8, 780: 8, 783: 8, 791: 8, 792: 8, 799: 8, 804: 8, 806: 8, 807: 8, 808: 8, 809: 8, 838: 8, 839: 8, 840: 8, 841: 8, 842: 8, 843: 8, 844: 8, 845: 8, 870: 8, 896: 8, 897: 8, 898: 8, 901: 8, 917: 8, 919: 8, 927: 8, 949: 8, 958: 8, 960: 4, 981: 8, 987: 8, 988: 8, 991: 8, 997: 8, 1000: 8, 1019: 8, 1122: 8, 1123: 8, 1124: 8, 1153: 8, 1162: 8, 1175: 8, 1312: 8, 1385: 8, 1413: 8, 1440: 5, 1514: 8, 1515: 8, 1520: 8, 1600: 8, 1601: 8, 1603: 8, 1624: 8, 1629: 8, 1631: 8, 1646: 8, 1648: 8, 1712: 6, 1714: 8, 1716: 8, 1717: 8, 1719: 8, 1720: 8},
],
CAR.VW_TOURAN: [
{64: 8, 134: 8, 159: 8, 173: 8, 178: 8, 253: 8, 257: 8, 260: 8, 262: 8, 278: 8, 279: 8, 283: 8, 286: 8, 288: 8, 289: 8, 290: 8, 294: 8, 295: 8, 299: 8, 302: 8, 314: 8, 346: 8, 385: 8, 418: 8, 427: 8, 668: 8, 679: 8, 681: 8, 695: 8, 779: 8, 780: 8, 783: 8, 787: 8, 788: 8, 789: 8, 791: 8, 792: 8, 799: 8, 802: 8, 804: 8, 806: 8, 807: 8, 808: 8, 809: 8, 838: 8, 839: 8, 840: 8, 841: 8, 842: 8, 843: 8, 844: 8, 845: 8, 870: 8, 896: 8, 897: 8, 898: 8, 901: 8, 917: 8, 919: 8, 949: 8, 958: 8, 960: 4, 981: 8, 987: 8, 988: 8, 991: 8, 997: 8, 1000: 8, 1019: 8, 1122: 8, 1123: 8, 1124: 8, 1153: 8, 1162: 8, 1175: 8, 1312: 8, 1332: 8, 1385: 8, 1413: 8, 1440: 5, 1514: 8, 1515: 8, 1520: 8, 1600: 8, 1601: 8, 1603: 8, 1624: 8, 1629: 8, 1631: 8, 1646: 8, 1648: 8, 1712: 6, 1714: 8, 1716: 8, 1717: 8, 1719: 8, 1720: 8, 1721: 8, 1792: 8, 1872: 8, 1976: 8, 1977: 8, 1985: 8},
],
}

DBC = {
CAR.GOLF: dbc_dict('vw_mqb_2010', None),
CAR.VW_TOURAN: dbc_dict('vw_mqb_2010', None),
CAR.SKODA_SUPERB_B8: dbc_dict('vw_mqb_2010', None),
}

0 comments on commit 8bace0e

Please sign in to comment.