Skip to content

Commit

Permalink
Tesla: setSpeed to 0 if not active (commaai#1366)
Browse files Browse the repository at this point in the history
* setSpeed to 0 if accel is 0

* setSpeed = 0 if not active
  • Loading branch information
lukasloetkolben authored and cydia2020 committed Oct 14, 2024
1 parent 7aefdec commit 336f677
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion opendbc/car/tesla/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def update(self, CC, CS, now_nanos):
state = 4 if not hands_on_fault else 13 # 4=ACC_ON, 13=ACC_CANCEL_GENERIC_SILENT
accel = clip(actuators.accel, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX)
cntr = (self.frame // 4) % 8
can_sends.append(self.tesla_can.create_longitudinal_command(state, accel, cntr))
can_sends.append(self.tesla_can.create_longitudinal_command(state, accel, cntr, CC.longActive))

# Increment counter so cancel is prioritized even without openpilot longitudinal
if hands_on_fault and not self.CP.openpilotLongitudinalControl:
Expand Down
4 changes: 2 additions & 2 deletions opendbc/car/tesla/teslacan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def create_steering_control(self, angle, enabled, counter):
values["DAS_steeringControlChecksum"] = self.checksum(0x488, data[:3])
return self.packer.make_can_msg("DAS_steeringControl", CANBUS.party, values)

def create_longitudinal_command(self, acc_state, accel, cntr):
def create_longitudinal_command(self, acc_state, accel, cntr, active):
values = {
"DAS_setSpeed": 0 if accel < 0 else V_CRUISE_MAX,
"DAS_setSpeed": 0 if (accel < 0 or not active) else V_CRUISE_MAX,
"DAS_accState": acc_state,
"DAS_aebEvent": 0,
"DAS_jerkMin": CarControllerParams.JERK_LIMIT_MIN,
Expand Down

0 comments on commit 336f677

Please sign in to comment.