Skip to content

Commit

Permalink
Re-enable Toyota for Gray panda (sshane#43)
Browse files Browse the repository at this point in the history
Co-authored-by: kegman <8837066+kegman@users.noreply.github.com>
  • Loading branch information
kegman and kegman authored Nov 29, 2020
1 parent b1fad46 commit d708e11
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 98 deletions.
20 changes: 6 additions & 14 deletions selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def compute_gb(accel, speed):
return float(accel) / 3.0

@staticmethod
def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
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 = "toyota"
ret.safetyModel = car.CarParams.SafetyModel.toyota
Expand Down Expand Up @@ -243,7 +243,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
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]:
elif candidate == CAR.LEXUS_NXH:
stop_and_go = True
ret.safetyParam = 73
ret.wheelbase = 2.66
Expand All @@ -253,16 +253,6 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
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

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

Expand All @@ -275,7 +265,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
tire_stiffness_factor=tire_stiffness_factor)

ret.enableCamera = True
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
Expand Down Expand Up @@ -327,6 +317,8 @@ def update(self, c, can_strings):
# events
events = self.create_common_events(ret)

if self.cp_cam.can_invalid_cnt >= 200 and self.CP.enableCamera and not self.CP.isPandaBlack:
events.add(EventName.invalidGiraffeToyota)
if self.CS.low_speed_lockout and self.CP.openpilotLongitudinalControl:
events.add(EventName.lowSpeedLockout)
if ret.vEgo < self.CP.minEnableSpeed and self.CP.openpilotLongitudinalControl:
Expand Down
Loading

0 comments on commit d708e11

Please sign in to comment.