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 fafc77f commit 6a3835c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion opendbc
8 changes: 5 additions & 3 deletions selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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))

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 6a3835c

Please sign in to comment.