Exemplo n.º 1
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, car_fw=[]):  # pylint: disable=dangerous-default-value
    ret = CarInterfaceBase.get_std_params(candidate, fingerprint, has_relay)
    ret.carName = "ford"
    ret.safetyModel = car.CarParams.SafetyModel.ford
    ret.dashcamOnly = True

    ret.wheelbase = 2.85
    ret.steerRatio = 14.8
    ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG
    ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
    ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01], [0.005]]     # TODO: tune this
    ret.lateralTuning.pid.kf = 1. / MAX_ANGLE   # MAX Steer angle to normalize FF
    ret.lateralTuning.pid.kdBP = [0., 18., 27., 35.]  # derivative disabled for now
    ret.lateralTuning.pid.kdV = [0., 0., 0., 0.]
    ret.steerActuatorDelay = 0.1  # Default delay, not measured yet
    ret.steerLimitTimer = 0.8
    ret.steerRateCost = 1.0
    ret.centerToFront = ret.wheelbase * 0.44
    tire_stiffness_factor = 0.5328

    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
                                                                         tire_stiffness_factor=tire_stiffness_factor)

    ret.steerControlType = car.CarParams.SteerControlType.angle

    ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.fwdCamera) or has_relay
    cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera)

    return ret
Exemplo n.º 2
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=None):
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "mazda"
        ret.safetyModel = car.CarParams.SafetyModel.mazda
        ret.lateralTuning.init('pid')

        ret.dashcamOnly = True

        ret.radarOffCan = True

        # Mazda port is a community feature for now
        ret.communityFeature = True

        ret.steerActuatorDelay = 0.1
        ret.steerRateCost = 1.0
        ret.steerLimitTimer = 0.8
        tire_stiffness_factor = 0.70  # not optimized yet

        if candidate in [CAR.CX5]:
            ret.mass = 3655 * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 15.5

            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2],
                                                                    [0.2]]

            ret.lateralTuning.pid.kf = 0.00006

            # No steer below disable speed
            ret.minSteerSpeed = LKAS_LIMITS.DISABLE_SPEED * CV.KPH_TO_MS

        # dp
        ret = common_interface_get_params_lqr(ret)

        ret.centerToFront = ret.wheelbase * 0.41

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        return ret
Exemplo n.º 3
0
    def get_params(candidate, fingerprint=None, has_relay=False, car_fw=None):
        if fingerprint is None:
            fingerprint = gen_empty_fingerprint()
        if car_fw is None:
            car_fw = []

        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)
        ret.carName = "chrysler"
        ret.safetyModel = car.CarParams.SafetyModel.chrysler

        # Chrysler port is a community feature, since we don't own one to test
        ret.communityFeature = True

        # Speed conversion:              20, 45 mph
        ret.wheelbase = 3.089  # in meters for Pacifica Hybrid 2017
        ret.steerRatio = 16.2  # Pacifica Hybrid 2017
        ret.mass = 2858. + STD_CARGO_KG  # kg curb weight Pacifica Hybrid 2017
        ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kiBP = [[9., 20.],
                                                                  [9., 20.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15, 0.30],
                                                                [0.03, 0.05]]
        ret.lateralTuning.pid.kf = 0.00006  # full torque for 10 deg at 80mph means 0.00007818594
        ret.lateralTuning.pid.kdBP = [0., 18., 27.,
                                      35.]  # derivative disabled for now
        ret.lateralTuning.pid.kdV = [0., 0., 0., 0.]
        ret.steerActuatorDelay = 0.1
        ret.steerRateCost = 0.7
        ret.steerLimitTimer = 0.4

        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

        ret.centerToFront = ret.wheelbase * 0.44

        ret.minSteerSpeed = 3.8  # m/s
        if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020,
                         CAR.JEEP_CHEROKEE_2019):
            # TODO allow 2019 cars to steer down to 13 m/s if already engaged.
            ret.minSteerSpeed = 17.5  # m/s 17 on the way up, 13 on the way down once engaged.

        # starting with reasonable value for civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass, ret.wheelbase, ret.centerToFront)

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay
        print("ECU Camera Simulated: {0}".format(ret.enableCamera))

        return ret
Exemplo n.º 4
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)
        ret.carName = "chrysler"
        ret.safetyModel = car.CarParams.SafetyModel.chrysler

        # Speed conversion:              20, 45 mph
        ret.wheelbase = 2.743  # in meters for Chrysler 200 2016
        ret.steerRatio = 16.2  # Pacifica Hybrid 2017
        ret.mass = 1721. + STD_CARGO_KG  # kg curb weight Chrysler 200 2016
        ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kiBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.4], [0.1]]
        ret.lateralTuning.pid.kf = 0.00006  # full torque for 10 deg at 80mph means 0.00007818594
        ret.steerActuatorDelay = 0.1
        ret.steerRateCost = 1.0
        ret.steerLimitTimer = 0.4

        #    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

        ret.centerToFront = ret.wheelbase * 0.44

        ret.minSteerSpeed = 15.65  # m/s
        #    if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.JEEP_CHEROKEE_2019):
        # TODO allow 2019 cars to steer down to 13 m/s if already engaged.
        #      ret.minSteerSpeed = 17.5  # m/s 17 on the way up, 13 on the way down once engaged.

        # starting with reasonable value for civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass, ret.wheelbase, ret.centerToFront)

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay
        print("ECU Camera Simulated: {0}".format(ret.enableCamera))

        return ret
Exemplo n.º 5
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   vin="",
                   has_relay=False):

        ret = car.CarParams.new_message()

        ret.carName = "toyota"
        ret.carFingerprint = candidate
        ret.carVin = vin
        ret.isPandaBlack = has_relay

        ret.safetyModel = car.CarParams.SafetyModel.toyota

        # pedal
        ret.enableCruise = not ret.enableGasInterceptor

        ret.steerActuatorDelay = 0.12  # Default delay, Prius has larger delay

        if candidate not in [CAR.PRIUS, CAR.RAV4,
                             CAR.RAV4H]:  # These cars use LQR/INDI
            ret.lateralTuning.init('pid')
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]

        if candidate == CAR.PRIUS:
            stop_and_go = True
            ret.safetyParam = 66  # see conversion factor for STEER_TORQUE_EPS in dbc file
            ret.wheelbase = 2.70
            ret.steerRatio = 15.74  # unknown end-to-end spec
            tire_stiffness_factor = 0.6371  # hand-tune
            ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG

            ret.lateralTuning.init('indi')
            ret.lateralTuning.indi.innerLoopGain = 4.0
            ret.lateralTuning.indi.outerLoopGain = 3.0
            ret.lateralTuning.indi.timeConstant = 1.0
            ret.lateralTuning.indi.actuatorEffectiveness = 1.0

            # TODO: Determine if this is better than INDI
            # ret.lateralTuning.init('lqr')
            # ret.lateralTuning.lqr.scale = 1500.0
            # ret.lateralTuning.lqr.ki = 0.01

            # ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            # ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            # ret.lateralTuning.lqr.c = [1., 0.]
            # ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
            # ret.lateralTuning.lqr.l = [0.03233671, 0.03185757]
            # ret.lateralTuning.lqr.dcGain = 0.002237852961363602

            ret.steerActuatorDelay = 0.5

        elif candidate in [CAR.RAV4, CAR.RAV4H]:
            stop_and_go = True if (candidate in CAR.RAV4H) else False
            ret.safetyParam = 73
            ret.wheelbase = 2.65
            ret.steerRatio = 16.88  # 14.5 is spec end-to-end
            tire_stiffness_factor = 0.5533
            ret.mass = 3650. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.init('lqr')

            ret.lateralTuning.lqr.scale = 1500.0
            ret.lateralTuning.lqr.ki = 0.05

            ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            ret.lateralTuning.lqr.c = [1., 0.]
            ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
            ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
            ret.lateralTuning.lqr.dcGain = 0.002237852961363602

        elif candidate == CAR.COROLLA:
            stop_and_go = False
            ret.safetyParam = 100
            ret.wheelbase = 2.70
            ret.steerRatio = 18.27
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00003  # full torque for 20 deg at 80mph means 0.00007818594

        elif candidate == CAR.LEXUS_RXH:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.79
            ret.steerRatio = 16.  # 14.8 is spec end-to-end
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG  # mean between min and max
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00006  # full torque for 10 deg at 80mph means 0.00007818594

        elif candidate in [CAR.CHR, CAR.CHRH]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.63906
            ret.steerRatio = 13.6
            tire_stiffness_factor = 0.7933
            ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.723],
                                                                    [0.0428]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate in [CAR.CAMRY, CAR.CAMRYH]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.82448
            ret.steerRatio = 13.7
            tire_stiffness_factor = 0.7933
            ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG  #mean between normal and hybrid
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate in [CAR.HIGHLANDER, CAR.HIGHLANDERH]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.78
            ret.steerRatio = 16.0
            tire_stiffness_factor = 0.8
            ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG  #mean between normal and hybrid limited
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.18
            ], [0.015]]  # community tuning
            ret.lateralTuning.pid.kf = 0.00012  # community tuning

        elif candidate == CAR.AVALON:
            stop_and_go = False
            ret.safetyParam = 73
            ret.wheelbase = 2.82
            ret.steerRatio = 14.8  #Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download
            tire_stiffness_factor = 0.7983
            ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.17],
                                                                    [0.03]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.RAV4_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.68986
            ret.steerRatio = 14.3
            tire_stiffness_factor = 0.7933
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.mass = 3370. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.COROLLA_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.63906
            ret.steerRatio = 13.9
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 3060. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.LEXUS_ESH_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.8702
            ret.steerRatio = 16.0  # not optimized
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 3704. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.SIENNA:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 3.03
            ret.steerRatio = 16.0
            tire_stiffness_factor = 0.444
            ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.LEXUS_IS:
            stop_and_go = False
            ret.safetyParam = 77
            ret.wheelbase = 2.79908
            ret.steerRatio = 13.3
            tire_stiffness_factor = 0.444
            ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.LEXUS_CTH:
            stop_and_go = True
            ret.safetyParam = 100
            ret.wheelbase = 2.60
            ret.steerRatio = 18.6
            tire_stiffness_factor = 0.517
            ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG  # mean between min and max
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00007

        ret.steerRateCost = 1.
        ret.centerToFront = ret.wheelbase * 0.44

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.torque

        # steer, gas, brake limitations VS speed
        ret.steerMaxBP = [16. * CV.KPH_TO_MS,
                          45. * CV.KPH_TO_MS]  # breakpoints at 1 and 40 kph
        ret.steerMaxV = [1., 1.]  # 2/3rd torque allowed above 45 kph
        ret.brakeMaxBP = [0.]
        ret.brakeMaxV = [1.]

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               ECU.CAM) or has_relay
        ret.enableDsu = is_ecu_disconnected(
            fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate,
            ECU.DSU) or (has_relay and candidate in TSS2_CAR)
        ret.enableApgs = False  # is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.APGS)
        ret.enableGasInterceptor = 0x201 in fingerprint[0]
        ret.openpilotLongitudinalControl = ret.enableCamera and ret.enableDsu
        cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera)
        cloudlog.warning("ECU DSU Simulated: %r", ret.enableDsu)
        cloudlog.warning("ECU APGS Simulated: %r", ret.enableApgs)
        cloudlog.warning("ECU Gas Interceptor: %r", ret.enableGasInterceptor)

        # 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. if (
            stop_and_go or ret.enableGasInterceptor) else 19. * CV.MPH_TO_MS

        ret.steerLimitAlert = False

        ret.longitudinalTuning.deadzoneBP = [0., 9.]
        ret.longitudinalTuning.deadzoneV = [0., .15]
        ret.longitudinalTuning.kpBP = [0., 5., 35.]
        ret.longitudinalTuning.kiBP = [0., 35.]
        ret.stoppingControl = False
        ret.startAccel = 0.0

        if ret.enableGasInterceptor:
            ret.gasMaxBP = [0., 9., 35]
            ret.gasMaxV = [0.2, 0.5, 0.7]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiV = [0.18, 0.12]
        else:
            ret.gasMaxBP = [0.]
            ret.gasMaxV = [0.5]
            ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5]
            ret.longitudinalTuning.kiV = [0.54, 0.36]

        return ret
Exemplo n.º 6
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "toyota"
        ret.safetyModel = car.CarParams.SafetyModel.toyota

        ret.steerActuatorDelay = 0.12  # Default delay, Prius has larger delay
        ret.steerLimitTimer = 0.4

        if candidate not in [CAR.PRIUS, CAR.RAV4,
                             CAR.RAV4H]:  # These cars use LQR/INDI
            ret.lateralTuning.init('pid')
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]

        if candidate == CAR.PRIUS:
            stop_and_go = True
            ret.safetyParam = 66  # see conversion factor for STEER_TORQUE_EPS in dbc file
            ret.wheelbase = 2.70
            ret.steerRatio = 15.74  # unknown end-to-end spec
            tire_stiffness_factor = 0.6371  # hand-tune
            ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG

            ret.lateralTuning.init('indi')
            ret.lateralTuning.indi.innerLoopGain = 4.0
            ret.lateralTuning.indi.outerLoopGain = 3.0
            ret.lateralTuning.indi.timeConstant = 1.0
            ret.lateralTuning.indi.actuatorEffectiveness = 1.0
            ret.steerActuatorDelay = 0.5

        elif candidate in [CAR.RAV4, CAR.RAV4H]:
            stop_and_go = True if (candidate in CAR.RAV4H) else False
            ret.safetyParam = 73
            ret.wheelbase = 2.65
            ret.steerRatio = 16.88  # 14.5 is spec end-to-end
            tire_stiffness_factor = 0.5533
            ret.mass = 3650. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.init('lqr')

            ret.lateralTuning.lqr.scale = 1500.0
            ret.lateralTuning.lqr.ki = 0.05

            ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            ret.lateralTuning.lqr.c = [1., 0.]
            ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
            ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
            ret.lateralTuning.lqr.dcGain = 0.002237852961363602

        elif candidate == CAR.COROLLA:
            stop_and_go = False
            ret.safetyParam = 100
            ret.wheelbase = 2.70
            ret.steerRatio = 18.27
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00003  # full torque for 20 deg at 80mph means 0.00007818594

        elif candidate == CAR.LEXUS_RX:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.79
            ret.steerRatio = 14.8
            tire_stiffness_factor = 0.5533
            ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.LEXUS_RXH:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.79
            ret.steerRatio = 16.  # 14.8 is spec end-to-end
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG  # mean between min and max
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00006  # full torque for 10 deg at 80mph means 0.00007818594

        elif candidate == CAR.LEXUS_RX_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.79
            ret.steerRatio = 14.8
            tire_stiffness_factor = 0.5533  # not optimized yet
            ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate in [CAR.CHR, CAR.CHRH]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.63906
            ret.steerRatio = 13.6
            tire_stiffness_factor = 0.7933
            ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.723],
                                                                    [0.0428]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate in [CAR.CAMRY, CAR.CAMRYH]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.82448
            ret.steerRatio = 13.7
            tire_stiffness_factor = 0.7933
            ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG  #mean between normal and hybrid
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.HIGHLANDER_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.84988  # 112.2 in = 2.84988 m
            ret.steerRatio = 16.0
            tire_stiffness_factor = 0.8
            ret.mass = 4700. * CV.LB_TO_KG + STD_CARGO_KG  # 4260 + 4-5 people
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.18
            ], [0.015]]  # community tuning
            ret.lateralTuning.pid.kf = 0.00012  # community tuning

        elif candidate in [CAR.HIGHLANDER, CAR.HIGHLANDERH]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.78
            ret.steerRatio = 16.0
            tire_stiffness_factor = 0.8
            ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG  #mean between normal and hybrid limited
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.18
            ], [0.015]]  # community tuning
            ret.lateralTuning.pid.kf = 0.00012  # community tuning

        elif candidate == CAR.AVALON:
            stop_and_go = False
            ret.safetyParam = 73
            ret.wheelbase = 2.82
            ret.steerRatio = 14.8  #Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download
            tire_stiffness_factor = 0.7983
            ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.17],
                                                                    [0.03]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.RAV4_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.68986
            ret.steerRatio = 14.3
            tire_stiffness_factor = 0.7933
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.mass = 3370. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.RAV4H_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.68986
            ret.steerRatio = 14.3
            tire_stiffness_factor = 0.7933
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.mass = 3800. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.63906
            ret.steerRatio = 13.9
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 3060. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate in [CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.8702
            ret.steerRatio = 16.0  # not optimized
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 3704. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.SIENNA:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 3.03
            ret.steerRatio = 16.0
            tire_stiffness_factor = 0.444
            ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.LEXUS_IS:
            stop_and_go = False
            ret.safetyParam = 77
            ret.wheelbase = 2.79908
            ret.steerRatio = 13.3
            tire_stiffness_factor = 0.444
            ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.LEXUS_CTH:
            stop_and_go = True
            ret.safetyParam = 100
            ret.wheelbase = 2.60
            ret.steerRatio = 18.6
            tire_stiffness_factor = 0.517
            ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG  # mean between min and max
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00007

        elif candidate == CAR.LEXUS_NXH:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.66
            ret.steerRatio = 14.7
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 4070 * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00006

        ret.steerRateCost = 1.
        ret.centerToFront = ret.wheelbase * 0.44

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay
        # Detect smartDSU, which intercepts ACC_CMD from the DSU allowing openpilot to send it
        smartDsu = 0x2FF in fingerprint[0]
        # In TSS2 cars the camera does long control
        ret.enableDsu = is_ecu_disconnected(
            fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate,
            Ecu.dsu) and candidate not in TSS2_CAR
        ret.enableGasInterceptor = 0x201 in fingerprint[0]
        # if the smartDSU is detected, openpilot can send ACC_CMD (and the smartDSU will block it from the DSU) or not (the DSU is "connected")
        ret.openpilotLongitudinalControl = ret.enableCamera and (
            smartDsu or ret.enableDsu or candidate in TSS2_CAR)
        cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera)
        cloudlog.warning("ECU DSU Simulated: %r", ret.enableDsu)
        cloudlog.warning("ECU Gas Interceptor: %r", ret.enableGasInterceptor)

        # 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. if (
            stop_and_go or ret.enableGasInterceptor) else 19. * CV.MPH_TO_MS

        # removing the DSU disables AEB and it's considered a community maintained feature
        # intercepting the DSU is a community feature since it requires unofficial hardware
        ret.communityFeature = ret.enableGasInterceptor or ret.enableDsu or smartDsu

        ret.longitudinalTuning.deadzoneBP = [0., 9.]
        ret.longitudinalTuning.deadzoneV = [0., .15]
        ret.longitudinalTuning.kpBP = [0., 5., 35.]
        ret.longitudinalTuning.kiBP = [0., 35.]

        if ret.enableGasInterceptor:
            ret.gasMaxBP = [0., 9., 35]
            ret.gasMaxV = [0.2, 0.5, 0.7]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiV = [0.18, 0.12]
        else:
            ret.gasMaxBP = [0.]
            ret.gasMaxV = [0.5]
            ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5]
            ret.longitudinalTuning.kiV = [0.54, 0.36]

        return ret
Exemplo n.º 7
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):  # pylint: disable=dangerous-default-value
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundai
        ret.radarOffCan = True
        # Most Hyundai car ports are community features for now
        ret.communityFeature = candidate not in [CAR.SONATA]

        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.4
        tire_stiffness_factor = 1.

        if candidate == CAR.SANTA_FE:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.766
            # Values from optimizer
            ret.steerRatio = 16.55  # 13.8 is spec end-to-end
            tire_stiffness_factor = 0.82
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]
            ret.lateralTuning.pid.kfBP = [0.]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.2, 0.35
            ], [0.05, 0.09]]
        elif candidate == CAR.SONATA:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 1513. + STD_CARGO_KG
            ret.wheelbase = 2.84
            ret.steerRatio = 13.27 * 1.15  # 15% higher at the center seems reasonable
            tire_stiffness_factor = 0.65
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.SONATA_2019:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 4497. * CV.LB_TO_KG
            ret.wheelbase = 2.804
            ret.steerRatio = 13.27 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.PALISADE:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 1999. + STD_CARGO_KG
            ret.wheelbase = 2.90
            ret.steerRatio = 13.75 * 1.15
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_SORENTO:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.1  # 10% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
            ret.lateralTuning.pid.kfV = [0.00006]
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 15.4  # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535
            tire_stiffness_factor = 0.385  # stiffnessFactor settled on 1.0081302973865127
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.HYUNDAI_GENESIS:
            ret.lateralTuning.pid.kfV = [0.00005]

            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
            ret.minSteerSpeed = 60 * CV.KPH_TO_MS
        elif candidate in [CAR.GENESIS_G90, CAR.GENESIS_G80]:
            ret.mass = 2200
            ret.wheelbase = 3.15
            ret.steerRatio = 12.069
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
            ret.minSteerSpeed = 60 * CV.KPH_TO_MS
        elif candidate == CAR.GENESIS_G80:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate == CAR.GENESIS_G90:
            ret.mass = 2200
            ret.wheelbase = 3.15
            ret.steerRatio = 12.069
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H]:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_STINGER:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 1825. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA:
            ret.lateralTuning.pid.kfV = [0.00006]
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  # Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA_EV:
            ret.lateralTuning.pid.kfV = [0.00006]
            ret.mass = 1685. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  # Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.IONIQ, CAR.IONIQ_EV_LTD]:
            ret.lateralTuning.pid.kfV = [0.00006]
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 31 * CV.MPH_TO_MS
        elif candidate == CAR.KIA_FORTE:
            ret.lateralTuning.pid.kfV = [0.00005]
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kfBP = [
                [0.], [0.], [0.]
            ]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]

        # these cars require a special panda safety mode due to missing counters and checksums in the messages
        if candidate in [
                CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_LTD, CAR.IONIQ, CAR.KONA_EV
        ]:
            ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay
        ret.sccBus = -1

        return ret
Exemplo n.º 8
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):  # pylint: disable=dangerous-default-value
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)
        ret.carName = "honda"

        if candidate in HONDA_BOSCH:
            ret.safetyModel = car.CarParams.SafetyModel.hondaBoschHarness if has_relay else car.CarParams.SafetyModel.hondaBoschGiraffe
            rdr_bus = 0 if has_relay else 2
            ret.enableCamera = is_ecu_disconnected(
                fingerprint[rdr_bus], FINGERPRINTS, ECU_FINGERPRINT, candidate,
                Ecu.fwdCamera) or has_relay
            ret.radarOffCan = True
            ret.openpilotLongitudinalControl = False
        else:
            ret.safetyModel = car.CarParams.SafetyModel.hondaNidec
            ret.enableCamera = is_ecu_disconnected(
                fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate,
                Ecu.fwdCamera) or has_relay
            ret.enableGasInterceptor = 0x201 in fingerprint[0]
            ret.openpilotLongitudinalControl = ret.enableCamera

        cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera)
        cloudlog.warning("ECU Gas Interceptor: %r", ret.enableGasInterceptor)

        ret.enableCruise = not ret.enableGasInterceptor
        ret.communityFeature = ret.enableGasInterceptor

        # Certain Hondas have an extra steering sensor at the bottom of the steering rack,
        # which improves controls quality as it removes the steering column torsion from feedback.
        # Tire stiffness factor fictitiously lower if it includes the steering column torsion effect.
        # For modeling details, see p.198-200 in "The Science of Vehicle Dynamics (2014), M. Guiggiani"
        ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0], [0]]
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kf = 0.00006  # conservative feed-forward

        eps_modified = False
        for fw in car_fw:
            if fw.ecu == "eps" and b"," in fw.fwVersion:
                eps_modified = True

        if candidate == CAR.CIVIC:
            stop_and_go = True
            ret.mass = CivicParams.MASS
            ret.wheelbase = CivicParams.WHEELBASE
            ret.centerToFront = CivicParams.CENTER_TO_FRONT
            ret.steerRatio = 15.38  # 10.93 is end-to-end spec
            if eps_modified:
                # stock request input values:     0x0000, 0x00DE, 0x014D, 0x01EF, 0x0290, 0x0377, 0x0454, 0x0610, 0x06EE
                # stock request output values:    0x0000, 0x0917, 0x0DC5, 0x1017, 0x119F, 0x140B, 0x1680, 0x1680, 0x1680
                # modified request output values: 0x0000, 0x0917, 0x0DC5, 0x1017, 0x119F, 0x140B, 0x1680, 0x2880, 0x3180
                # stock filter output values:     0x009F, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108
                # modified filter output values:  0x009F, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0400, 0x0480
                # note: max request allowed is 4096, but request is capped at 3840 in firmware, so modifications result in 2x max
                ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[
                    0, 2560, 8000
                ], [0, 2560, 3840]]
                ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                        [0.1]]
            else:
                ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[
                    0, 2560
                ], [0, 2560]]
                ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[1.1],
                                                                        [0.33]]
            tire_stiffness_factor = 1.

            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.54, 0.36]

        elif candidate in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL):
            stop_and_go = True
            ret.mass = CivicParams.MASS
            ret.wheelbase = CivicParams.WHEELBASE
            ret.centerToFront = CivicParams.CENTER_TO_FRONT
            ret.steerRatio = 15.38  # 10.93 is end-to-end spec
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 4096], [0, 4096]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 1.
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8],
                                                                    [0.24]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH):
            stop_and_go = True
            if not candidate == CAR.ACCORDH:  # Hybrid uses same brake msg as hatch
                ret.safetyParam = 1  # Accord(ICE), CRV 5G, and RDX 3G use an alternate user brake msg
            ret.mass = 3279. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.83
            ret.centerToFront = ret.wheelbase * 0.39
            ret.steerRatio = 16.33  # 11.82 is spec end-to-end
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 4096], [0, 4096]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.8467
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

            if eps_modified:
                ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                        [0.09]]
            else:
                ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                        [0.18]]

        elif candidate == CAR.ACURA_ILX:
            stop_and_go = False
            ret.mass = 3095. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.67
            ret.centerToFront = ret.wheelbase * 0.37
            ret.steerRatio = 18.61  # 15.3 is spec end-to-end
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 3840], [0, 3840]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.72
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8],
                                                                    [0.24]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate in (CAR.CRV, CAR.CRV_EU):
            stop_and_go = False
            ret.mass = 3572. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.62
            ret.centerToFront = ret.wheelbase * 0.41
            ret.steerRatio = 16.89  # as spec
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 1000], [0, 1000]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.444
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8],
                                                                    [0.24]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.CRV_5G:
            stop_and_go = True
            ret.safetyParam = 1  # Accord(ICE), CRV 5G, and RDX 3G use an alternate user brake msg
            ret.mass = 3410. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.66
            ret.centerToFront = ret.wheelbase * 0.41
            ret.steerRatio = 16.0  # 12.3 is spec end-to-end
            if eps_modified:
                # stock request input values:     0x0000, 0x00DB, 0x01BB, 0x0296, 0x0377, 0x0454, 0x0532, 0x0610, 0x067F
                # stock request output values:    0x0000, 0x0500, 0x0A15, 0x0E6D, 0x1100, 0x1200, 0x129A, 0x134D, 0x1400
                # modified request output values: 0x0000, 0x0500, 0x0A15, 0x0E6D, 0x1100, 0x1200, 0x1ACD, 0x239A, 0x2800
                ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[
                    0, 2560, 10000
                ], [0, 2560, 3840]]
                ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.21],
                                                                        [0.07]]
            else:
                ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[
                    0, 3840
                ], [0, 3840]]
                ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                    0.64
                ], [0.192]]
            tire_stiffness_factor = 0.677
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.CRV_HYBRID:
            stop_and_go = True
            ret.safetyParam = 1  # Accord(ICE), CRV 5G, and RDX 3G use an alternate user brake msg
            ret.mass = 1667. + STD_CARGO_KG  # mean of 4 models in kg
            ret.wheelbase = 2.66
            ret.centerToFront = ret.wheelbase * 0.41
            ret.steerRatio = 16.0  # 12.3 is spec end-to-end
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 4096], [0, 4096]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.677
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.18]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.FIT:
            stop_and_go = False
            ret.mass = 2644. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.53
            ret.centerToFront = ret.wheelbase * 0.39
            ret.steerRatio = 13.06
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 4096], [0, 4096]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.75
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.06]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.HRV:
            stop_and_go = False
            ret.mass = 3125 * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.61
            ret.centerToFront = ret.wheelbase * 0.41
            ret.steerRatio = 15.2
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096],
                                                                     [0, 4096]]
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.025]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.ACURA_RDX:
            stop_and_go = False
            ret.mass = 3935. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.68
            ret.centerToFront = ret.wheelbase * 0.38
            ret.steerRatio = 15.0  # as spec
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 1000], [0, 1000]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.444
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8],
                                                                    [0.24]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.ACURA_RDX_3G:
            stop_and_go = True
            ret.safetyParam = 1  # Accord(ICE), CRV 5G, and RDX 3G use an alternate user brake msg
            ret.mass = 4068. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.75
            ret.centerToFront = ret.wheelbase * 0.41
            ret.steerRatio = 11.95  # as spec
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840],
                                                                     [0, 3840]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.18]]
            tire_stiffness_factor = 0.677
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.ODYSSEY:
            stop_and_go = False
            ret.mass = 4471. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 3.00
            ret.centerToFront = ret.wheelbase * 0.41
            ret.steerRatio = 14.35  # as spec
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 4096], [0, 4096]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.82
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.45],
                                                                    [0.135]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.ODYSSEY_CHN:
            stop_and_go = False
            ret.mass = 1849.2 + STD_CARGO_KG  # mean of 4 models in kg
            ret.wheelbase = 2.90
            ret.centerToFront = ret.wheelbase * 0.41  # from CAR.ODYSSEY
            ret.steerRatio = 14.35
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 32767], [0, 32767]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.82
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.45],
                                                                    [0.135]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate in (CAR.PILOT, CAR.PILOT_2019):
            stop_and_go = False
            ret.mass = 4204. * CV.LB_TO_KG + STD_CARGO_KG  # average weight
            ret.wheelbase = 2.82
            ret.centerToFront = ret.wheelbase * 0.428
            ret.steerRatio = 17.25  # as spec
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 4096], [0, 4096]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.444
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.38],
                                                                    [0.11]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.RIDGELINE:
            stop_and_go = False
            ret.mass = 4515. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 3.18
            ret.centerToFront = ret.wheelbase * 0.41
            ret.steerRatio = 15.59  # as spec
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 4096], [0, 4096]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.444
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.38],
                                                                    [0.11]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        elif candidate == CAR.INSIGHT:
            stop_and_go = True
            ret.mass = 2987. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.centerToFront = ret.wheelbase * 0.39
            ret.steerRatio = 15.0  # 12.58 is spec end-to-end
            ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [
                [0, 4096], [0, 4096]
            ]  # TODO: determine if there is a dead zone at the top end
            tire_stiffness_factor = 0.82
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.18]]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kiV = [0.18, 0.12]

        else:
            raise ValueError("unsupported car %s" % candidate)

        # 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. Otherwise, add 0.5 mph margin to not
        # conflict with PCM acc
        ret.minEnableSpeed = -1. if (
            stop_and_go or ret.enableGasInterceptor) else 25.5 * CV.MPH_TO_MS

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        ret.gasMaxBP = [0.]  # m/s
        ret.gasMaxV = [0.6] if ret.enableGasInterceptor else [
            0.
        ]  # max gas allowed
        ret.brakeMaxBP = [5., 20.]  # m/s
        ret.brakeMaxV = [1., 0.8]  # max brake allowed

        ret.stoppingControl = True
        ret.startAccel = 0.5

        ret.steerActuatorDelay = 0.1
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.8

        return ret
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundai

        # Hyundai port is a community feature for now
        ret.communityFeature = True

        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.8
        tire_stiffness_factor = 1.

        ret.lateralTuning.pid.kd = 0.

        if candidate in [CAR.SANTA_FE, CAR.SANTA_FE_1]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.766
            # Values from optimizer
            ret.steerRatio = 16.55  # 13.8 is spec end-to-end
            tire_stiffness_factor = 0.82
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.2, 0.35
            ], [0.05, 0.09]]
        elif candidate in [CAR.SONATA, CAR.SONATA_H]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1513. + STD_CARGO_KG
            ret.wheelbase = 2.84
            ret.steerRatio = 13.27 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.PALISADE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1999. + STD_CARGO_KG
            ret.wheelbase = 2.90
            ret.steerRatio = 13.75 * 1.15
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_SORENTO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.1  # 10% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 15.4  # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535
            tire_stiffness_factor = 0.385  # stiffnessFactor settled on 1.0081302973865127
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.HYUNDAI_GENESIS:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
            ret.minSteerSpeed = 60 * CV.KPH_TO_MS
        elif candidate in [CAR.GENESIS_G90, CAR.GENESIS_G80]:
            ret.mass = 2200
            ret.wheelbase = 3.15
            ret.steerRatio = 12.069
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_STINGER:
            ret.lateralTuning.pid.kf = 0.00005
            ret.steerActuatorDelay = 0.08  # Stinger Limited AWD 3.3T stock value (Tunder's 2020)
            ret.steerLimitTimer = 0.01  # no timer on value changes, lightning fast up or down (Tunder's 2020)
            tire_stiffness_factor = 0.7  # LiveParameters (Tunder's 2020)
            ret.steerRateCost = 0.25  # i don't know what this actually does, but the car drives much better this way than at 1.0.  (Tunder)
            ret.mass = 1825. + STD_CARGO_KG
            ret.wheelbase = 2.906  # https://www.kia.com/us/en/stinger/specs
            ret.steerRatio = 10.28  # measured by wheel alignment machine/reported steering angle by OP, still being worked on.  2020 GT Limited AWD has a variable steering ratio ultimately ending in 10.28.  The ratio at 0-1 deg is unknown, but likely higher than 10.28 to soften steering movements at midline (Tunder)
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [
                [0.13], [0.05]
            ]  # any higher p value and it oscillates forever.  much lower and it doesn't turn enough (lazy)
        elif candidate == CAR.KONA:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.IONIQ:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.KONA_EV:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1685. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_NIRO_EV:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1737. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.IONIQ_EV_LTD:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.KIA_FORTE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_CEED:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1350. + STD_CARGO_KG
            ret.wheelbase = 2.65
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_SPORTAGE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.1  # 10% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 0.
        elif candidate == CAR.GRANDEUR:
            tire_stiffness_factor = 0.6
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.845
            ret.lateralTuning.init('lqr')
            ret.lateralTuning.lqr.scale = 2000.0
            ret.lateralTuning.lqr.ki = 0.01
            ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            ret.lateralTuning.lqr.c = [1., 0.]
            ret.lateralTuning.lqr.k = [-100., 450.]
            ret.lateralTuning.lqr.l = [0.22, 0.318]
            ret.lateralTuning.lqr.dcGain = 0.003
            ret.steerRatio = 13.7
            ret.steerActuatorDelay = 0.3
            ret.steerRateCost = 0.5
            ret.steerLimitTimer = 0.8

        elif candidate == CAR.K7_HYBRID:
            tire_stiffness_factor = 0.9
            ret.mass = 1685. + STD_CARGO_KG
            ret.wheelbase = 2.885
            ret.steerRatio = 13.7
            ret.steerActuatorDelay = 0.3
            ret.steerRateCost = 0.5
            ret.steerLimitTimer = 0.6
            ret.lateralTuning.init('lqr')
            ret.lateralTuning.lqr.scale = 2000.0
            ret.lateralTuning.lqr.ki = 0.03
            ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            ret.lateralTuning.lqr.c = [1., 0.]
            ret.lateralTuning.lqr.k = [-100., 450.]
            ret.lateralTuning.lqr.l = [0.22, 0.318]
            ret.lateralTuning.lqr.dcGain = 0.003

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.torque

        ret.longitudinalTuning.kpBP = [0., 5., 35.]
        ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
        ret.longitudinalTuning.kiBP = [0., 35.]
        ret.longitudinalTuning.kiV = [0.18, 0.12]
        ret.longitudinalTuning.deadzoneBP = [0.]
        ret.longitudinalTuning.deadzoneV = [0.]

        # steer, gas, brake limitations VS speed
        ret.steerMaxBP = [0.]
        ret.steerMaxV = [1.0]
        ret.gasMaxBP = [0.]
        ret.gasMaxV = [0.5]
        ret.brakeMaxBP = [0., 20.]
        ret.brakeMaxV = [1., 0.8]

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        ret.stoppingControl = True
        ret.startAccel = 0.0

        # ignore CAN2 address if L-CAN on the same BUS
        ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
                                                                         else 2 if 1056 in fingerprint[2] else -1
        ret.radarOffCan = ret.sccBus == -1
        ret.openpilotLongitudinalControl = bool(ret.sccBus
                                                and not ret.radarOffCan)
        ret.autoLcaEnabled = True

        return ret
Exemplo n.º 10
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundai
        ret.radarOffCan = True

        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.4
        tire_stiffness_factor = 1.

        if candidate == CAR.SANTA_FE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.766
            # Values from optimizer
            ret.steerRatio = 16.55  # 13.8 is spec end-to-end
            tire_stiffness_factor = 0.82
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.2, 0.35
            ], [0.05, 0.09]]
            ret.minSteerSpeed = 0.
        elif candidate == CAR.KIA_SORENTO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.1  # 10% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 0.
        elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.HYUNDAI_GENESIS:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
            ret.minSteerSpeed = 60 * CV.KPH_TO_MS
        elif candidate in [CAR.GENESIS_G90, CAR.GENESIS_G80]:
            ret.mass = 2200
            ret.wheelbase = 3.15
            ret.steerRatio = 12.069
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_STINGER:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1825. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 0.
        elif candidate == CAR.KONA:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.IONIQ:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.KONA_EV:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1685. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.IONIQ_EV_LTD:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.KIA_FORTE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        return ret
Exemplo n.º 11
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay=False):
    ret = car.CarParams.new_message()

    ret.carName = "gm"
    ret.carFingerprint = candidate
    ret.carVin = vin
    ret.isPandaBlack = has_relay

    ret.enableCruise = False

    # Presence of a camera on the object bus is ok.
    # Have to go to read_only if ASCM is online (ACC-enabled cars),
    # or camera is on powertrain bus (LKA cars without ACC).
    ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.CAM) or \
                       has_relay or \
                       candidate == CAR.CADILLAC_CT6
    ret.openpilotLongitudinalControl = ret.enableCamera
    tire_stiffness_factor = 0.444  # not optimized yet

    if candidate == CAR.VOLT:
      # supports stop and go, but initial engage must be above 18mph (which include conservatism)
      ret.minEnableSpeed = 18 * CV.MPH_TO_MS
      ret.mass = 1607. + STD_CARGO_KG
      ret.safetyModel = car.CarParams.SafetyModel.gm
      ret.wheelbase = 2.69
      ret.steerRatio = 15.7
      ret.steerRatioRear = 0.
      ret.centerToFront = ret.wheelbase * 0.4 # wild guess

    elif candidate == CAR.BOLT:
      # initial engage unkown - copied from Volt. Stop and go unknown.
      ret.minEnableSpeed = 18 * CV.MPH_TO_MS
      ret.mass = 1616. + STD_CARGO_KG
      ret.safetyModel = car.CarParams.SafetyModel.gm
      ret.wheelbase = 2.60096
      ret.steerRatio = 16.8
      ret.steerRatioRear = 0.
      ret.centerToFront = ret.wheelbase * 0.4 # wild guess

    elif candidate == CAR.MALIBU:
      # supports stop and go, but initial engage must be above 18mph (which include conservatism)
      ret.minEnableSpeed = 18 * CV.MPH_TO_MS
      ret.mass = 1496. + STD_CARGO_KG
      ret.safetyModel = car.CarParams.SafetyModel.gm
      ret.wheelbase = 2.83
      ret.steerRatio = 15.8
      ret.steerRatioRear = 0.
      ret.centerToFront = ret.wheelbase * 0.4 # wild guess

    elif candidate == CAR.HOLDEN_ASTRA:
      ret.mass = 1363. + STD_CARGO_KG
      ret.wheelbase = 2.662
      # Remaining parameters copied from Volt for now
      ret.centerToFront = ret.wheelbase * 0.4
      ret.minEnableSpeed = 18 * CV.MPH_TO_MS
      ret.safetyModel = car.CarParams.SafetyModel.gm
      ret.steerRatio = 15.7
      ret.steerRatioRear = 0.

    elif candidate == CAR.ACADIA:
      ret.minEnableSpeed = -1. # engage speed is decided by pcm
      ret.mass = 4353. * CV.LB_TO_KG + STD_CARGO_KG
      ret.safetyModel = car.CarParams.SafetyModel.gm
      ret.wheelbase = 2.86
      ret.steerRatio = 14.4  #end to end is 13.46
      ret.steerRatioRear = 0.
      ret.centerToFront = ret.wheelbase * 0.4

    elif candidate == CAR.BUICK_REGAL:
      ret.minEnableSpeed = 18 * CV.MPH_TO_MS
      ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2
      ret.safetyModel = car.CarParams.SafetyModel.gm
      ret.wheelbase = 2.83 #111.4 inches in meters
      ret.steerRatio = 14.4 # guess for tourx
      ret.steerRatioRear = 0.
      ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx

    elif candidate == CAR.CADILLAC_ATS:
      ret.minEnableSpeed = 18 * CV.MPH_TO_MS
      ret.mass = 1601. + STD_CARGO_KG
      ret.safetyModel = car.CarParams.SafetyModel.gm
      ret.wheelbase = 2.78
      ret.steerRatio = 15.3
      ret.steerRatioRear = 0.
      ret.centerToFront = ret.wheelbase * 0.49

    elif candidate == CAR.CADILLAC_CT6:
      # engage speed is decided by pcm
      ret.minEnableSpeed = -1.
      ret.mass = 4016. * CV.LB_TO_KG + STD_CARGO_KG
      ret.safetyModel = car.CarParams.SafetyModel.cadillac
      ret.wheelbase = 3.11
      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


    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, 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.]]
    ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.00]]
    ret.lateralTuning.pid.kf = 0.00004   # full torque for 20 deg at 80mph means 0.00007818594

    ret.steerMaxBP = [0.]  # m/s
    ret.steerMaxV = [1.]
    ret.gasMaxBP = [0.]
    ret.gasMaxV = [.5]
    ret.brakeMaxBP = [0.]
    ret.brakeMaxV = [1.]

    ret.longitudinalTuning.kpBP = [5., 35.]
    ret.longitudinalTuning.kpV = [2.4, 1.5]
    ret.longitudinalTuning.kiBP = [0.]
    ret.longitudinalTuning.kiV = [0.36]
    ret.longitudinalTuning.deadzoneBP = [0.]
    ret.longitudinalTuning.deadzoneV = [0.]

    ret.steerLimitAlert = True

    ret.stoppingControl = True
    ret.startAccel = 0.8

    ret.steerActuatorDelay = 0.1  # Default delay, not measured yet
    ret.steerRateCost = 1.0
    ret.steerControlType = car.CarParams.SteerControlType.torque

    return ret
Exemplo n.º 12
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, car_fw=[]):  # pylint: disable=dangerous-default-value
    ret = CarInterfaceBase.get_std_params(candidate, fingerprint, has_relay)

    ret.carName = "hyundai"
    ret.safetyModel = car.CarParams.SafetyModel.hyundai
    ret.radarOffCan = True

    # Most Hyundai car ports are community features for now
    ret.communityFeature = candidate not in [CAR.SONATA]

    ret.steerActuatorDelay = 0.4  # Default delay
    ret.steerRateCost = 0.45
    ret.steerLimitTimer = 0.8
    tire_stiffness_factor = 1.

    ret.longitudinalTuning.kfBP = [0., 5.]
    ret.longitudinalTuning.kfV = [1., 1.]

    ret.lateralTuning.pid.kiBP = [0., 1., 20.]
    ret.lateralTuning.pid.kpV = [0.01, 0.03, 0.03]
    ret.lateralTuning.pid.kpBP = [0., 10., 30.]
    ret.lateralTuning.pid.kiV = [0.001, 0.003, 0.003]
    ret.lateralTuning.pid.kfBP = [0., 10., 30.]
    ret.lateralTuning.pid.kfV = [0.00002, 0.00003, 0.00003]

    if candidate == CAR.SANTA_FE:
      ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.766
      # Values from optimizer
      ret.steerRatio = 16.55  # 13.8 is spec end-to-end
      tire_stiffness_factor = 0.82
    elif candidate in [CAR.SONATA, CAR.SONATA_HEV]:
      ret.mass = 1513. + STD_CARGO_KG
      ret.wheelbase = 2.84
      ret.steerRatio = 13.27 * 1.15   # 15% higher at the center seems reasonable
      tire_stiffness_factor = 0.65
    elif candidate == CAR.SONATA_2019:
      ret.mass = 4497. * CV.LB_TO_KG
      ret.wheelbase = 2.804
      ret.steerRatio = 13.27 * 1.15   # 15% higher at the center seems reasonable
    elif candidate == CAR.PALISADE:
      ret.mass = 1999. + STD_CARGO_KG
      ret.wheelbase = 2.90
      ret.steerRatio = 13.75 * 1.15
      ret.lateralTuning.pid.kiBP = [0., 1., 20.]
      ret.lateralTuning.pid.kpV = [0.01, 0.04, 0.05]
    elif candidate == CAR.KIA_SORENTO:
      ret.mass = 1985. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.1   # 10% higher at the center seems reasonable
    elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 15.4            # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535
      tire_stiffness_factor = 0.385    # stiffnessFactor settled on 1.0081302973865127
      ret.minSteerSpeed = 32 * CV.MPH_TO_MS
    elif candidate == CAR.HYUNDAI_GENESIS:
      ret.steerActuatorDelay = 0.3
      ret.steerRateCost = 0.45
      ret.mass = 2060. + STD_CARGO_KG
      ret.wheelbase = 3.01
      ret.steerRatio = 16.5
      ret.minSteerSpeed = 55 * CV.KPH_TO_MS
    elif candidate == CAR.GENESIS_G70:
      ret.lateralTuning.init('indi')
      ret.lateralTuning.indi.innerLoopGain = 3.0
      ret.lateralTuning.indi.outerLoopGain = 2.0
      ret.lateralTuning.indi.timeConstant = 1.0
      ret.lateralTuning.indi.actuatorEffectiveness = 1.5
      ret.steerActuatorDelay = 0.08
      ret.steerLimitTimer = 0.4
      tire_stiffness_factor = 1.125
      ret.steerRateCost = 1.0
      ret.mass = 1640.0 + STD_CARGO_KG
      ret.wheelbase = 2.84
      ret.steerRatio = 13.56
    elif candidate == CAR.GENESIS_G80:
      ret.steerActuatorDelay = 0.4
      ret.steerRateCost = 0.45
      ret.mass = 2060. + STD_CARGO_KG
      ret.wheelbase = 3.01
      ret.steerRatio = 16.5
    elif candidate == CAR.GENESIS_G90:
      ret.mass = 2060. + STD_CARGO_KG
      ret.wheelbase = 3.01
      ret.steerRatio = 16.5
    elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_HEV]:
      ret.mass = 3558. * CV.LB_TO_KG
      ret.wheelbase = 2.80
      ret.steerRatio = 13.75 * 1.15
      tire_stiffness_factor = 0.5
    elif candidate == CAR.KIA_STINGER:
      ret.mass = 1825. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.15   # 15% higher at the center seems reasonable
    elif candidate == CAR.KONA:
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73 * 1.15  # Spec
      tire_stiffness_factor = 0.385
    elif candidate in [CAR.KONA_HEV, CAR.KONA_EV]:
      ret.mass = 1685. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73 * 1.15  # Spec
      tire_stiffness_factor = 0.385
    elif candidate in [CAR.IONIQ_HEV, CAR.IONIQ_EV_LTD]:
      ret.mass = 1490. + STD_CARGO_KG   #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73 * 1.15   #Spec
      tire_stiffness_factor = 0.385
    elif candidate == CAR.KIA_FORTE:
      ret.mass = 3558. * CV.LB_TO_KG
      ret.wheelbase = 2.80
      ret.steerRatio = 13.75 * 1.15
      tire_stiffness_factor = 0.5
    elif candidate == CAR.KIA_CEED:
      ret.mass = 1350. + STD_CARGO_KG
      ret.wheelbase = 2.65
      ret.steerRatio = 13.75
      tire_stiffness_factor = 0.5
    elif candidate == CAR.KIA_SPORTAGE:
      ret.mass = 1985. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.1   # 10% higher at the center seems reasonable
    elif candidate == CAR.VELOSTER:
      ret.mass = 2960. * CV.LB_TO_KG
      ret.wheelbase = 2.69
      ret.steerRatio = 13.75 * 1.15
    elif candidate in [CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_EV]:
      ret.steerRatio = 13.73
      ret.mass = 1737. + STD_CARGO_KG
      ret.wheelbase = 2.7
      tire_stiffness_factor = 0.385
    elif candidate in [CAR.GRANDEUR, CAR.GRANDEUR_HEV]:
      ret.mass = 1719. + STD_CARGO_KG
      ret.wheelbase = 2.8
      ret.steerRatio = 12.5
    elif candidate in [CAR.KIA_CADENZA, CAR.KIA_CADENZA_HEV]:
      ret.mass = 1575. + STD_CARGO_KG
      ret.wheelbase = 2.85
      ret.steerRatio = 12.5
      ret.steerRateCost = 0.4

    # these cars require a special panda safety mode due to missing counters and checksums in the messages
    if candidate in [ CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_LTD, CAR.IONIQ_HEV, CAR.KONA_EV, CAR.KIA_SORENTO, CAR.SONATA_2019, 
                     CAR.KIA_OPTIMA, CAR.VELOSTER, CAR.KIA_STINGER, CAR.GENESIS_G70, CAR.SONATA_HEV, CAR.SANTA_FE, CAR.GENESIS_G90]:
      ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy

    ret.centerToFront = ret.wheelbase * 0.4

    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
                                                                         tire_stiffness_factor=tire_stiffness_factor)

    ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.fwdCamera) or has_relay
    ret.autoLcaEnabled = True

    return ret
Exemplo n.º 13
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):  # pylint: disable=dangerous-default-value
        op_params = opParams()
        use_lqr = op_params.get('use_lqr')
        prius_use_pid = False  # op_params.get('prius_use_pid')
        corollaTSS2_use_indi = False  # op_params.get('corollaTSS2_use_indi')
        rav4TSS2_use_indi = op_params.get('rav4TSS2_use_indi')

        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "toyota"
        ret.safetyModel = car.CarParams.SafetyModel.allOutput

        ret.steerActuatorDelay = 0.12  # Default delay, Prius has larger delay
        ret.steerLimitTimer = 0.4
        ret.hasZss = 0x23 in fingerprint[
            0]  # Detect whether car has accurate ZSS
        ret.steerRateCost = 0.5 if ret.hasZss else 1.0

        # Improved longitudinal tune
        if candidate in [
                CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.RAV4_TSS2,
                CAR.RAV4H_TSS2
        ]:
            ret.longitudinalTuning.deadzoneBP = [0., 8.05]
            ret.longitudinalTuning.deadzoneV = [.0, .14]
            ret.longitudinalTuning.kpBP = [0., 5., 20.]
            ret.longitudinalTuning.kpV = [1.3, 1.0, 0.7]
            ret.longitudinalTuning.kiBP = [0., 5., 12., 20., 27.]
            ret.longitudinalTuning.kiV = [.35, .23, .20, .17, .1]
            ret.stoppingBrakeRate = 0.1  # reach stopping target smoothly
            ret.startingBrakeRate = 2.0  # release brakes fast
            ret.startAccel = 1.2  # Accelerate from 0 faster
        else:
            # Default longitudinal tune
            ret.longitudinalTuning.deadzoneBP = [0., 9.]
            ret.longitudinalTuning.deadzoneV = [0., .15]
            ret.longitudinalTuning.kpBP = [0., 5., 35.]
            ret.longitudinalTuning.kiBP = [0., 35.]
            ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5]
            ret.longitudinalTuning.kiV = [0.54, 0.36]

        CARS_NOT_PID = [CAR.RAV4, CAR.RAV4H]
        if not prius_use_pid:
            CARS_NOT_PID.append(CAR.PRIUS)

        if candidate not in CARS_NOT_PID and not use_lqr:  # These cars use LQR/INDI
            ret.lateralTuning.init('pid')
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]

        if candidate == CAR.PRIUS:
            stop_and_go = True
            ret.safetyParam = 54  # see conversion factor for STEER_TORQUE_EPS in dbc file
            ret.wheelbase = 2.70
            ret.steerRatio = 13.4  # unknown end-to-end spec
            tire_stiffness_factor = 0.6371  # hand-tune
            ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG
            ret.steerActuatorDelay = 0.3

            if prius_use_pid:
                ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.07],
                                                                        [0.04]]
                ret.lateralTuning.pid.kdV = [0.]
                ret.lateralTuning.pid.kf = 0.00009531750004645412
                ret.lateralTuning.pid.newKfTuned = True
            else:
                ret.lateralTuning.init('indi')
                ret.lateralTuning.indi.innerLoopGainV = [4.0]
                ret.lateralTuning.indi.outerLoopGainV = [3.0]
                ret.lateralTuning.indi.timeConstantV = [
                    0.1
                ] if ret.hasZss else [1.0]
                ret.lateralTuning.indi.actuatorEffectivenessV = [1.0]

        elif candidate in [CAR.RAV4, CAR.RAV4H]:
            stop_and_go = True if (candidate in CAR.RAV4H) else False
            ret.safetyParam = 73
            ret.wheelbase = 2.65
            ret.steerRatio = 16.88  # 14.5 is spec end-to-end
            tire_stiffness_factor = 0.5533
            ret.mass = 3650. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.init('lqr')

            ret.lateralTuning.lqr.scale = 1500.0
            ret.lateralTuning.lqr.ki = 0.05

            ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            ret.lateralTuning.lqr.c = [1., 0.]
            ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
            ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
            ret.lateralTuning.lqr.dcGain = 0.002237852961363602

        elif candidate == CAR.COROLLA:
            stop_and_go = False
            ret.safetyParam = 88
            ret.wheelbase = 2.70
            ret.steerRatio = 17.43
            ret.minSpeedCan = 0.1 * CV.KPH_TO_MS
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kpV = [[
                20, 31
            ], [0.05, 0.12]]  # 45 to 70 mph
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kiV = [[20, 31],
                                                                     [
                                                                         0.001,
                                                                         0.01
                                                                     ]]
            ret.lateralTuning.pid.kdBP, ret.lateralTuning.pid.kdV = [[20, 31],
                                                                     [
                                                                         0.0,
                                                                         0.0
                                                                     ]]
            # ret.lateralTuning.pid.kf = 0.00003  # full torque for 20 deg at 80mph means 0.00007818594
            ret.lateralTuning.pid.kf = 0.000055  # full torque for 20 deg at 80mph means 0.00007818594
            ret.lateralTuning.pid.newKfTuned = True

        elif candidate == CAR.OLD_CAR:
            stop_and_go = True
            ret.safetyParam = 100
            ret.wheelbase = 2.830  # This is updated for BMW
            ret.steerRatio = 17.9  # This is updated for BMW
            tire_stiffness_factor = 0.444
            ret.mass = 2000  # This is updated for BMW
            ret.longitudinalTuning.kpBP = [0., 15., 22.]
            ret.longitudinalTuning.kiBP = [0., 15., 22.]
            ret.gasMaxBP = [0., 5., 12., 25.]
            ret.gasMaxV = [0.5, 0.6, 0.8, 1.0]
            #+      ret.gasMaxV = [0.1, 0.4, 0.8]

            ret.longitudinalTuning.deadzoneBP = [0.]
            ret.longitudinalTuning.deadzoneV = [0.]

            ret.enableGasInterceptor = True  #OLD_CAR USES ALWAYS INTERCEPTOR MESSAGE FOR GAS

            if ret.enableGasInterceptor:
                ret.longitudinalTuning.kpV = [0.4, 0.6, 0.7]
                ret.longitudinalTuning.kiV = [0.2, 0.35, 0.5]

            ret.lateralTuning.init('lqr')
            ret.lateralTuning.lqr.scale = 1500.0
            ret.lateralTuning.lqr.ki = 0.07

            ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            ret.lateralTuning.lqr.c = [1., 0.]
            ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
            ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
            ret.lateralTuning.lqr.dcGain = 0.002237852961363602

        elif candidate == CAR.LEXUS_RX:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.79
            ret.steerRatio = 14.8
            tire_stiffness_factor = 0.5533
            ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.LEXUS_RXH:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.79
            ret.steerRatio = 16.  # 14.8 is spec end-to-end
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG  # mean between min and max
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00006  # full torque for 10 deg at 80mph means 0.00007818594

        elif candidate == CAR.LEXUS_RX_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.79
            ret.steerRatio = 14.8
            tire_stiffness_factor = 0.5533  # not optimized yet
            ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.LEXUS_RXH_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.79
            ret.steerRatio = 16.0  # 14.8 is spec end-to-end
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 4481.0 * CV.LB_TO_KG + STD_CARGO_KG  # mean between min and max
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.15]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate in [CAR.CHR, CAR.CHRH]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.63906
            ret.steerRatio = 13.6
            tire_stiffness_factor = 0.7933
            ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.723],
                                                                    [0.0428]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate in [
                CAR.CAMRY, CAR.CAMRYH, CAR.CAMRY_TSS2, CAR.CAMRYH_TSS2
        ]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.82448
            ret.steerRatio = 13.7
            tire_stiffness_factor = 0.7933
            ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate in [CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.84988  # 112.2 in = 2.84988 m
            ret.steerRatio = 16.0
            tire_stiffness_factor = 0.8
            ret.mass = 4700. * CV.LB_TO_KG + STD_CARGO_KG  # 4260 + 4-5 people
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.18
            ], [0.015]]  # community tuning
            ret.lateralTuning.pid.kf = 0.00012  # community tuning

        elif candidate in [CAR.HIGHLANDER, CAR.HIGHLANDERH]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.78
            ret.steerRatio = 16.0
            tire_stiffness_factor = 0.8
            ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid limited
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.18
            ], [0.015]]  # community tuning
            ret.lateralTuning.pid.kf = 0.00012  # community tuning

        elif candidate == CAR.AVALON:
            stop_and_go = False
            ret.safetyParam = 73
            ret.wheelbase = 2.82
            ret.steerRatio = 14.8  # Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download
            tire_stiffness_factor = 0.7983
            ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG  # mean between normal and hybrid
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.17],
                                                                    [0.03]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.RAV4_TSS2:
            stop_and_go = True
            ret.safetyParam = 56
            ret.wheelbase = 2.68986
            ret.steerRatio = 14.3
            tire_stiffness_factor = 0.7933
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15],
                                                                    [0.05]]
            ret.lateralTuning.pid.kdV = [0.1]
            ret.mass = 3370. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kf = 0.00004
            for fw in car_fw:
                if fw.ecu == "eps" and fw.fwVersion == b"8965B42170\x00\x00\x00\x00\x00\x00":
                    ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                        0.6
                    ], [0.1]]
                    ret.lateralTuning.pid.kf = 0.00007818594
                    break

            if rav4TSS2_use_indi:  # Rav4 2020 TSS2 Tune, needs to be verified, based on cgwtuning
                ret.lateralTuning.init('indi')
                ret.lateralTuning.indi.innerLoopGainBP = [16.7, 25]
                ret.lateralTuning.indi.innerLoopGainV = [15, 15]
                ret.lateralTuning.indi.outerLoopGainBP = [
                    8.3, 11.1, 13.9, 16.7, 19.4, 22.2, 25, 30.1, 33.3, 36.1
                ]
                ret.lateralTuning.indi.outerLoopGainV = [
                    4.7, 6.1, 8.35, 10.5, 12.8, 14.99, 16, 17, 18, 19
                ]
                ret.lateralTuning.indi.timeConstantBP = [
                    8.3, 11.1, 13.9, 16.7, 19.4, 22.2, 25, 30.1, 33.3, 36.1
                ]
                ret.lateralTuning.indi.timeConstantV = [
                    1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.0, 4.0, 4.0
                ]
                ret.lateralTuning.indi.actuatorEffectivenessBP = [16.7, 25]
                ret.lateralTuning.indi.actuatorEffectivenessV = [15, 15]
                ret.steerRateCost = 0.3

        elif candidate == CAR.RAV4H_TSS2:
            stop_and_go = True
            ret.safetyParam = 56
            ret.wheelbase = 2.68986
            ret.steerRatio = 14.3
            tire_stiffness_factor = 0.7933
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15],
                                                                    [0.05]]
            ret.lateralTuning.pid.kdV = [0.1]
            ret.mass = 3800. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kf = 0.00004
            for fw in car_fw:
                if fw.ecu == "eps" and fw.fwVersion == b"8965B42170\x00\x00\x00\x00\x00\x00":
                    ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                        0.6
                    ], [0.1]]
                    ret.lateralTuning.pid.kf = 0.00007818594
                    break

            if rav4TSS2_use_indi:  # Rav4 2020 TSS2 Tune, based on cgwtuning, needs to be verified
                ret.lateralTuning.init('indi')
                ret.lateralTuning.indi.innerLoopGainBP = [16.7, 25]
                ret.lateralTuning.indi.innerLoopGainV = [15, 15]
                ret.lateralTuning.indi.outerLoopGainBP = [
                    8.3, 11.1, 13.9, 16.7, 19.4, 22.2, 25, 30.1, 33.3, 36.1
                ]
                ret.lateralTuning.indi.outerLoopGainV = [
                    4.7, 6.1, 8.35, 10.5, 12.8, 14.99, 16, 17, 18, 19
                ]
                ret.lateralTuning.indi.timeConstantBP = [
                    8.3, 11.1, 13.9, 16.7, 19.4, 22.2, 25, 30.1, 33.3, 36.1
                ]
                ret.lateralTuning.indi.timeConstantV = [
                    1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.0, 4.0, 4.0
                ]
                ret.lateralTuning.indi.actuatorEffectivenessBP = [16.7, 25]
                ret.lateralTuning.indi.actuatorEffectivenessV = [15, 15]
                ret.steerRateCost = 0.3

        elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]:
            stop_and_go = True
            ret.safetyParam = 54
            ret.wheelbase = 2.67  # Average between 2.70 for sedan and 2.64 for hatchback
            ret.steerRatio = 15.33
            tire_stiffness_factor = 0.996  # not optimized yet
            ret.mass = 3060. * CV.LB_TO_KG + STD_CARGO_KG

            if corollaTSS2_use_indi:  # birdman6450#7399's Corolla 2020 TSS2 Tune
                ret.lateralTuning.init('indi')
                ret.lateralTuning.indi.innerLoopGainBP = [18, 22, 26]
                ret.lateralTuning.indi.innerLoopGainV = [9, 12, 15]
                ret.lateralTuning.indi.outerLoopGainBP = [18, 22, 26]
                ret.lateralTuning.indi.outerLoopGainV = [8, 11, 14.99]
                ret.lateralTuning.indi.timeConstantBP = [18, 22, 26]
                ret.lateralTuning.indi.timeConstantV = [1, 3, 4.5]
                ret.lateralTuning.indi.actuatorEffectivenessBP = [18, 22, 26]
                ret.lateralTuning.indi.actuatorEffectivenessV = [9, 12, 15]
                ret.steerActuatorDelay = 0.42 - 0.2
            else:
                ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                        [0.1]]
                ret.lateralTuning.pid.kf = 0.00007818594
                # ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[.028], [.0012]]  # birdman6450#7399's Corolla 2020 PIF Tune
                # ret.lateralTuning.pid.kdV = [0.]
                # ret.lateralTuning.pid.kf = 0.000153263811757641
                # ret.lateralTuning.pid.newKfTuned = True
                # ret.steerActuatorDelay = 0.48 - 0.2

        elif candidate in [CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.8702
            ret.steerRatio = 16.0  # not optimized
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 3704. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.LEXUS_ESH:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.8190
            ret.steerRatio = 16.06
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 3682. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.SIENNA:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 3.03
            ret.steerRatio = 15.5
            tire_stiffness_factor = 0.444
            ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19],
                                                                    [0.02]]
            ret.lateralTuning.pid.kf = 0.00007818594

        elif candidate == CAR.LEXUS_IS:
            stop_and_go = False
            ret.safetyParam = 77
            ret.wheelbase = 2.79908
            ret.steerRatio = 13.3
            tire_stiffness_factor = 0.444
            ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.LEXUS_CTH:
            stop_and_go = True
            ret.safetyParam = 100
            ret.wheelbase = 2.60
            ret.steerRatio = 18.6
            tire_stiffness_factor = 0.517
            ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG  # mean between min and max
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3],
                                                                    [0.05]]
            ret.lateralTuning.pid.kf = 0.00007

        elif candidate in [CAR.LEXUS_NXH, CAR.LEXUS_NX]:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.66
            ret.steerRatio = 14.7
            tire_stiffness_factor = 0.444  # not optimized yet
            ret.mass = 4070 * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6],
                                                                    [0.1]]
            ret.lateralTuning.pid.kf = 0.00006

        elif candidate == CAR.PRIUS_TSS2:
            stop_and_go = True
            ret.safetyParam = 73
            ret.wheelbase = 2.70002  # from toyota online sepc.
            ret.steerRatio = 13.4  # True steerRation from older prius
            tire_stiffness_factor = 0.6371  # hand-tune
            ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.35],
                                                                    [0.15]]
            ret.lateralTuning.pid.kf = 0.00007818594

        if use_lqr:
            ret.lateralTuning.init('lqr')

            ret.lateralTuning.lqr.scale = 1500.0
            ret.lateralTuning.lqr.ki = 0.05

            ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            ret.lateralTuning.lqr.c = [1., 0.]
            ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
            ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
            ret.lateralTuning.lqr.dcGain = 0.002237852961363602

        ret.centerToFront = ret.wheelbase * 0.44

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # old car has to enable camera simulation, since we don't have the TSS peripherals
        ret.enableCamera = (candidate == CAR.OLD_CAR) or is_ecu_disconnected(
            fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate,
            Ecu.fwdCamera) or has_relay

        # Detect smartDSU, which intercepts ACC_CMD from the DSU allowing openpilot to send it
        smartDsu = 0x2FF in fingerprint[0]
        # TODO: use FW query for the enableDsu flag
        # In TSS2 cars the camera does long control
        ret.enableDsu = is_ecu_disconnected(
            fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate,
            Ecu.dsu) and candidate not in NO_DSU_CAR

        ret.enableGasInterceptor = (candidate
                                    == CAR.OLD_CAR) or 0x201 in fingerprint[0]

        # if the smartDSU is detected, openpilot can send ACC_CMD (and the smartDSU will block it from the DSU) or not (the DSU is "connected")
        ret.openpilotLongitudinalControl = (candidate == CAR.OLD_CAR) or (
            ret.enableCamera and
            (smartDsu or ret.enableDsu or candidate in TSS2_CAR))
        cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera)
        cloudlog.warning("ECU DSU Simulated: %r", ret.enableDsu)
        cloudlog.warning("ECU Gas Interceptor: %r", ret.enableGasInterceptor)

        # 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. if (
            stop_and_go or ret.enableGasInterceptor) else MIN_ACC_SPEED

        # removing the DSU disables AEB and it's considered a community maintained feature
        # intercepting the DSU is a community feature since it requires unofficial hardware
        ret.communityFeature = ret.enableGasInterceptor or ret.enableDsu or smartDsu

        return ret
Exemplo n.º 14
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):  # pylint: disable=dangerous-default-value
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundai
        ret.radarOffCan = True

        # Most Hyundai car ports are community features for now
        ret.communityFeature = candidate not in [CAR.SONATA]

        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.4
        tire_stiffness_factor = 1.

        if candidate == CAR.SANTA_FE:
            ret.lateralTuning.pid.kf = 0.000050
            ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.766
            # Values from optimizer
            ret.steerRatio = 16.55  # 13.8 is spec end-to-end
            tire_stiffness_factor = 0.82
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.2, 0.35
            ], [0.05, 0.09]]
        elif candidate == CAR.SONATA:
            ret.lateralTuning.init('indi')
            ret.lateralTuning.indi.innerLoopGain = 3  #3.3 #3.8 2.2 1.62 was 3 was 4 outer and inner are gains. Higher values = more steering
            ret.lateralTuning.indi.outerLoopGain = 2  #2.3#2.8was 2.3 # 3.0 2.8 was 3.0 - good. kinda twitchy 3.5 was 4.05 2.0 outer and inner are gains. Higher values = more steering
            ret.lateralTuning.indi.timeConstant = 0.8  # 1 1.3 was 1.75 was 1.49 was 1.60 was 1.49, responded to bumps. was 1.0 timeconstant is smoothing. Higher values == more smoothing
            ret.lateralTuning.indi.actuatorEffectiveness = 1  #was 0.7 0.9 was 1.2. 1.2 was 1.1 - almost good, tad too much power 1.45 1.62 was 1.5 how much it steers. Lower values == more steering
            ret.steerActuatorDelay = 0.14  #was .16 # 0.2, tad too early steer .52 0.53 was 0.56 was 0.52 was 0.6 - 0.08 on tunder
            ret.steerLimitTimer = 0.4  #best working so far in the entire group was 0.4 stock is 0.01, 0.4 works well, trying 0.2, 0.1 for quicker turn in.  0.1 is strong on highway, notchy in town
            #ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1516. + STD_CARGO_KG  #was 1513
            ret.wheelbase = 2.84
            ret.steerRatio = 15.4192  # was 13.27 * 1.15. this comes from live params
            tire_stiffness_factor = 1.00  # was 0.65 this comes from live params
            #ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
            #ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
        elif candidate == CAR.SONATA_2019:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 4498. * CV.LB_TO_KG
            ret.wheelbase = 2.804
            ret.steerRatio = 13.27 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.PALISADE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1999. + STD_CARGO_KG
            ret.wheelbase = 2.90
            ret.steerRatio = 13.75 * 1.15
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_SORENTO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 01986. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.1  # 10% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 15.4  # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535
            tire_stiffness_factor = 0.385  # stiffnessFactor settled on 1.0081302973865127
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.HYUNDAI_GENESIS:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
            ret.minSteerSpeed = 60 * CV.KPH_TO_MS
        elif candidate == CAR.GENESIS_G80:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate == CAR.GENESIS_G90:
            ret.mass = 2200
            ret.wheelbase = 3.15
            ret.steerRatio = 12.069
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KIA_STINGER:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1825. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  # Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA_EV:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1685. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  # Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.IONIQ, CAR.IONIQ_EV_LTD]:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS
        elif candidate == CAR.KIA_FORTE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]

        # these cars require a special panda safety mode due to missing counters and checksums in the messages
        if candidate in [
                CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_LTD, CAR.IONIQ, CAR.KONA_EV
        ]:
            ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        return ret
Exemplo n.º 15
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):

        ret = car.CarParams.new_message()

        ret.carName = "hyundai"
        ret.carFingerprint = candidate
        ret.isPandaBlack = has_relay
        ret.safetyModel = car.CarParams.SafetyModel.hyundai
        ret.enableCruise = True  # stock acc
        ret.minSteerSpeed = 0  # 5 km/h

        ret.steerActuatorDelay = 0.10  # Default delay   0.15
        ret.steerRateCost = 0.45
        ret.steerLimitTimer = 0.8
        tire_stiffness_factor = 0.7
        #ret.radarOffCan = False
        """
      0.7.5
      ret.steerActuatorDelay = 0.1  # Default delay   0.1
      ret.steerRateCost = 0.5
      ret.steerLimitTimer = 0.4
      tire_stiffness_factor = 1
    """
        """
      0.7.3
      ret.steerActuatorDelay = 0.10  # Default delay   0.15
      ret.steerRateCost = 0.45
      ret.steerLimitTimer = 0.8
      tire_stiffness_factor = 0.7
    """

        if candidate == CAR.SANTAFE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1830. + STD_CARGO_KG
            ret.wheelbase = 2.765
            # Values from optimizer
            ret.steerRatio = 13.8  # 13.8 is spec end-to-end
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.SORENTO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1950. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.GENESIS:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate in [CAR.K5, CAR.SONATA]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1470. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 12.75
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.SONATA_TURBO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1565. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.K5_HEV:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1595. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 12.75
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate in [CAR.GRANDEUR, CAR.K7]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1570. + STD_CARGO_KG
            ret.wheelbase = 2.885
            ret.steerRatio = 12.5
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate in [CAR.GRANDEUR_HEV, CAR.K7_HEV]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1675. + STD_CARGO_KG
            ret.wheelbase = 2.845
            ret.steerRatio = 12.0  #12.5
            ret.steerRateCost = 0.4  #0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 32.4 KPH ~ 79.2 KPH
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.STINGER:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1825. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.KONA:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1330. + STD_CARGO_KG
            ret.wheelbase = 2.6
            ret.steerRatio = 13.5  #Spec
            ret.steerRateCost = 0.4
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.KONA_HEV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1330. + STD_CARGO_KG
            ret.wheelbase = 2.6
            ret.steerRatio = 13.5  #Spec
            ret.steerRateCost = 0.4
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.KONA_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1330. + STD_CARGO_KG
            ret.wheelbase = 2.6
            ret.steerRatio = 13.5  #Spec
            ret.steerRateCost = 0.4
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.NIRO_HEV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1425. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.NIRO_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1425. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.IONIQ_HEV:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.IONIQ_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            ret.steerRatio = 13.25  #Spec
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.NEXO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1885. + STD_CARGO_KG
            ret.wheelbase = 2.79
            ret.steerRatio = 12.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.MOHAVE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2250. + STD_CARGO_KG
            ret.wheelbase = 2.895
            ret.steerRatio = 14.1
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.I30:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1380. + STD_CARGO_KG
            ret.wheelbase = 2.65
            ret.steerRatio = 13.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]
        elif candidate == CAR.AVANTE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.5  # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535
            tire_stiffness_factor = 0.385  # stiffnessFactor settled on 1.0081302973865127
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                9., 22.
            ], [9., 22.]]  # 9m/s = 32.4km/h  ~  22m/s = 79.2 km/h
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.1, 0.11
            ], [0.02, 0.05]]

        ret.minEnableSpeed = -1.  # enable is done by stock ACC, so ignore this

        ret.longitudinalTuning.kpBP = [0., 5., 35.]
        ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
        ret.longitudinalTuning.kiBP = [0., 35.]
        ret.longitudinalTuning.kiV = [0.18, 0.12]
        ret.longitudinalTuning.deadzoneBP = [0.]
        ret.longitudinalTuning.deadzoneV = [0.]

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.torque

        # steer, gas, brake limitations VS speed
        ret.steerMaxBP = [0.]
        ret.steerMaxV = [1.0]
        ret.gasMaxBP = [0.]
        ret.gasMaxV = [0.5]
        ret.brakeMaxBP = [0., 20.]
        ret.brakeMaxV = [1., 0.8]

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay
        ret.openpilotLongitudinalControl = False

        ret.stoppingControl = True
        ret.startAccel = 0.0

        # ignore CAN2 address if L-CAN on the same BUS
        ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
                                                                         else 2 if 1056 in fingerprint[2] else -1
        ret.autoLcaEnabled = 0

        return ret
Exemplo n.º 16
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   vin="",
                   has_relay=False):
        ret = car.CarParams.new_message()

        ret.carName = "subaru"
        ret.radarOffCan = True
        ret.carFingerprint = candidate
        ret.carVin = vin
        ret.isPandaBlack = has_relay
        ret.safetyModel = car.CarParams.SafetyModel.subaru

        ret.enableCruise = True
        ret.steerLimitAlert = True

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               ECU.CAM) or has_relay

        ret.steerRateCost = 0.7

        if candidate in [CAR.IMPREZA]:
            ret.mass = 1568. + STD_CARGO_KG
            ret.wheelbase = 2.67
            ret.centerToFront = ret.wheelbase * 0.5
            ret.steerRatio = 15
            ret.steerActuatorDelay = 0.4  # end-to-end angle controller
            ret.lateralTuning.pid.kf = 0.00005
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[
                0., 20.
            ], [0., 20.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.3],
                                                                    [
                                                                        0.02,
                                                                        0.03
                                                                    ]]
            ret.steerMaxBP = [0.]  # m/s
            ret.steerMaxV = [1.]

        ret.steerControlType = car.CarParams.SteerControlType.torque
        ret.steerRatioRear = 0.
        # testing tuning

        # No long control in subaru
        ret.gasMaxBP = [0.]
        ret.gasMaxV = [0.]
        ret.brakeMaxBP = [0.]
        ret.brakeMaxV = [0.]
        ret.longitudinalTuning.deadzoneBP = [0.]
        ret.longitudinalTuning.deadzoneV = [0.]
        ret.longitudinalTuning.kpBP = [0.]
        ret.longitudinalTuning.kpV = [0.]
        ret.longitudinalTuning.kiBP = [0.]
        ret.longitudinalTuning.kiV = [0.]

        # end from gm

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass, ret.wheelbase, ret.centerToFront)

        return ret
Exemplo n.º 17
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):  # pylint: disable=dangerous-default-value
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy
        if candidate in [CAR.SONATA]:
            ret.safetyModel = car.CarParams.SafetyModel.hyundai

        # Most Hyundai car ports are community features for now
        ret.communityFeature = candidate not in [CAR.SONATA]

        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.8
        tire_stiffness_factor = 1.

        if candidate in [CAR.SANTA_FE, CAR.SANTA_FE_1]:
            ret.mass = 1694 + STD_CARGO_KG
            ret.wheelbase = 2.766

        elif candidate == CAR.SONATA_2019:
            ret.mass = 4497. * CV.LB_TO_KG
            ret.wheelbase = 2.804

        elif candidate == CAR.PALISADE:
            ret.mass = 1999. + STD_CARGO_KG
            ret.wheelbase = 2.90

        elif candidate == CAR.KIA_SORENTO:
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78

        elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385
            ret.minSteerSpeed = 32 * CV.MPH_TO_MS

        elif candidate == CAR.HYUNDAI_GENESIS:
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.minSteerSpeed = 60 * CV.KPH_TO_MS

        elif candidate == CAR.GENESIS_G80:
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5

        elif candidate == CAR.GENESIS_G90:
            ret.mass = 2200
            ret.wheelbase = 3.15

        elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H]:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5

        elif candidate == CAR.KIA_STINGER:
            tire_stiffness_factor = 1.125  # LiveParameters (Tunder's 2020)
            ret.steerRateCost = 1.0
            ret.mass = 1825.0 + STD_CARGO_KG
            ret.wheelbase = 2.906  # https://www.kia.com/us/en/stinger/specs
            ret.steerRatio = 13.56

        elif candidate == CAR.KONA:
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385

        elif candidate in [CAR.KONA_HEV, CAR.KONA_EV]:
            ret.mass = 1685. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385

        elif candidate in [CAR.IONIQ, CAR.IONIQ_EV_LTD]:
            ret.mass = 1490. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385

        elif candidate == CAR.KIA_FORTE:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80

        elif candidate == CAR.KIA_CEED:
            ret.mass = 1350. + STD_CARGO_KG
            ret.wheelbase = 2.65

        elif candidate == CAR.KIA_SPORTAGE:
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.minSteerSpeed = 0.

        elif candidate in [CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_EV]:
            ret.mass = 1737. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385

        elif candidate in [CAR.KIA_CARDENZA, CAR.KIA_CARDENZA_HEV]:
            ret.mass = 1575. + STD_CARGO_KG
            ret.wheelbase = 2.85

        elif candidate in [CAR.SONATA, CAR.SONATA_H]:
            ret.mass = 1513. + STD_CARGO_KG
            ret.wheelbase = 2.84
            tire_stiffness_factor = 0.65

        elif candidate in [CAR.GRANDEUR, CAR.GRANDEUR_HEV]:

            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.845
            tire_stiffness_factor = 0.6

        # LQR control by default

        ret.lateralTuning.init('lqr')

        ret.lateralTuning.lqr.scale = 1700.0
        ret.lateralTuning.lqr.ki = 0.03

        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-105.0, 450.0]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = 0.003

        ret.steerRatio = 15.2
        ret.steerActuatorDelay = 0.4
        ret.steerRateCost = 0.55
        ret.steerLimitTimer = 1.3

        ret.steerMaxBP = [30. * CV.KPH_TO_MS, 50. * CV.KPH_TO_MS]
        ret.steerMaxV = [1., 1.5]

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.torque

        ret.longitudinalTuning.kpBP = [0., 10., 40.]
        ret.longitudinalTuning.kpV = [1.2, 0.6, 0.2]
        ret.longitudinalTuning.kiBP = [0., 10., 30., 40.]
        ret.longitudinalTuning.kiV = [0.05, 0.02, 0.01, 0.005]
        ret.longitudinalTuning.deadzoneBP = [0., 40]
        ret.longitudinalTuning.deadzoneV = [0., 0.02]

        # steer, gas, brake limitations VS speed

        ret.gasMaxBP = [0., 10., 40.]
        ret.gasMaxV = [0.5, 0.5, 0.5]
        ret.brakeMaxBP = [0., 20.]
        ret.brakeMaxV = [1., 0.8]

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        ret.stoppingControl = True
        ret.startAccel = 0.0

        # ignore CAN2 address if L-CAN on the same BUS
        ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
            else 2 if 1056 in fingerprint[2] else -1
        ret.radarOffCan = ret.sccBus == -1
        ret.openpilotLongitudinalControl = False  # TODO make ui toggle
        ret.enableCruise = not ret.radarOffCan
        ret.autoLcaEnabled = True
        ret.spasEnabled = False

        return ret
Exemplo n.º 18
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundai

        # Hyundai port is a community feature for now
        ret.communityFeature = False

        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.8
        tire_stiffness_factor = 1.

        if candidate in [CAR.SANTAFE, CAR.SANTAFE_1]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1830. + STD_CARGO_KG
            ret.wheelbase = 2.765
            # Values from optimizer
            ret.steerRatio = 13.8  # 13.8 is spec end-to-end
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.SORENTO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1950. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.AVANTE, CAR.I30]:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.GENESIS:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate in [CAR.GENESIS_G90, CAR.GENESIS_G80]:
            ret.mass = 2200
            ret.wheelbase = 3.15
            ret.steerRatio = 12.069
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate in [CAR.K5, CAR.SONATA]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1470. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 12.75
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.SONATA_TURBO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1565. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.K5_HYBRID, CAR.SONATA_HYBRID]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1595. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 12.75
            ret.steerRateCost = 0.45
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.22],
                                                                    [0.04]]
        elif candidate in [CAR.GRANDEUR, CAR.K7]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1570. + STD_CARGO_KG
            ret.wheelbase = 2.885
            ret.steerRatio = 12.5
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.GRANDEUR_HYBRID, CAR.K7_HYBRID]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1675. + STD_CARGO_KG
            ret.wheelbase = 2.885
            ret.steerRatio = 12.5
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[
                0.20
            ], [0.03]]  # [[0.25], [0.05]]
        elif candidate == CAR.STINGER:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1825. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1330. + STD_CARGO_KG
            ret.wheelbase = 2.6
            ret.steerRatio = 13.5  #Spec
            ret.steerRateCost = 0.4
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1330. + STD_CARGO_KG
            ret.wheelbase = 2.6
            ret.steerRatio = 13.5  #Spec
            ret.steerRateCost = 0.4
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.NIRO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1425. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.NIRO_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1425. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.IONIQ:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.IONIQ_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            ret.steerRatio = 13.25  #Spec
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.K3:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 13.75
            tire_stiffness_factor = 0.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.NEXO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1885. + STD_CARGO_KG
            ret.wheelbase = 2.79
            ret.steerRatio = 12.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.SELTOS:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1470. + STD_CARGO_KG
            ret.wheelbase = 2.63
            ret.steerRatio = 13.0
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]

        ret.minEnableSpeed = -1.  # enable is done by stock ACC, so ignore this

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.torque

        ret.longitudinalTuning.kpBP = [0., 5., 35.]
        ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
        ret.longitudinalTuning.kiBP = [0., 35.]
        ret.longitudinalTuning.kiV = [0.18, 0.12]
        ret.longitudinalTuning.deadzoneBP = [0.]
        ret.longitudinalTuning.deadzoneV = [0.]

        # steer, gas, brake limitations VS speed
        ret.steerMaxBP = [0.]
        ret.steerMaxV = [1.0]
        ret.gasMaxBP = [0.]
        ret.gasMaxV = [0.5]
        ret.brakeMaxBP = [0., 20.]
        ret.brakeMaxV = [1., 0.8]

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        ret.stoppingControl = True
        ret.startAccel = 0.0

        # ignore CAN2 address if L-CAN on the same BUS
        ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
                                                                         else 2 if 1056 in fingerprint[2] else -1
        ret.radarOffCan = ret.sccBus == -1
        ret.openpilotLongitudinalControl = bool(ret.sccBus
                                                and not ret.radarOffCan)
        ret.autoLcaEnabled = True

        return ret
Exemplo n.º 19
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, car_fw=[]):  # pylint: disable=dangerous-default-value
    ret = CarInterfaceBase.get_std_params(candidate, fingerprint, has_relay)

    ret.carName = "hyundai"
    ret.safetyModel = car.CarParams.SafetyModel.hyundai
    
    params = Params()
    if int(params.get('LateralControlPriority')) == 0:
      ret.radarOffCan = False
    else:
      ret.radarOffCan = True
      
    PidKp = int(params.get('PidKp')) * 0.01
    PidKi = int(params.get('PidKi')) * 0.001
    PidKf = int(params.get('PidKf')) * 0.00001
    OuterLoopGain = int(params.get('OuterLoopGain')) * 0.1
    InnerLoopGain = int(params.get('InnerLoopGain')) * 0.1
    TimeConstant = int(params.get('TimeConstant')) * 0.1
    ActuatorEffectiveness = int(params.get('ActuatorEffectiveness')) * 0.1
    Scale = int(params.get('Scale')) * 1.0
    LqrKi = int(params.get('LqrKi')) * 0.001
    DcGain = int(params.get('DcGain')) * 0.000001

    # Most Hyundai car ports are community features for now
    ret.communityFeature = False

    tire_stiffness_factor = int(params.get('TireStiffnessFactorAdj')) * 0.01
    ret.steerActuatorDelay = int(params.get('SteerActuatorDelayAdj')) * 0.001
    ret.steerRateCost = int(params.get('SteerRateCostAdj')) * 0.001
    ret.steerLimitTimer = int(params.get('SteerLimitTimerAdj')) * 0.1
    ret.steerRatio = int(params.get('SteerRatioAdj')) * 0.1

    if int(params.get('LateralControlMethod')) == 0:
      if candidate == CAR.SANTAFE:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1830. + STD_CARGO_KG
        ret.wheelbase = 2.765
        # Values from optimizer
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.SORENTO:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1950. + STD_CARGO_KG
        ret.wheelbase = 2.78
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.GENESIS:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 2060. + STD_CARGO_KG
        ret.wheelbase = 3.01
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
     #g90 값 입력
      elif candidate == CAR.GENESIS_G90:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 2290. + STD_CARGO_KG
        ret.wheelbase = 3.45
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
   #g90값 입력 종료  
      elif candidate in [CAR.K5, CAR.SONATA]:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1470. + STD_CARGO_KG
        ret.wheelbase = 2.80
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.SONATA_TURBO:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1565. + STD_CARGO_KG
        ret.wheelbase = 2.80
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate in [CAR.K5_HEV, CAR.SONATA_HEV]:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1595. + STD_CARGO_KG
        ret.wheelbase = 2.80
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate in [CAR.GRANDEUR, CAR.K7]:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1570. + STD_CARGO_KG
        ret.wheelbase = 2.885
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate in [CAR.GRANDEUR_HEV, CAR.K7_HEV]:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1675. + STD_CARGO_KG
        ret.wheelbase = 2.885
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.STINGER:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1825. + STD_CARGO_KG
        ret.wheelbase = 2.78
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.KONA:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.KONA_HEV:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.KONA_EV:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.NIRO_HEV:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1425. + STD_CARGO_KG
        ret.wheelbase = 2.7
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.NIRO_EV:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1425. + STD_CARGO_KG
        ret.wheelbase = 2.7
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.IONIQ_HEV:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1275. + STD_CARGO_KG
        ret.wheelbase = 2.7
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.IONIQ_EV:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1490. + STD_CARGO_KG   #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
        ret.wheelbase = 2.7
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.NEXO:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1885. + STD_CARGO_KG
        ret.wheelbase = 2.79
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.MOHAVE:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 2250. + STD_CARGO_KG
        ret.wheelbase = 2.895
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.I30:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1380. + STD_CARGO_KG
        ret.wheelbase = 2.65
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.AVANTE:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1275. + STD_CARGO_KG
        ret.wheelbase = 2.7
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.SELTOS:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1470. + STD_CARGO_KG
        ret.wheelbase = 2.63
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
      elif candidate == CAR.PALISADE:
        ret.lateralTuning.pid.kf = PidKf
        ret.mass = 1955. + STD_CARGO_KG
        ret.wheelbase = 2.90
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[PidKp], [PidKi]]
    elif int(params.get('LateralControlMethod')) == 1:
      if candidate == CAR.SANTAFE:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1830. + STD_CARGO_KG
        ret.wheelbase = 2.765
      elif candidate == CAR.SORENTO:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1950. + STD_CARGO_KG
        ret.wheelbase = 2.78
      elif candidate == CAR.GENESIS:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 2060. + STD_CARGO_KG
        ret.wheelbase = 3.01
     #g90 값 입력  
      elif candidate == CAR.GENESIS_G90:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 2290. + STD_CARGO_KG
        ret.wheelbase = 3.45
      #g90 값 입력 종료   
      elif candidate in [CAR.K5, CAR.SONATA]:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1470. + STD_CARGO_KG
        ret.wheelbase = 2.80
      elif candidate == CAR.SONATA_TURBO:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1565. + STD_CARGO_KG
        ret.wheelbase = 2.80
      elif candidate in [CAR.K5_HEV, CAR.SONATA_HEV]:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1595. + STD_CARGO_KG
        ret.wheelbase = 2.80
      elif candidate in [CAR.GRANDEUR, CAR.K7]:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1570. + STD_CARGO_KG
        ret.wheelbase = 2.885
      elif candidate in [CAR.GRANDEUR_HEV, CAR.K7_HEV]:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1675. + STD_CARGO_KG
        ret.wheelbase = 2.885
      elif candidate == CAR.STINGER:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1825. + STD_CARGO_KG
        ret.wheelbase = 2.78
      elif candidate == CAR.KONA:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
      elif candidate == CAR.KONA_HEV:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
      elif candidate == CAR.KONA_EV:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
      elif candidate == CAR.NIRO_HEV:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1425. + STD_CARGO_KG
        ret.wheelbase = 2.7
      elif candidate == CAR.NIRO_EV:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1425. + STD_CARGO_KG
        ret.wheelbase = 2.7
      elif candidate == CAR.IONIQ_HEV:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1275. + STD_CARGO_KG
        ret.wheelbase = 2.7
      elif candidate == CAR.IONIQ_EV:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1490. + STD_CARGO_KG   #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
        ret.wheelbase = 2.7
      elif candidate == CAR.NEXO:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1885. + STD_CARGO_KG
        ret.wheelbase = 2.79
      elif candidate == CAR.MOHAVE:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 2250. + STD_CARGO_KG
        ret.wheelbase = 2.895
      elif candidate == CAR.I30:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1380. + STD_CARGO_KG
        ret.wheelbase = 2.65
      elif candidate == CAR.AVANTE:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1275. + STD_CARGO_KG
        ret.wheelbase = 2.7
      elif candidate == CAR.SELTOS:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1470. + STD_CARGO_KG
        ret.wheelbase = 2.63
      elif candidate == CAR.PALISADE:
        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
        ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
        ret.lateralTuning.indi.timeConstant = TimeConstant
        ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness 
        ret.mass = 1955. + STD_CARGO_KG
        ret.wheelbase = 2.90
    elif int(params.get('LateralControlMethod')) == 2:
      if candidate == CAR.SANTAFE:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1830. + STD_CARGO_KG
        ret.wheelbase = 2.765
      elif candidate == CAR.SORENTO:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1950. + STD_CARGO_KG
        ret.wheelbase = 2.78
      elif candidate == CAR.GENESIS:
        ret.mass = 1980. + STD_CARGO_KG
        ret.wheelbase = 3.01
        ret.steerRatio = 15.0
        ret.steerActuatorDelay = 0.3
        ret.steerRateCost = 0.55
        ret.steerLimitTimer = 2.5
       #lqr 조향 시작
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = 1950.0
        ret.lateralTuning.lqr.ki = 0.005
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = 0.00288
      #lqr 조향 종료 
    #g90 값 입력  
      elif candidate == CAR.GENESIS_G90:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = 1680 #Scale
        ret.lateralTuning.lqr.ki = 0.01
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268] 
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05] 
        ret.lateralTuning.lqr.c = [1., 0.] 
        ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255] 
        ret.lateralTuning.lqr.l = [0.3233671, 0.3185757] 
        ret.lateralTuning.lqr.dcGain = 0.002858 #0.002237852961363602
        ret.mass = 2290. + STD_CARGO_KG
        ret.wheelbase = 3.45
        ret.steerLimitTimer = 2.5 #int(params.get('SteerLimitTimerAdj')) * 0.1
        ret.steerRatio = 13.0 #int(params.get('SteerRatioAdj')) * 0.1
        ret.steerActuatorDelay = 0.2 #int(params.get('SteerActuatorDelayAdj')) * 0.001
        ret.steerRateCost = 0.55 #int(params.get('SteerRateCostAdj')) * 0.001


        #g90 값 입력   
      elif candidate in [CAR.K5, CAR.SONATA]:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1470. + STD_CARGO_KG
        ret.wheelbase = 2.80
      elif candidate == CAR.SONATA_TURBO:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1565. + STD_CARGO_KG
        ret.wheelbase = 2.80
      elif candidate in [CAR.K5_HEV, CAR.SONATA_HEV]:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1595. + STD_CARGO_KG
        ret.wheelbase = 2.80
      elif candidate in [CAR.GRANDEUR, CAR.K7]:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1570. + STD_CARGO_KG
        ret.wheelbase = 2.885
      elif candidate in [CAR.GRANDEUR_HEV, CAR.K7_HEV]:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1675. + STD_CARGO_KG
        ret.wheelbase = 2.885
      elif candidate == CAR.STINGER:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1825. + STD_CARGO_KG
        ret.wheelbase = 2.78
      elif candidate == CAR.KONA:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
      elif candidate == CAR.KONA_HEV:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
      elif candidate == CAR.KONA_EV:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1330. + STD_CARGO_KG
        ret.wheelbase = 2.6
      elif candidate == CAR.NIRO_HEV:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1425. + STD_CARGO_KG
        ret.wheelbase = 2.7
      elif candidate == CAR.NIRO_EV:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1425. + STD_CARGO_KG
        ret.wheelbase = 2.7
      elif candidate == CAR.IONIQ_HEV:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1275. + STD_CARGO_KG
        ret.wheelbase = 2.7
      elif candidate == CAR.IONIQ_EV:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1490. + STD_CARGO_KG   #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
        ret.wheelbase = 2.7
      elif candidate == CAR.NEXO:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1885. + STD_CARGO_KG
        ret.wheelbase = 2.79
      elif candidate == CAR.MOHAVE:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 2250. + STD_CARGO_KG
        ret.wheelbase = 2.895
      elif candidate == CAR.I30:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1380. + STD_CARGO_KG
        ret.wheelbase = 2.65
      elif candidate == CAR.AVANTE:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1275. + STD_CARGO_KG
        ret.wheelbase = 2.7
      elif candidate == CAR.SELTOS:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1470. + STD_CARGO_KG
        ret.wheelbase = 2.63
      elif candidate == CAR.PALISADE:
        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = Scale
        ret.lateralTuning.lqr.ki = LqrKi
        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-100., 450.]
        ret.lateralTuning.lqr.l = [0.22, 0.318]
        ret.lateralTuning.lqr.dcGain = DcGain
        ret.mass = 1955. + STD_CARGO_KG
        ret.wheelbase = 2.90


    # these cars require a special panda safety mode due to missing counters and checksums in the messages
    if candidate in [CAR.GENESIS, CAR.IONIQ_EV, CAR.IONIQ_HEV, CAR.KONA_EV]:
      ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy

    ret.centerToFront = ret.wheelbase * 0.4

    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
                                                                         tire_stiffness_factor=tire_stiffness_factor)

    ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.fwdCamera) or has_relay



    # ignore CAN2 address if L-CAN on the same BUS
    ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[1] else 0    # MDPS12
    ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[1] else 0     # SAS11
    ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] else 2 if 1056 in fingerprint[2] else -1  # SCC11
    return ret
Exemplo n.º 20
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay=False):

    ret = car.CarParams.new_message()
    ret.carName = "honda"
    ret.carFingerprint = candidate
    ret.carVin = vin
    ret.isPandaBlack = has_relay

    if candidate in HONDA_BOSCH:
      ret.safetyModel = car.CarParams.SafetyModel.hondaBosch
      rdr_bus = 0 if has_relay else 2
      ret.enableCamera = is_ecu_disconnected(fingerprint[rdr_bus], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.CAM) or has_relay
      ret.radarOffCan = True
      ret.openpilotLongitudinalControl = False
    else:
      ret.safetyModel = car.CarParams.SafetyModel.honda
      ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.CAM) or has_relay
      ret.enableGasInterceptor = 0x201 in fingerprint[0]
      ret.openpilotLongitudinalControl = ret.enableCamera

    cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera)
    cloudlog.warning("ECU Gas Interceptor: %r", ret.enableGasInterceptor)

    ret.enableCruise = not ret.enableGasInterceptor
    ret.communityFeature = ret.enableGasInterceptor

    # Certain Hondas have an extra steering sensor at the bottom of the steering rack,
    # which improves controls quality as it removes the steering column torsion from feedback.
    # Tire stiffness factor fictitiously lower if it includes the steering column torsion effect.
    # For modeling details, see p.198-200 in "The Science of Vehicle Dynamics (2014), M. Guiggiani"

    ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
    ret.lateralTuning.pid.kf = 0.00000 # conservative feed-forward

    ret.steerRateCost = 0.35

    if candidate in [CAR.CIVIC, CAR.CIVIC_BOSCH]:
      stop_and_go = True
      ret.mass = CivicParams.MASS
      ret.wheelbase = CivicParams.WHEELBASE
      ret.centerToFront = CivicParams.CENTER_TO_FRONT
      ret.steerRatio = 10.9  # 10.93 is end-to-end spec
      tire_stiffness_factor = 1.

      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.54, 0.36]
      ret.lateralTuning.pid.kf = 0.00006 # conservative feed-forward
      ret.steerRateCost = 0.1

    elif candidate in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH):
      stop_and_go = True
      if not candidate == CAR.ACCORDH: # Hybrid uses same brake msg as hatch
        ret.safetyParam = 1  # Accord and CRV 5G use an alternate user brake msg
      ret.mass = 3279. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.83
      ret.centerToFront = ret.wheelbase * 0.39
      ret.steerRatio = 16.33  # 11.82 is spec end-to-end
      tire_stiffness_factor = 0.8467
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.ACURA_ILX:
      stop_and_go = False
      ret.mass = 3095. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.67
      ret.centerToFront = ret.wheelbase * 0.37
      ret.steerRatio = 18.61  # 15.3 is spec end-to-end
      tire_stiffness_factor = 0.72
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.CRV:
      stop_and_go = False
      ret.mass = 3572. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.62
      ret.centerToFront = ret.wheelbase * 0.41
      ret.steerRatio = 16.89  # as spec
      tire_stiffness_factor = 0.444
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.CRV_5G:
      stop_and_go = True
      ret.safetyParam = 1  # Accord and CRV 5G use an alternate user brake msg
      ret.mass = 3410. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.66
      ret.centerToFront = ret.wheelbase * 0.41
      ret.steerRatio = 16.0  # 12.3 is spec end-to-end
      tire_stiffness_factor = 0.677
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.CRV_HYBRID:
      stop_and_go = True
      ret.safetyParam = 1  # Accord and CRV 5G use an alternate user brake msg
      ret.mass = 1667. + STD_CARGO_KG # mean of 4 models in kg
      ret.wheelbase = 2.66
      ret.centerToFront = ret.wheelbase * 0.41
      ret.steerRatio = 16.0  # 12.3 is spec end-to-end
      tire_stiffness_factor = 0.677
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.FIT:
      stop_and_go = False
      ret.mass = 2644. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.53
      ret.centerToFront = ret.wheelbase * 0.39
      ret.steerRatio = 10.25
      tire_stiffness_factor = 0.75
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.20], [0.04]]
      # BP values are speeds - 0 m/s, 10 m/s, 35 m/s
      # which is 0 MPH, 22 MPH, and 78 MPH
      ret.longitudinalTuning.kpBP = [0., 10., 35.]
      # These are corresponding Kp values with the above speeds
      ret.longitudinalTuning.kpV = [0.6, 0.4, 0.3]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.ACURA_RDX:
      stop_and_go = False
      ret.mass = 3935. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.68
      ret.centerToFront = ret.wheelbase * 0.38
      ret.steerRatio = 15.0  # as spec
      tire_stiffness_factor = 0.444
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.INSIGHT:
      stop_and_go = True
      ret.mass = 2987. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.centerToFront = ret.wheelbase * 0.39
      ret.steerRatio = 15  # 12.58 is spec end-to-end
      tire_stiffness_factor = 0.82
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.ODYSSEY:
      stop_and_go = False
      ret.mass = 4471. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 3.00
      ret.centerToFront = ret.wheelbase * 0.41
      ret.steerRatio = 14.35  # as spec
      tire_stiffness_factor = 0.82
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.45], [0.135]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate == CAR.ODYSSEY_CHN:
      stop_and_go = False
      ret.mass = 1849.2 + STD_CARGO_KG  # mean of 4 models in kg
      ret.wheelbase = 2.90
      ret.centerToFront = ret.wheelbase * 0.41  # from CAR.ODYSSEY
      ret.steerRatio = 14.35
      tire_stiffness_factor = 0.82
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.45], [0.135]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]

    elif candidate in (CAR.PILOT, CAR.PILOT_2018, CAR.PILOT_2019):
      stop_and_go = False
      ret.mass = 4204. * CV.LB_TO_KG + STD_CARGO_KG # average weight
      ret.wheelbase = 2.82
      ret.centerToFront = ret.wheelbase * 0.428 # average weight distribution
      ret.steerRatio = 12.5         # Tuned value for 0.6.4 to eliminate wobble
      tire_stiffness_factor = 0.62 # LiveParameters Value
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.45], [0.21]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]
    
    elif candidate == CAR.RIDGELINE:
      stop_and_go = False
      ret.mass = 4515. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 3.18
      ret.centerToFront = ret.wheelbase * 0.41
      ret.steerRatio = 12.5        # as spec
      tire_stiffness_factor = 0.62 # not optimized yet
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.45], [0.21]]
      ret.longitudinalTuning.kpBP = [0., 5., 35.]
      ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
      ret.longitudinalTuning.kiBP = [0., 35.]
      ret.longitudinalTuning.kiV = [0.18, 0.12]
      ret.lateralTuning.pid.kf = 0.00006

    else:
      raise ValueError("unsupported car %s" % candidate)

    ret.steerControlType = car.CarParams.SteerControlType.torque

    # 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. Otherwise, add 0.5 mph margin to not
    # conflict with PCM acc
    ret.minEnableSpeed = -1. if (stop_and_go or ret.enableGasInterceptor) else 25.5 * CV.MPH_TO_MS

    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
                                                                         tire_stiffness_factor=tire_stiffness_factor)

    # no rear steering, at least on the listed cars above
    ret.steerRatioRear = 0.

    # no max steer limit VS speed
    ret.steerMaxBP = [0.]  # m/s
    ret.steerMaxV = [1.]   # max steer allowed

    # prevent lurching when resuming
    if ret.enableGasInterceptor:
      ret.gasMaxBP = [0., 3, 8, 35]
      ret.gasMaxV = [0.2, 0.3, 0.5, 0.6]
    else:
      ret.gasMaxBP = [0.]  # m/s
      ret.gasMaxV = [0.] # max gas allowed
    
    #ret.gasMaxBP = [0.]  # m/s
    #ret.gasMaxV = [0.6] if ret.enableGasInterceptor else [0.] # max gas allowed
    ret.brakeMaxBP = [5., 20.]  # m/s
    ret.brakeMaxV = [1., 0.8]   # max brake allowed

    ret.longitudinalTuning.deadzoneBP = [0.]
    ret.longitudinalTuning.deadzoneV = [0.]

    ret.stoppingControl = True
    ret.startAccel = 0.5

    ret.steerActuatorDelay = 0.1
    ret.steerLimitTimer = 0.8

    return ret
Exemplo n.º 21
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay=False):

    ret = car.CarParams.new_message()

    ret.carName = "chrysler"
    ret.carFingerprint = candidate
    ret.carVin = vin
    ret.isPandaBlack = has_relay

    ret.safetyModel = car.CarParams.SafetyModel.chrysler

    # pedal
    ret.enableCruise = True

    # Speed conversion:              20, 45 mph
    ret.wheelbase = 3.089  # in meters for Pacifica Hybrid 2017
    ret.steerRatio = 16.2 # Pacifica Hybrid 2017
    ret.mass = 2858. + STD_CARGO_KG  # kg curb weight Pacifica Hybrid 2017
    ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kiBP = [[9., 20.], [9., 20.]]
    ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15,0.30], [0.03,0.05]]
    ret.lateralTuning.pid.kf = 0.00006   # full torque for 10 deg at 80mph means 0.00007818594
    ret.steerActuatorDelay = 0.1
    ret.steerRateCost = 0.7
    ret.steerLimitTimer = 0.4

    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

    ret.centerToFront = ret.wheelbase * 0.44

    ret.minSteerSpeed = 3.8  # m/s
    ret.minEnableSpeed = -1.   # enable is done by stock ACC, so ignore this
    if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.JEEP_CHEROKEE_2019):
      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.

    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront)

    # no rear steering, at least on the listed cars above
    ret.steerRatioRear = 0.

    # steer, gas, brake limitations VS speed
    ret.steerMaxBP = [16. * CV.KPH_TO_MS, 45. * CV.KPH_TO_MS]  # breakpoints at 1 and 40 kph
    ret.steerMaxV = [1., 1.]  # 2/3rd torque allowed above 45 kph
    ret.gasMaxBP = [0.]
    ret.gasMaxV = [0.5]
    ret.brakeMaxBP = [5., 20.]
    ret.brakeMaxV = [1., 0.8]

    ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.CAM) or has_relay
    print("ECU Camera Simulated: {0}".format(ret.enableCamera))
    ret.openpilotLongitudinalControl = False

    ret.stoppingControl = False
    ret.startAccel = 0.0

    ret.longitudinalTuning.deadzoneBP = [0., 9.]
    ret.longitudinalTuning.deadzoneV = [0., .15]
    ret.longitudinalTuning.kpBP = [0., 5., 35.]
    ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5]
    ret.longitudinalTuning.kiBP = [0., 35.]
    ret.longitudinalTuning.kiV = [0.54, 0.36]

    return ret
Exemplo n.º 22
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):  # pylint: disable=dangerous-default-value
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.openpilotLongitudinalControl = Params().get_bool(
            'LongControlEnabled')

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy
        if candidate in [CAR.SONATA]:
            ret.safetyModel = car.CarParams.SafetyModel.hyundai

        # Most Hyundai car ports are community features for now
        ret.communityFeature = candidate not in [CAR.SONATA, CAR.PALISADE]

        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.8
        tire_stiffness_factor = 1.

        ret.maxSteeringAngleDeg = 90.
        ret.startAccel = 1.0

        eps_modified = False
        for fw in car_fw:
            if fw.ecu == "eps" and b"," in fw.fwVersion:
                eps_modified = True

        # genesis
        if candidate == CAR.GENESIS:
            ret.mass = 1900. + STD_CARGO_KG
            ret.wheelbase = 3.01
        elif candidate == CAR.GENESIS_G70:
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.84
        elif candidate == CAR.GENESIS_G80:
            ret.mass = 1855. + STD_CARGO_KG
            ret.wheelbase = 3.01
        elif candidate == CAR.GENESIS_G90:
            ret.mass = 2200
            ret.wheelbase = 3.15
        elif candidate == CAR.GENESIS_G90_L:
            ret.mass = 2290
            ret.wheelbase = 3.45
        # hyundai
        elif candidate in [CAR.SANTA_FE]:
            ret.mass = 1694 + STD_CARGO_KG
            ret.wheelbase = 2.766
        elif candidate in [CAR.SONATA, CAR.SONATA_HEV]:
            ret.mass = 1513. + STD_CARGO_KG
            ret.wheelbase = 2.84
            tire_stiffness_factor = 0.65
        elif candidate in [CAR.SONATA19, CAR.SONATA19_HEV]:
            ret.mass = 4497. * CV.LB_TO_KG
            ret.wheelbase = 2.804
        elif candidate == CAR.SONATA_LF_TURBO:
            ret.mass = 1590. + STD_CARGO_KG
            ret.wheelbase = 2.805
            tire_stiffness_factor = 0.65
        elif candidate == CAR.PALISADE:
            ret.mass = 1999. + STD_CARGO_KG
            ret.wheelbase = 2.90
            if eps_modified:
                ret.maxSteeringAngleDeg = 1000.
        elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.7
        elif candidate == CAR.KONA:
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.7
        elif candidate in [CAR.KONA_HEV, CAR.KONA_EV]:
            ret.mass = 1395. + STD_CARGO_KG
            ret.wheelbase = 2.6
            tire_stiffness_factor = 0.7
        elif candidate in [CAR.IONIQ, CAR.IONIQ_EV_LTD]:
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.7
        elif candidate in [CAR.GRANDEUR_IG, CAR.GRANDEUR_IG_HEV]:
            tire_stiffness_factor = 0.8
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.845
            ret.maxSteeringAngleDeg = 120.
        elif candidate in [CAR.GRANDEUR_IG_FL, CAR.GRANDEUR_IG_FL_HEV]:
            tire_stiffness_factor = 0.8
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.845
            ret.maxSteeringAngleDeg = 120.
        elif candidate == CAR.VELOSTER:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            tire_stiffness_factor = 0.9
        # kia
        elif candidate == CAR.SORENTO:
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
            tire_stiffness_factor = 0.7
        elif candidate in [CAR.K5, CAR.K5_HEV]:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            tire_stiffness_factor = 0.7
        elif candidate == CAR.STINGER:
            tire_stiffness_factor = 1.125  # LiveParameters (Tunder's 2020)
            ret.mass = 1825.0 + STD_CARGO_KG
            ret.wheelbase = 2.906  # https://www.kia.com/us/en/stinger/specs
        elif candidate == CAR.FORTE:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            tire_stiffness_factor = 0.7
        elif candidate == CAR.CEED:
            ret.mass = 1350. + STD_CARGO_KG
            ret.wheelbase = 2.65
            tire_stiffness_factor = 0.6
        elif candidate == CAR.SPORTAGE:
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
        elif candidate in [CAR.NIRO_HEV, CAR.NIRO_EV]:
            ret.mass = 1737. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.7
        elif candidate in [CAR.K7, CAR.K7_HEV]:
            tire_stiffness_factor = 0.7
            ret.mass = 1650. + STD_CARGO_KG
            ret.wheelbase = 2.855
        elif candidate == CAR.SELTOS:
            ret.mass = 1310. + STD_CARGO_KG
            ret.wheelbase = 2.6
            tire_stiffness_factor = 0.7

        ret.lateralTuning.init('indi')
        ret.lateralTuning.indi.innerLoopGainBP = [0.]
        ret.lateralTuning.indi.innerLoopGainV = [3.3]
        ret.lateralTuning.indi.outerLoopGainBP = [0.]
        ret.lateralTuning.indi.outerLoopGainV = [2.6]
        ret.lateralTuning.indi.timeConstantBP = [0.]
        ret.lateralTuning.indi.timeConstantV = [1.4]
        ret.lateralTuning.indi.actuatorEffectivenessBP = [0.]
        ret.lateralTuning.indi.actuatorEffectivenessV = [2.]

        ret.steerRatio = 16.5
        ret.steerActuatorDelay = 0.1
        ret.steerLimitTimer = 2.5
        ret.minSteerSpeed = 0
        ret.steerRateCost = 0.4

        ret.steerMaxBP = [0.]
        ret.steerMaxV = [1.5]

        if ret.openpilotLongitudinalControl:

            ret.longitudinalTuning.kpBP = [
                0., 10. * CV.KPH_TO_MS, 20. * CV.KPH_TO_MS, 40. * CV.KPH_TO_MS,
                70. * CV.KPH_TO_MS, 100. * CV.KPH_TO_MS
            ]
            ret.longitudinalTuning.kpV = [0.95, 0.75, 0.6, 0.5, 0.43, 0.38]
            ret.longitudinalTuning.kiBP = [0.]
            ret.longitudinalTuning.kiV = [0.015]
            ret.longitudinalTuning.kf = 0.5
            ret.longitudinalTuning.deadzoneBP = [0., 100. * CV.KPH_TO_MS]
            ret.longitudinalTuning.deadzoneV = [0., 0.015]

            ret.gasMaxBP = [
                0., 10. * CV.KPH_TO_MS, 20. * CV.KPH_TO_MS, 70. * CV.KPH_TO_MS,
                130. * CV.KPH_TO_MS
            ]
            ret.gasMaxV = [0.4, 0.28, 0.2, 0.14, 0.11]

            ret.brakeMaxBP = [0.]
            ret.brakeMaxV = [1.3]

            ret.stoppingBrakeRate = 0.15  # brake_travel/s while trying to stop
            ret.startingBrakeRate = 0.6  # brake_travel/s while releasing on restart
            ret.startAccel = 1.5

        else:
            # scc smoother
            ret.longitudinalTuning.kpBP = [
                0., 10. * CV.KPH_TO_MS, 40. * CV.KPH_TO_MS, 100. * CV.KPH_TO_MS
            ]
            ret.longitudinalTuning.kpV = [1.3, 1.2, 1.0, 0.45]
            ret.longitudinalTuning.kiBP = [0.]
            ret.longitudinalTuning.kiV = [0.]
            ret.longitudinalTuning.deadzoneBP = [0., 40]
            ret.longitudinalTuning.deadzoneV = [0., 0.02]

            ret.gasMaxBP = [0.]
            ret.gasMaxV = [0.5]
            ret.brakeMaxBP = [0., 20.]
            ret.brakeMaxV = [1., 0.8]

        ret.radarTimeStep = 0.05
        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.torque

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay
        ret.stoppingControl = True

        # ignore CAN2 address if L-CAN on the same BUS
        ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
                                                                         else 2 if 1056 in fingerprint[2] else -1

        print("!!!!! BUS", "MDPS", ret.mdpsBus, "SAS", ret.sasBus, "SCC",
              ret.sccBus)

        ret.radarOffCan = ret.sccBus == -1
        ret.enableCruise = not ret.radarOffCan

        # set safety_hyundai_community only for non-SCC, MDPS harrness or SCC harrness cars or cars that have unknown issue
        if ret.radarOffCan or ret.mdpsBus == 1 or ret.openpilotLongitudinalControl or ret.sccBus == 1 or Params(
        ).get_bool('MadModeEnabled'):
            ret.safetyModel = car.CarParams.SafetyModel.hyundaiCommunity
        return ret
Exemplo n.º 23
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, car_fw=[]):

    ret = car.CarParams.new_message()

    ret.carName = "hyundai"
    ret.carFingerprint = candidate
    ret.isPandaBlack = has_relay
    ret.safetyModel = car.CarParams.SafetyModel.hyundai
    ret.enableCruise = True  # stock acc

    ret.steerActuatorDelay = 0.15  # Default delay
    ret.steerRateCost = 0.45
    ret.steerLimitTimer = 0.8
    tire_stiffness_factor = 0.7

    ret.minEnableSpeed = -1.   # enable is done by stock ACC, so ignore this
    ret.minSteerSpeed = 0.
    #ret.minSteerSpeed = 60 * CV.KPH_TO_MS

    if candidate == CAR.GENESIS:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 2060. + STD_CARGO_KG
      ret.wheelbase = 3.01
      ret.steerRatio = 16.5
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]]           
    elif candidate in [CAR.GENESIS_G90, CAR.GENESIS_G80]:
      ret.mass = 2200. + STD_CARGO_KG
      ret.wheelbase = 3.15
      ret.steerRatio = 12.069
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]]
    elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
      ret.lateralTuning.pid.kf = 0.00006
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73
      tire_stiffness_factor = 0.385
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate in [CAR.SONATA, CAR.SONATA_HEV]:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1640. + STD_CARGO_KG
      ret.wheelbase = 2.80
      ret.steerRatio = 13.75
      tire_stiffness_factor = 0.5
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate in [CAR.GRANDEUR, CAR.GRANDEUR_HEV]:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1719. + STD_CARGO_KG
      ret.wheelbase = 2.8
      ret.steerRatio = 14.4
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate == CAR.SANTA_FE:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1870. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 16.55  # 13.8 is spec end-to-end
      tire_stiffness_factor = 0.82
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[9., 22.], [9., 22.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.35], [0.05, 0.09]]      
    elif candidate == CAR.IONIQ:
      ret.lateralTuning.pid.kf = 0.00006
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73
      tire_stiffness_factor = 0.385
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate == CAR.IONIQ_EV:
      ret.lateralTuning.pid.kf = 0.00006
      ret.mass = 1490. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73
      tire_stiffness_factor = 0.385
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]      
    elif candidate == CAR.KONA:
      ret.lateralTuning.pid.kf = 0.00006
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73
      tire_stiffness_factor = 0.385
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate == CAR.KONA_EV:
      ret.lateralTuning.pid.kf = 0.00006
      ret.mass = 1685. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73   
      tire_stiffness_factor = 0.385
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_HEV]:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1525. + STD_CARGO_KG
      ret.wheelbase = 2.80
      ret.steerRatio = 13.75
      tire_stiffness_factor = 0.5
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]      
    elif candidate in [CAR.KIA_CARDENZA, CAR.KIA_CARDENZA_HEV]:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1575. + STD_CARGO_KG
      ret.wheelbase = 2.85
      ret.steerRatio = 13.75
      tire_stiffness_factor = 0.5
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]      
    elif candidate == CAR.KIA_FORTE:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1613. + STD_CARGO_KG
      ret.wheelbase = 2.80
      ret.steerRatio = 13.75
      tire_stiffness_factor = 0.5
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]           
    elif candidate == CAR.KIA_SORENTO:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1985. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.1   # 10% higher at the center seems reasonable
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate == CAR.KIA_STINGER:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1825. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.15   # 15% higher at the center seems reasonable
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate == CAR.KIA_SELTOS:
      ret.lateralTuning.pid.kf = 0.00006
      ret.mass = 1444. + STD_CARGO_KG
      ret.wheelbase = 2.6
      ret.steerRatio = 13.73 * 1.1
      tire_stiffness_factor = 0.385
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate == CAR.KIA_SOUL_EV:
      ret.lateralTuning.pid.kf = 0.00006
      ret.mass = 1682. + STD_CARGO_KG
      ret.wheelbase = 2.6
      ret.steerRatio = 13.73
      tire_stiffness_factor = 0.385
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate == CAR.KIA_SPORTAGE:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1626. + STD_CARGO_KG
      ret.wheelbase = 2.67
      ret.steerRatio = 14.4 * 1.1   # 10% higher at the center seems reasonable
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]

    ret.longitudinalTuning.kpBP = [0., 5., 35.]
    ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
    ret.longitudinalTuning.kiBP = [0., 35.]
    ret.longitudinalTuning.kiV = [0.18, 0.12]
    ret.longitudinalTuning.deadzoneBP = [0.]
    ret.longitudinalTuning.deadzoneV = [0.]

    ret.centerToFront = ret.wheelbase * 0.4

    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
                                                                         tire_stiffness_factor=tire_stiffness_factor)

    # no rear steering, at least on the listed cars above
    ret.steerRatioRear = 0.
    ret.steerControlType = car.CarParams.SteerControlType.torque

    # steer, gas, brake limitations VS speed
    ret.steerMaxBP = [0.]
    ret.steerMaxV = [1.0]
    ret.gasMaxBP = [0.]
    ret.gasMaxV = [0.5]
    ret.brakeMaxBP = [0., 20.]
    ret.brakeMaxV = [1., 0.8]

    ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.fwdCamera) or has_relay
    ret.openpilotLongitudinalControl = False

    ret.stoppingControl = True
    ret.startAccel = 0.0

    # ignore CAN2 address if L-CAN on the same BUS
    ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[1] else 0
    ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[1] else 0
    ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
                                                                     else 2 if 1056 in fingerprint[2] else -1
    ret.autoLcaEnabled = 1

    return ret
Exemplo n.º 24
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, car_fw=[]):  # pylint: disable=dangerous-default-value
    ret = CarInterfaceBase.get_std_params(candidate, fingerprint, has_relay)

    ret.carName = "hyundai"
    ret.safetyModel = car.CarParams.SafetyModel.hyundai

    # Most Hyundai car ports are community features for now
    ret.communityFeature = candidate not in [CAR.SONATA, CAR.PALISADE]

    ret.steerActuatorDelay = 0.3  # Default delay not used, check pathplanner for BPs
    ret.steerRateCost = 0.5
    ret.steerLimitTimer = 0.1
    tire_stiffness_factor = 0.7

    #Long tuning Params -  make individual params for cars, baseline Hyundai genesis
    ret.longitudinalTuning.kpBP = [0., 1., 10., 35.]
    ret.longitudinalTuning.kpV = [0.12, 1.3, .85, .65]
    ret.longitudinalTuning.kiBP = [0., 15., 35.]
    ret.longitudinalTuning.kiV = [.35, .25, .15]
    ret.longitudinalTuning.deadzoneBP = [0., .5]
    ret.longitudinalTuning.deadzoneV = [0.00, 0.00]
    ret.gasMaxBP = [0., 1., 1.1, 15., 40.]
    ret.gasMaxV = [2., 2., 2., 1.68, 1.3]
    ret.brakeMaxBP = [0., 5., 5.1]
    ret.brakeMaxV = [3.5, 3.5, 3.5]  # safety limits to stop unintended deceleration

    ret.lateralTuning.pid.kpBP = [0., 10., 30.]
    ret.lateralTuning.pid.kpV = [0.01, 0.02, 0.03]
    ret.lateralTuning.pid.kiBP = [0., 10., 30.]
    ret.lateralTuning.pid.kiV = [0.001, 0.0015, 0.002]
    ret.lateralTuning.pid.kf = 0.00005

    if candidate in [CAR.SANTA_FE, CAR.SANTA_FE_2017]:
      ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.766
      ret.steerRatio = 16.55
    elif candidate in [CAR.SONATA, CAR.SONATA_HEV]:
      ret.mass = 1513. + STD_CARGO_KG
      ret.wheelbase = 2.84
      ret.steerRatio = 13.27 * 1.15
    elif candidate in [CAR.SONATA_2019, CAR.SONATA_HEV_2019]:
      ret.mass = 4497. * CV.LB_TO_KG
      ret.wheelbase = 2.804
      ret.steerRatio = 13.27 * 1.15
    elif candidate == CAR.PALISADE:
      ret.mass = 1999. + STD_CARGO_KG
      ret.wheelbase = 2.90
      ret.steerRatio = 13.75 * 1.15
    elif candidate == CAR.KIA_SORENTO:
      ret.mass = 1985. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.1
    elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 15.4
      ret.minSteerSpeed = 32 * CV.MPH_TO_MS
    elif candidate == CAR.ELANTRA_2020:
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 15.4
    elif candidate == CAR.HYUNDAI_GENESIS:
      ret.mass = 2060. + STD_CARGO_KG
      ret.wheelbase = 3.01
      ret.steerRatio = 16.5
      ret.minSteerSpeed = 55 * CV.KPH_TO_MS
    elif candidate == CAR.GENESIS_G70:
      ret.lateralTuning.init('indi')
      ret.lateralTuning.indi.innerLoopGain = 3.0
      ret.lateralTuning.indi.outerLoopGain = 2.0
      ret.lateralTuning.indi.timeConstant = 1.0
      ret.lateralTuning.indi.actuatorEffectiveness = 1.5
      ret.mass = 1640.0 + STD_CARGO_KG
      ret.wheelbase = 2.84
      ret.steerRatio = 13.56
    elif candidate == CAR.GENESIS_G80:
      ret.steerActuatorDelay = 0.4
      ret.steerRateCost = 0.45
      ret.mass = 2060. + STD_CARGO_KG
      ret.wheelbase = 3.01
      ret.steerRatio = 16.5
    elif candidate == CAR.GENESIS_G90:
      ret.mass = 2060. + STD_CARGO_KG
      ret.wheelbase = 3.01
      ret.steerRatio = 16.5
    elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_HEV]:
      ret.mass = 3558. * CV.LB_TO_KG
      ret.wheelbase = 2.80
      ret.steerRatio = 13.75 * 1.15
    elif candidate == CAR.KIA_STINGER:
      ret.mass = 1825. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.15
    elif candidate == CAR.KONA:
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73 * 1.15
    elif candidate in [CAR.KONA_HEV, CAR.KONA_EV]:
      ret.mass = 1685. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73 * 1.15
    elif candidate in [CAR.IONIQ_HEV, CAR.IONIQ_EV_LTD]:
      ret.mass = 1490. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73 * 1.15
    elif candidate == CAR.KIA_FORTE:
      ret.mass = 3558. * CV.LB_TO_KG
      ret.wheelbase = 2.80
      ret.steerRatio = 13.75 * 1.15
    elif candidate == CAR.KIA_CEED:
      ret.mass = 1350. + STD_CARGO_KG
      ret.wheelbase = 2.65
      ret.steerRatio = 13.75 * 1.15
    elif candidate == CAR.KIA_SPORTAGE:
      ret.mass = 1985. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.15
    elif candidate == CAR.VELOSTER:
      ret.mass = 2960. * CV.LB_TO_KG
      ret.wheelbase = 2.69
      ret.steerRatio = 13.75 * 1.15
    elif candidate in [CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_EV]:
      ret.steerRatio = 13.73
      ret.mass = 1737. + STD_CARGO_KG
      ret.wheelbase = 2.7
    elif candidate in [CAR.GRANDEUR, CAR.GRANDEUR_HEV]:
      ret.mass = 1719. + STD_CARGO_KG
      ret.wheelbase = 2.8
      ret.steerRatio = 12.5* 1.15
    elif candidate in [CAR.KIA_CADENZA, CAR.KIA_CADENZA_HEV]:
      ret.mass = 1575. + STD_CARGO_KG
      ret.wheelbase = 2.85
      ret.steerRatio = 12.5 * 1.15

    # these cars require a special panda safety mode due to missing counters and checksums in the messages

    ret.mdpsHarness = True
    ret.sasBus = 0 if (688 in fingerprint[0] or not ret.mdpsHarness) else 1
    ret.fcaBus = 0 if 909 in fingerprint[0] else 2 if 909 in fingerprint[2] else -1
    ret.bsmAvailable = True if 1419 in fingerprint[0] else False
    ret.lfaAvailable = True if 1157 in fingerprint[2] else False
    ret.lvrAvailable = True if 871 in fingerprint[0] else False
    ret.evgearAvailable = True if 882 in fingerprint[0] else False
    ret.emsAvailable = True if 608 and 809 in fingerprint[0] else False

    if True:
      ret.sccBus = 2 if 1057 in fingerprint[2] and False else 0 if 1057 in fingerprint[0] else -1
    else:
      ret.sccBus = -1

    ret.radarOffCan = (ret.sccBus == -1)
    #ret.radarTimeStep = 0.1

    ret.openpilotLongitudinalControl = True and not (ret.sccBus == 0)

    if candidate in [ CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_LTD, CAR.IONIQ_HEV, CAR.KONA_EV, CAR.KIA_NIRO_EV, CAR.KIA_SORENTO, CAR.SONATA_2019,
                      CAR.KIA_OPTIMA, CAR.VELOSTER, CAR.KIA_STINGER, CAR.GENESIS_G70, CAR.SONATA_HEV, CAR.SANTA_FE, CAR.GENESIS_G80,
                      CAR.GENESIS_G90]:
      ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy

    if ret.mdpsHarness or \
            (candidate in [CAR.KIA_OPTIMA_HEV, CAR.SONATA_HEV, CAR.IONIQ_HEV, CAR.SONATA_HEV_2019,
                          CAR.KIA_CADENZA_HEV, CAR.GRANDEUR_HEV, CAR.KIA_NIRO_HEV, CAR.KONA_HEV]):
      ret.safetyModel = car.CarParams.SafetyModel.hyundaiCommunity

    if ret.radarOffCan or (ret.sccBus == 2) or True:
      ret.safetyModel = car.CarParams.SafetyModel.hyundaiCommunityNonscc
    if ret.mdpsHarness:
      ret.minSteerSpeed = 0.

    ret.centerToFront = ret.wheelbase * 0.4

    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
                                                                         tire_stiffness_factor=tire_stiffness_factor)

    ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.fwdCamera) \
                       or has_relay

    ret.radarDisablePossible = True

    ret.enableCruise = False and ret.sccBus == 0

    if ret.radarDisablePossible:
      ret.openpilotLongitudinalControl = True
      ret.safetyModel = car.CarParams.SafetyModel.hyundaiCommunityNonscc # todo based on toggle
      ret.sccBus = -1
      ret.enableCruise = False
      ret.radarOffCan = True
      if ret.fcaBus == 0:
        ret.fcaBus = -1

    return ret
Exemplo n.º 25
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):
        global ATOMC
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundai
        ret.radarOffCan = False  #False(선행차우선)  #True(차선우선)    #선행차량 인식 마크 유무.

        ret.radarOffCan = bool(params.get('OpkrTraceSet') != b'1')
        ret.lateralsRatom.learnerParams = int(params.get('OpkrEnableLearner'))

        # Hyundai port is a community feature for now
        ret.communityFeature = False  #True

        ret.longcontrolEnabled = False
        """
      0.7.5
      ret.steerActuatorDelay = 0.1  # Default delay   0.1
      ret.steerRateCost = 0.5
      ret.steerLimitTimer = 0.4
      tire_stiffness_factor = 1
    """
        """
      0.7.3
      ret.steerActuatorDelay = 0.10  # Default delay   0.15
      ret.steerRateCost = 0.45
      ret.steerLimitTimer = 0.8
      tire_stiffness_factor = 0.7
    """

        tire_stiffness_factor = 1.
        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.4

        if candidate == CAR.SANTAFE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1830. + STD_CARGO_KG
            ret.wheelbase = 2.765
            # Values from optimizer
            ret.steerRatio = 13.8  # 13.8 is spec end-to-end
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.SORENTO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1950. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.GENESIS:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2060. + STD_CARGO_KG
            ret.wheelbase = 3.01
            ret.steerRatio = 16.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16],
                                                                    [0.01]]
        elif candidate in [CAR.K5, CAR.SONATA]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1470. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 12.75
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.SONATA_TURBO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1565. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.K5_HEV, CAR.SONATA_HEV]:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1595. + STD_CARGO_KG
            ret.wheelbase = 2.80
            ret.steerRatio = 12.75
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.GRANDEUR, CAR.K7]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1570. + STD_CARGO_KG
            ret.wheelbase = 2.885
            ret.steerRatio = 12.5
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate in [CAR.GRANDEUR_HEV, CAR.K7_HEV]:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1675. + STD_CARGO_KG
            ret.wheelbase = 2.885
            ret.steerRatio = 12.5
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.STINGER:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1825. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 14.4 * 1.15  # 15% higher at the center seems reasonable
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1330. + STD_CARGO_KG
            ret.wheelbase = 2.6
            ret.steerRatio = 13.5  #Spec
            ret.steerRateCost = 0.4
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA_HEV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1330. + STD_CARGO_KG
            ret.wheelbase = 2.6
            ret.steerRatio = 13.5  #Spec
            ret.steerRateCost = 0.4
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.KONA_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1330. + STD_CARGO_KG
            ret.wheelbase = 2.6
            ret.steerRatio = 13.5  #Spec
            ret.steerRateCost = 0.4
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.NIRO_HEV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1425. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.NIRO_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1425. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.IONIQ_HEV:
            ret.lateralTuning.pid.kf = 0.00006
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.73  #Spec
            tire_stiffness_factor = 0.385
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.IONIQ_EV:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            ret.steerRatio = 13.25  #Spec
            ret.steerRateCost = 0.4
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.NEXO:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1885. + STD_CARGO_KG
            ret.wheelbase = 2.79
            ret.steerRatio = 12.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.MOHAVE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 2250. + STD_CARGO_KG
            ret.wheelbase = 2.895
            ret.steerRatio = 14.1
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.I30:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1380. + STD_CARGO_KG
            ret.wheelbase = 2.65
            ret.steerRatio = 13.5
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.AVANTE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            ret.steerRatio = 13.5  # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535
            tire_stiffness_factor = 0.385  # stiffnessFactor settled on 1.0081302973865127
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.SELTOS:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1470. + STD_CARGO_KG
            ret.wheelbase = 2.63
            ret.steerRatio = 13.0
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]
        elif candidate == CAR.PALISADE:
            ret.lateralTuning.pid.kf = 0.00005
            ret.mass = 1955. + STD_CARGO_KG
            ret.wheelbase = 2.90
            ret.steerRatio = 13.0
            ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.],
                                                                      [0.]]
            ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25],
                                                                    [0.05]]

        # 3번 atom param.
        ret.lateralPIDatom.sRKPHV = [9., 17.]  # 속도. 32~61

        ret.lateralPIDatom.sRkBPV = ATOMC.sR_BPV  # 조향각.
        ret.lateralPIDatom.sRBoostV = ATOMC.sR_BoostV
        ret.lateralPIDatom.sRkpV1 = ATOMC.sR_kpV1
        ret.lateralPIDatom.sRkiV1 = ATOMC.sR_kiV1
        ret.lateralPIDatom.sRkdV1 = ATOMC.sR_kdV1
        ret.lateralPIDatom.sRkfV1 = ATOMC.sR_kfV1

        ret.lateralPIDatom.sRkpV2 = ATOMC.sR_kpV2
        ret.lateralPIDatom.sRkiV2 = ATOMC.sR_kiV2
        ret.lateralPIDatom.sRkdV2 = ATOMC.sR_kdV2
        ret.lateralPIDatom.sRkfV2 = ATOMC.sR_kfV2

        ret.lateralCVatom.cvBPV = ATOMC.cvBPV
        ret.lateralCVatom.cvSteerMaxV1 = ATOMC.cvSteerMaxV1
        ret.lateralCVatom.cvSteerDeltaUpV1 = ATOMC.cvSteerDeltaUpV1
        ret.lateralCVatom.cvSteerDeltaDnV1 = ATOMC.cvSteerDeltaDnV1
        ret.lateralCVatom.cvSteerMaxV2 = ATOMC.cvSteerMaxV2
        ret.lateralCVatom.cvSteerDeltaUpV2 = ATOMC.cvSteerDeltaUpV2
        ret.lateralCVatom.cvSteerDeltaDnV2 = ATOMC.cvSteerDeltaDnV2

        ret.lateralsRatom.deadzone = ATOMC.deadzone
        ret.lateralsRatom.steerOffset = ATOMC.steerOffset
        ret.lateralsRatom.tireStiffnessFactor = ATOMC.tire_stiffness_factor

        ret.steerRatio = ATOMC.steerRatio  #10.5  #12.5
        ret.steerRateCost = ATOMC.steerRateCost  #0.4 #0.4
        ret.steerActuatorDelay = ATOMC.steerActuatorDelay
        ret.steerLimitTimer = ATOMC.steerLimitTimer
        tire_stiffness_factor = ATOMC.tire_stiffness_factor

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        # ignore CAN2 address if L-CAN on the same BUS
        ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
                                                                         else 2 if 1056 in fingerprint[2] else -1

        ret.openpilotLongitudinalControl = False

        return ret
Exemplo n.º 26
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):  # pylint: disable=dangerous-default-value
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy
        #if candidate in [CAR.SONATA]:
        #  ret.safetyModel = car.CarParams.SafetyModel.hyundai

        params = Params()
        PidKp = int(params.get('PidKp')) * 0.01
        PidKi = int(params.get('PidKi')) * 0.001
        PidKf = int(params.get('PidKf')) * 0.00001
        InnerLoopGain = int(params.get('InnerLoopGain')) * 0.1
        OuterLoopGain = int(params.get('OuterLoopGain')) * 0.1
        TimeConstant = int(params.get('TimeConstant')) * 0.1
        ActuatorEffectiveness = int(params.get('ActuatorEffectiveness')) * 0.1
        Scale = int(params.get('Scale')) * 1.0
        LqrKi = int(params.get('LqrKi')) * 0.001
        DcGain = int(params.get('DcGain')) * 0.0001
        LqrSteerMaxV = int(params.get('SteerMaxvAdj')) * 0.1

        # Most Hyundai car ports are community features for now
        ret.communityFeature = False

        tire_stiffness_factor = int(
            params.get('TireStiffnessFactorAdj')) * 0.01
        ret.steerActuatorDelay = int(
            params.get('SteerActuatorDelayAdj')) * 0.01
        ret.steerRateCost = int(params.get('SteerRateCostAdj')) * 0.01
        ret.steerLimitTimer = int(params.get('SteerLimitTimerAdj')) * 0.01
        ret.steerRatio = int(params.get('SteerRatioAdj')) * 0.1

        if candidate == CAR.GENESIS:
            ret.mass = 1900. + STD_CARGO_KG
            ret.wheelbase = 3.01
        elif candidate == CAR.GENESIS_G70:
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.84
        elif candidate == CAR.GENESIS_G80:
            ret.mass = 1855. + STD_CARGO_KG
            ret.wheelbase = 3.01
        elif candidate == CAR.GENESIS_G90:
            ret.mass = 2200
            ret.wheelbase = 3.15
        elif candidate == CAR.GENESIS_G90_L:
            ret.mass = 2290
            ret.wheelbase = 3.45
        elif candidate in [CAR.SANTA_FE]:
            ret.mass = 1694 + STD_CARGO_KG
            ret.wheelbase = 2.766
        elif candidate in [CAR.SONATA, CAR.SONATA_HEV]:
            ret.mass = 1513. + STD_CARGO_KG
            ret.wheelbase = 2.84
        elif candidate in [CAR.SONATA19, CAR.SONATA19_HEV]:
            ret.mass = 4497. * CV.LB_TO_KG
            ret.wheelbase = 2.804
        elif candidate == CAR.SONATA_LF_TURBO:
            ret.mass = 1590. + STD_CARGO_KG
            ret.wheelbase = 2.805
        elif candidate == CAR.PALISADE:
            ret.mass = 1999. + STD_CARGO_KG
            ret.wheelbase = 2.90
        elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
        elif candidate == CAR.KONA:
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
        elif candidate in [CAR.KONA_HEV, CAR.KONA_EV]:
            ret.mass = 1685. + STD_CARGO_KG
            ret.wheelbase = 2.7
        elif candidate in [CAR.IONIQ, CAR.IONIQ_EV_LTD]:
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
        elif candidate in [CAR.GRANDEUR, CAR.GRANDEUR_HEV]:
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.845
        elif candidate == CAR.VELOSTER:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
        elif candidate == CAR.NEXO:
            ret.mass = 1885. + STD_CARGO_KG
            ret.wheelbase = 2.79
        # kia
        elif candidate == CAR.SORENTO:
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
        elif candidate in [CAR.OPTIMA, CAR.OPTIMA_HEV]:
            ret.wheelbase = 2.80
            ret.mass = 1595. + STD_CARGO_KG
        elif candidate == CAR.STINGER:
            ret.mass = 1825.0 + STD_CARGO_KG
            ret.wheelbase = 2.906  # https://www.kia.com/us/en/stinger/specs
        elif candidate == CAR.FORTE:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
        elif candidate == CAR.CEED:
            ret.mass = 1350. + STD_CARGO_KG
            ret.wheelbase = 2.65
        elif candidate == CAR.SPORTAGE:
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
        elif candidate in [CAR.NIRO_HEV, CAR.NIRO_EV]:
            ret.mass = 1737. + STD_CARGO_KG
            ret.wheelbase = 2.7
        elif candidate in [CAR.CADENZA, CAR.CADENZA_HEV]:
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.845

        if int(params.get('LateralControlMethod')) == 0:
            ret.lateralTuning.pid.kf = PidKf
            ret.lateralTuning.pid.kpBP = [0., 9.]
            ret.lateralTuning.pid.kpV = [0.1, PidKp]
            ret.lateralTuning.pid.kiBP = [0., 9.]
            ret.lateralTuning.pid.kiV = [0.01, PidKi]
        elif int(params.get('LateralControlMethod')) == 1:
            ret.lateralTuning.init('indi')
            ret.lateralTuning.indi.innerLoopGain = InnerLoopGain
            ret.lateralTuning.indi.outerLoopGain = OuterLoopGain
            ret.lateralTuning.indi.timeConstant = TimeConstant
            ret.lateralTuning.indi.actuatorEffectiveness = ActuatorEffectiveness
        elif int(params.get('LateralControlMethod')) == 2:
            ret.lateralTuning.init('lqr')
            ret.lateralTuning.lqr.scale = Scale
            ret.lateralTuning.lqr.ki = LqrKi
            ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
            ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
            ret.lateralTuning.lqr.c = [1., 0.]
            ret.lateralTuning.lqr.k = [-110., 451.]
            ret.lateralTuning.lqr.l = [0.33, 0.318]
            ret.lateralTuning.lqr.dcGain = DcGain
            ret.steerMaxV = [LqrSteerMaxV]
            ret.steerMaxBP = [0.]

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.torque

        ret.longitudinalTuning.kpBP = [0., 10., 40.]
        ret.longitudinalTuning.kpV = [1.2, 0.6, 0.2]
        ret.longitudinalTuning.kiBP = [0., 10., 30., 40.]
        ret.longitudinalTuning.kiV = [0.05, 0.02, 0.01, 0.005]
        ret.longitudinalTuning.deadzoneBP = [0., 40]
        ret.longitudinalTuning.deadzoneV = [0., 0.02]

        # steer, gas, brake limitations VS speed

        ret.gasMaxBP = [0., 10., 40.]
        ret.gasMaxV = [0.5, 0.5, 0.5]
        ret.brakeMaxBP = [0., 20.]
        ret.brakeMaxV = [1., 0.8]

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        ret.stoppingControl = True
        ret.startAccel = 0.0

        # ignore CAN2 address if L-CAN on the same BUS
        ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
                                                                         else 2 if 1056 in fingerprint[2] else -1
        ret.radarOffCan = False
        ret.openpilotLongitudinalControl = False
        ret.enableCruise = not ret.radarOffCan
        ret.spasEnabled = False

        # set safety_hyundai_community only for non-SCC, MDPS harrness or SCC harrness cars or cars that have unknown issue
        if ret.radarOffCan or ret.mdpsBus == 1 or ret.openpilotLongitudinalControl or ret.sccBus == 1 or True:
            ret.safetyModel = car.CarParams.SafetyModel.hyundaiCommunity
        return ret
Exemplo n.º 27
0
  def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay=False):

    ret = car.CarParams.new_message()

    ret.carName = "hyundai"
    ret.carFingerprint = candidate
    ret.carVin = vin
    ret.isPandaBlack = has_relay
    ret.radarOffCan = True
    ret.safetyModel = car.CarParams.SafetyModel.hyundai
    ret.enableCruise = True  # stock acc

    ret.steerActuatorDelay = 0.1  # Default delay
    ret.steerRateCost = 0.5
    ret.steerLimitTimer = 0.4
    tire_stiffness_factor = 1.

    if candidate == CAR.SANTA_FE:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG
      ret.wheelbase = 2.766

      # Values from optimizer
      ret.steerRatio = 16.55  # 13.8 is spec end-to-end
      tire_stiffness_factor = 0.82

      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[9., 22.], [9., 22.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.35], [0.05, 0.09]]
      ret.minSteerSpeed = 0.
    elif candidate == CAR.KIA_SORENTO:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1985. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.1   # 10% higher at the center seems reasonable
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
      ret.minSteerSpeed = 0.
    elif candidate == CAR.ELANTRA:
      ret.lateralTuning.pid.kf = 0.00006
      ret.mass = 1275. + STD_CARGO_KG
      ret.wheelbase = 2.7
      ret.steerRatio = 13.73   #Spec
      tire_stiffness_factor = 0.385
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
      ret.minSteerSpeed = 32 * CV.MPH_TO_MS
    elif candidate == CAR.GENESIS:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 2060. + STD_CARGO_KG
      ret.wheelbase = 3.01
      ret.steerRatio = 16.5
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]]
      ret.minSteerSpeed = 35 * CV.MPH_TO_MS
    elif candidate == CAR.KIA_OPTIMA:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 3558. * CV.LB_TO_KG
      ret.wheelbase = 2.80
      ret.steerRatio = 13.75
      tire_stiffness_factor = 0.5
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
    elif candidate == CAR.KIA_STINGER:
      ret.lateralTuning.pid.kf = 0.00005
      ret.mass = 1825. + STD_CARGO_KG
      ret.wheelbase = 2.78
      ret.steerRatio = 14.4 * 1.15   # 15% higher at the center seems reasonable
      ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
      ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
      ret.minSteerSpeed = 0.

    ret.minEnableSpeed = -1.   # enable is done by stock ACC, so ignore this
    ret.longitudinalTuning.kpBP = [0.]
    ret.longitudinalTuning.kpV = [0.]
    ret.longitudinalTuning.kiBP = [0.]
    ret.longitudinalTuning.kiV = [0.]
    ret.longitudinalTuning.deadzoneBP = [0.]
    ret.longitudinalTuning.deadzoneV = [0.]

    ret.centerToFront = ret.wheelbase * 0.4

    # TODO: get actual value, for now starting with reasonable value for
    # civic and scaling by mass and wheelbase
    ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
                                                                         tire_stiffness_factor=tire_stiffness_factor)


    # no rear steering, at least on the listed cars above
    ret.steerRatioRear = 0.
    ret.steerControlType = car.CarParams.SteerControlType.torque

    # steer, gas, brake limitations VS speed
    ret.steerMaxBP = [0.]
    ret.steerMaxV = [1.0]
    ret.gasMaxBP = [0.]
    ret.gasMaxV = [1.]
    ret.brakeMaxBP = [0.]
    ret.brakeMaxV = [1.]

    ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.CAM) or has_relay
    ret.openpilotLongitudinalControl = False

    ret.stoppingControl = False
    ret.startAccel = 0.0

    return ret
Exemplo n.º 28
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):

        ret = car.CarParams.new_message()

        ret.carName = "ford"
        ret.carFingerprint = candidate
        ret.isPandaBlack = has_relay

        ret.safetyModel = car.CarParams.SafetyModel.ford
        ret.dashcamOnly = True

        # pedal
        ret.enableCruise = True

        ret.wheelbase = 2.85
        ret.steerRatio = 14.8
        ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01], [
            0.005
        ]]  # TODO: tune this
        ret.lateralTuning.pid.kf = 1. / MAX_ANGLE  # MAX Steer angle to normalize FF
        ret.steerActuatorDelay = 0.1  # Default delay, not measured yet
        ret.steerLimitTimer = 0.8
        ret.steerRateCost = 1.0
        ret.centerToFront = ret.wheelbase * 0.44
        tire_stiffness_factor = 0.5328

        # 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.

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.angle

        # steer, gas, brake limitations VS speed
        ret.steerMaxBP = [0.]  # breakpoints at 1 and 40 kph
        ret.steerMaxV = [1.0]  # 2/3rd torque allowed above 45 kph
        ret.gasMaxBP = [0.]
        ret.gasMaxV = [0.5]
        ret.brakeMaxBP = [5., 20.]
        ret.brakeMaxV = [1., 0.8]

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               ECU.CAM) or has_relay
        ret.openpilotLongitudinalControl = False
        cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera)

        ret.stoppingControl = False
        ret.startAccel = 0.0

        ret.longitudinalTuning.deadzoneBP = [0., 9.]
        ret.longitudinalTuning.deadzoneV = [0., .15]
        ret.longitudinalTuning.kpBP = [0., 5., 35.]
        ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5]
        ret.longitudinalTuning.kiBP = [0., 35.]
        ret.longitudinalTuning.kiV = [0.54, 0.36]

        return ret
Exemplo n.º 29
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)
        ret.carName = "gm"
        ret.safetyModel = car.CarParams.SafetyModel.gm  # default to gm
        ret.enableCruise = False  # stock cruise control is kept off

        # GM port is considered a community feature, since it disables AEB;
        # TODO: make a port that uses a car harness and it only intercepts the camera
        ret.communityFeature = True

        # Presence of a camera on the object bus is ok.
        # Have to go to read_only if ASCM is online (ACC-enabled cars),
        # or camera is on powertrain bus (LKA cars without ACC).
        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay
        ret.openpilotLongitudinalControl = ret.enableCamera
        tire_stiffness_factor = 0.444  # not optimized yet

        # Start with a baseline lateral tuning for all GM vehicles. Override tuning as needed in each model section below.
        ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
        ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.00]]
        ret.lateralTuning.pid.kf = 0.00004  # full torque for 20 deg at 80mph means 0.00007818594
        ret.steerRateCost = 1.0
        ret.steerActuatorDelay = 0.1  # Default delay, not measured yet

        if candidate == CAR.VOLT:
            # supports stop and go, but initial engage must be above 18mph (which include conservatism)
            ret.minEnableSpeed = 18 * CV.MPH_TO_MS
            ret.mass = 1607. + STD_CARGO_KG
            ret.wheelbase = 2.69
            ret.steerRatio = 15.7
            ret.steerRatioRear = 0.
            ret.centerToFront = ret.wheelbase * 0.4  # wild guess

        elif candidate == CAR.MALIBU:
            # supports stop and go, but initial engage must be above 18mph (which include conservatism)
            ret.minEnableSpeed = 18 * CV.MPH_TO_MS
            ret.mass = 1496. + STD_CARGO_KG
            ret.wheelbase = 2.83
            ret.steerRatio = 15.8
            ret.steerRatioRear = 0.
            ret.centerToFront = ret.wheelbase * 0.4  # wild guess

        elif candidate == CAR.HOLDEN_ASTRA:
            ret.mass = 1363. + STD_CARGO_KG
            ret.wheelbase = 2.662
            # Remaining parameters copied from Volt for now
            ret.centerToFront = ret.wheelbase * 0.4
            ret.minEnableSpeed = 18 * CV.MPH_TO_MS
            ret.steerRatio = 15.7
            ret.steerRatioRear = 0.

        elif candidate == CAR.ACADIA:
            ret.minEnableSpeed = -1.  # engage speed is decided by pcm
            ret.mass = 4353. * CV.LB_TO_KG + STD_CARGO_KG
            ret.wheelbase = 2.86
            ret.steerRatio = 14.4  #end to end is 13.46
            ret.steerRatioRear = 0.
            ret.centerToFront = ret.wheelbase * 0.4

        elif candidate == CAR.BUICK_REGAL:
            ret.minEnableSpeed = 18 * CV.MPH_TO_MS
            ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG  # (3849+3708)/2
            ret.wheelbase = 2.83  #111.4 inches in meters
            ret.steerRatio = 14.4  # guess for tourx
            ret.steerRatioRear = 0.
            ret.centerToFront = ret.wheelbase * 0.4  # guess for tourx

        elif candidate == CAR.CADILLAC_ATS:
            ret.minEnableSpeed = 18 * CV.MPH_TO_MS
            ret.mass = 1601. + STD_CARGO_KG
            ret.wheelbase = 2.78
            ret.steerRatio = 15.3
            ret.steerRatioRear = 0.
            ret.centerToFront = ret.wheelbase * 0.49

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        ret.longitudinalTuning.kpBP = [5., 35.]
        ret.longitudinalTuning.kpV = [2.4, 1.5]
        ret.longitudinalTuning.kiBP = [0.]
        ret.longitudinalTuning.kiV = [0.36]

        ret.stoppingControl = True
        ret.startAccel = 0.8

        ret.steerLimitTimer = 0.4
        ret.radarTimeStep = 0.0667  # GM radar runs at 15Hz instead of standard 20Hz

        return ret
Exemplo n.º 30
0
    def get_params(candidate,
                   fingerprint=gen_empty_fingerprint(),
                   has_relay=False,
                   car_fw=[]):  # pylint: disable=dangerous-default-value
        ret = CarInterfaceBase.get_std_params(candidate, fingerprint,
                                              has_relay)

        ret.carName = "hyundai"
        ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy
        if candidate in [CAR.SONATA]:
            ret.safetyModel = car.CarParams.SafetyModel.hyundai

        # Most Hyundai car ports are community features for now
        ret.communityFeature = candidate not in [CAR.SONATA, CAR.PALISADE]

        ret.steerActuatorDelay = 0.1  # Default delay
        ret.steerRateCost = 0.5
        ret.steerLimitTimer = 0.8
        tire_stiffness_factor = 1.

        # genesis
        if candidate == CAR.GENESIS:
            ret.mass = 1900. + STD_CARGO_KG
            ret.wheelbase = 3.01
        elif candidate == CAR.GENESIS_G70:
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.84
        elif candidate == CAR.GENESIS_G80:
            ret.mass = 1855. + STD_CARGO_KG
            ret.wheelbase = 3.01
        elif candidate == CAR.GENESIS_G90:
            ret.mass = 2200
            ret.wheelbase = 3.15
        elif candidate == CAR.GENESIS_G90_L:
            ret.mass = 2290
            ret.wheelbase = 3.45
        # hyundai
        elif candidate in [CAR.SANTA_FE]:
            ret.mass = 1694 + STD_CARGO_KG
            ret.wheelbase = 2.766
        elif candidate in [CAR.SONATA, CAR.SONATA_HEV]:
            ret.mass = 1513. + STD_CARGO_KG
            ret.wheelbase = 2.84
            tire_stiffness_factor = 0.65
        elif candidate in [CAR.SONATA19, CAR.SONATA19_HEV]:
            ret.mass = 4497. * CV.LB_TO_KG
            ret.wheelbase = 2.804
        elif candidate == CAR.SONATA_LF_TURBO:
            ret.mass = 1590. + STD_CARGO_KG
            ret.wheelbase = 2.805
            tire_stiffness_factor = 0.65
        elif candidate == CAR.PALISADE:
            ret.mass = 1999. + STD_CARGO_KG
            ret.wheelbase = 2.90
        elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]:
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385  # stiffnessFactor settled on 1.0081302973865127
        elif candidate == CAR.KONA:
            ret.mass = 1275. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385
        elif candidate in [CAR.KONA_HEV, CAR.KONA_EV]:
            ret.mass = 1685. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385
        elif candidate in [CAR.IONIQ, CAR.IONIQ_EV_LTD]:
            ret.mass = 1490. + STD_CARGO_KG  #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385
        elif candidate in [CAR.GRANDEUR, CAR.GRANDEUR_HEV]:
            tire_stiffness_factor = 0.8
            ret.mass = 1640. + STD_CARGO_KG
            ret.wheelbase = 2.845
        elif candidate == CAR.VELOSTER:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            tire_stiffness_factor = 0.5
        # kia
        elif candidate == CAR.SORENTO:
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
            tire_stiffness_factor = 0.5
        elif candidate in [CAR.K5, CAR.K5_HEV]:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            tire_stiffness_factor = 0.5
        elif candidate == CAR.STINGER:
            tire_stiffness_factor = 1.125  # LiveParameters (Tunder's 2020)
            ret.mass = 1825.0 + STD_CARGO_KG
            ret.wheelbase = 2.906  # https://www.kia.com/us/en/stinger/specs
        elif candidate == CAR.FORTE:
            ret.mass = 3558. * CV.LB_TO_KG
            ret.wheelbase = 2.80
            tire_stiffness_factor = 0.5
        elif candidate == CAR.CEED:
            ret.mass = 1350. + STD_CARGO_KG
            ret.wheelbase = 2.65
            tire_stiffness_factor = 0.5
        elif candidate == CAR.SPORTAGE:
            ret.mass = 1985. + STD_CARGO_KG
            ret.wheelbase = 2.78
        elif candidate in [CAR.NIRO_HEV, CAR.NIRO_EV]:
            ret.mass = 1737. + STD_CARGO_KG
            ret.wheelbase = 2.7
            tire_stiffness_factor = 0.385
        elif candidate in [CAR.K7, CAR.K7_HEV]:
            tire_stiffness_factor = 0.385
            ret.mass = 1705. + STD_CARGO_KG
            ret.wheelbase = 2.855

        ret.lateralTuning.init('lqr')
        ret.lateralTuning.lqr.scale = 1900.0
        ret.lateralTuning.lqr.ki = 0.01
        ret.lateralTuning.lqr.dcGain = 0.003

        ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
        ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
        ret.lateralTuning.lqr.c = [1., 0.]
        ret.lateralTuning.lqr.k = [-110., 451.]
        ret.lateralTuning.lqr.l = [0.33, 0.318]

        ret.steerRatio = 14.4
        ret.steerActuatorDelay = 0.1
        ret.steerLimitTimer = 0.8
        ret.steerRateCost = 0.5

        ret.steerMaxBP = [0.]
        ret.steerMaxV = [1.1]

        ret.centerToFront = ret.wheelbase * 0.4

        # TODO: get actual value, for now starting with reasonable value for
        # civic and scaling by mass and wheelbase
        ret.rotationalInertia = scale_rot_inertia(ret.mass, 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, ret.tireStiffnessRear = scale_tire_stiffness(
            ret.mass,
            ret.wheelbase,
            ret.centerToFront,
            tire_stiffness_factor=tire_stiffness_factor)

        # no rear steering, at least on the listed cars above
        ret.steerRatioRear = 0.
        ret.steerControlType = car.CarParams.SteerControlType.torque

        ret.longitudinalTuning.kpBP = [0., 10., 40.]
        ret.longitudinalTuning.kpV = [1.2, 0.6, 0.2]
        ret.longitudinalTuning.kiBP = [0., 10., 30., 40.]
        ret.longitudinalTuning.kiV = [0.05, 0.02, 0.01, 0.005]
        ret.longitudinalTuning.deadzoneBP = [0., 40]
        ret.longitudinalTuning.deadzoneV = [0., 0.02]

        # steer, gas, brake limitations VS speed

        ret.gasMaxBP = [0., 10., 40.]
        ret.gasMaxV = [0.5, 0.5, 0.5]
        ret.brakeMaxBP = [0., 20.]
        ret.brakeMaxV = [1., 0.8]

        ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS,
                                               ECU_FINGERPRINT, candidate,
                                               Ecu.fwdCamera) or has_relay

        ret.stoppingControl = True
        ret.startAccel = 0.0

        # ignore CAN2 address if L-CAN on the same BUS
        ret.mdpsBus = 1 if 593 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sasBus = 1 if 688 in fingerprint[1] and 1296 not in fingerprint[
            1] else 0
        ret.sccBus = 0 if 1056 in fingerprint[0] else 1 if 1056 in fingerprint[1] and 1296 not in fingerprint[1] \
                                                                         else 2 if 1056 in fingerprint[2] else -1
        ret.radarOffCan = ret.sccBus == -1
        ret.openpilotLongitudinalControl = Params().get(
            'LongControlEnabled') == b'1'
        ret.enableCruise = not ret.radarOffCan
        ret.spasEnabled = False

        # set safety_hyundai_community only for non-SCC, MDPS harrness or SCC harrness cars or cars that have unknown issue
        if ret.radarOffCan or ret.mdpsBus == 1 or ret.openpilotLongitudinalControl or ret.sccBus == 1 or Params(
        ).get('MadModeEnabled') == b'1':
            ret.safetyModel = car.CarParams.SafetyModel.hyundaiCommunity
        return ret