From 6a3835c337b2bab477252000cf60a850960169ec Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 19 Mar 2024 11:50:17 +0100 Subject: [PATCH] add gasPressed --- opendbc | 2 +- selfdrive/car/toyota/carstate.py | 8 +++++--- selfdrive/car/toyota/interface.py | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/opendbc b/opendbc index 6484550f093b6d..916726e2a45dab 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit 6484550f093b6d21d2520a21f5c75bd47a59996d +Subproject commit 916726e2a45dab7c2e9961d3b9ce8ce38ecc60c6 diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 87687d33b8cc2a..5ed02466d9d749 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -67,10 +67,11 @@ def update(self, cp, cp_cam): if self.CP.enableGasInterceptor: ret.gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) // 2 ret.gasPressed = ret.gas > 805 + elif self.CP.flags & ToyotaFlags.GEAR_PACKET_HYBRID.value: + ret.gas = cp.vl["GAS_PEDAL"]["GAS_PEDAL_USER"] + ret.gasPressed = cp.vl["GAS_PEDAL"]["GAS_PEDAL_USER"] > 0 else: - # TODO: find a common gas pedal percentage signal - if self.CP.carFingerprint not in [CAR.RAV4_PRIME]: - ret.gasPressed = cp.vl["PCM_CRUISE"]["GAS_RELEASED"] == 0 + ret.gasPressed = cp.vl["PCM_CRUISE"]["GAS_RELEASED"] == 0 ret.wheelSpeeds = self.get_wheel_speeds( cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FL"], @@ -217,6 +218,7 @@ def get_can_parser(CP): if CP.flags & ToyotaFlags.GEAR_PACKET_HYBRID.value: messages.append(("GEAR_PACKET_HYBRID", 60)) + messages.append(("GAS_PEDAL", 42)) else: messages.append(("GEAR_PACKET", 1)) diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 75c98263857660..9a9887b6d475e1 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -55,7 +55,8 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): ret.flags |= ToyotaFlags.RADAR_CAN_FILTER.value # Detect missing GEAR_PACKET msg, but has GEAR_PACKET_HYBRID - if 0x3BC not in fingerprint[0] and 0x127 in fingerprint[0]: + # For new we also assume this correlates to having a the GAS_PEDAL message on 0x116 + if 0x3BC not in fingerprint[0] and 0x127 in fingerprint[0] and 0x116 in fingerprint[0]: ret.flags |= ToyotaFlags.GEAR_PACKET_HYBRID.value # In TSS2 cars, the camera does long control