Skip to content

Commit

Permalink
add gasPressed
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm committed Mar 19, 2024
1 parent aa5d769 commit 56995fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def update(self, cp, cp_cam):
ret.brakePressed = cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0
ret.brakeHoldActive = cp.vl["ESP_CONTROL"]["BRAKE_HOLD_ACTIVE"] == 1

if self.CP.carFingerprint not in [CAR.RAV4_PRIME]:
if 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:
ret.gasPressed = cp.vl["PCM_CRUISE"]["GAS_RELEASED"] == 0

ret.wheelSpeeds = self.get_wheel_speeds(
Expand Down Expand Up @@ -213,6 +216,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))

Expand Down
3 changes: 2 additions & 1 deletion selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56995fe

Please sign in to comment.