Skip to content

Commit

Permalink
remove ACCEL_TO_SPEED_MULTIPLIER
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasloetkolben committed Sep 23, 2024
1 parent d928a8b commit 210c29c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
13 changes: 5 additions & 8 deletions opendbc/car/tesla/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from opendbc.car import apply_std_steer_angle_limits
from opendbc.car.interfaces import CarControllerBase
from opendbc.car.tesla.teslacan import TeslaCAN
from opendbc.car.tesla.values import DBC, CarControllerParams
from opendbc.car.tesla.values import CarControllerParams


class CarController(CarControllerBase):
Expand Down Expand Up @@ -41,18 +41,15 @@ def update(self, CC, CS, now_nanos):
if self.CP.openpilotLongitudinalControl and self.frame % 4 == 0:
state = CS.das_control["DAS_accState"]
if hands_on_fault:
state = 13 # "ACC_CANCEL_GENERIC_SILENT"
state = 13 # "ACC_CANCEL_GENERIC_SILENT"
accel = clip(actuators.accel, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX)
speed = max(CS.out.vEgo + (accel * CarControllerParams.ACCEL_TO_SPEED_MULTIPLIER), 0)
min_accel = max(accel, 0)
max_accel = accel
cntr = (self.frame // 4) % 8
can_sends.append(self.tesla_can.create_longitudinal_command(state, speed, max_accel, min_accel, cntr))
cntr = (self.frame // 4) % 8
can_sends.append(self.tesla_can.create_longitudinal_command(state, accel, cntr))

# Increment counter so cancel is prioritized even without openpilot longitudinal
if hands_on_fault and not self.CP.openpilotLongitudinalControl:
cntr = (CS.das_control["DAS_controlCounter"] + 1) % 8
can_sends.append(self.tesla_can.create_cancel_command(cntr))
can_sends.append(self.tesla_can.create_longitudinal_command(13, 0, cntr))

# TODO: HUD control
new_actuators = copy.copy(actuators)
Expand Down
13 changes: 5 additions & 8 deletions opendbc/car/tesla/teslacan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.interfaces import V_CRUISE_MAX
from opendbc.car.tesla.values import CANBUS, CarControllerParams


Expand All @@ -24,21 +24,18 @@ 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, speed, min_accel, max_accel, cntr):
def create_longitudinal_command(self, acc_state, accel, cntr):
values = {
"DAS_setSpeed": speed * CV.MS_TO_KPH,
"DAS_setSpeed": 0 if accel < 0 else V_CRUISE_MAX,
"DAS_accState": acc_state,
"DAS_aebEvent": 0,
"DAS_jerkMin": CarControllerParams.JERK_LIMIT_MIN,
"DAS_jerkMax": CarControllerParams.JERK_LIMIT_MAX,
"DAS_accelMin": min_accel,
"DAS_accelMax": max_accel,
"DAS_accelMin": max(accel, 0),
"DAS_accelMax": accel,
"DAS_controlCounter": cntr,
"DAS_controlChecksum": 0,
}
data = self.packer.make_can_msg("DAS_control", CANBUS.party, values)[1]
values["DAS_controlChecksum"] = self.checksum(0x2b9, data[:7])
return self.packer.make_can_msg("DAS_control", CANBUS.party, values)

def create_cancel_command(self, cntr):
return self.create_longitudinal_command(13, 0, 0, 0, cntr)
1 change: 0 additions & 1 deletion opendbc/car/tesla/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class CarControllerParams:
ACCEL_MAX = 2.0 # m/s^2
JERK_LIMIT_MAX = 5
JERK_LIMIT_MIN = -5
ACCEL_TO_SPEED_MULTIPLIER = 3

def __init__(self, CP):
pass
Expand Down

0 comments on commit 210c29c

Please sign in to comment.