1
1
import numpy as np
2
2
from collections import namedtuple
3
3
4
- from opendbc .car .common .conversions import Conversions as CV
5
4
from opendbc .can .packer import CANPacker
6
- from opendbc .car import Bus , DT_CTRL , rate_limit , make_tester_present_msg , structs
5
+ from opendbc .car import Bus , DT_CTRL , rate_limit , make_tester_present_msg , structs , apply_driver_steer_torque_limits
7
6
from opendbc .car .honda import hondacan
8
- from opendbc .car .honda .values import CruiseButtons , VISUAL_HUD , HONDA_BOSCH , HONDA_BOSCH_RADARLESS , HONDA_NIDEC_ALT_PCM_ACCEL , CarControllerParams
7
+ from opendbc .car .common .conversions import Conversions as CV
8
+ from opendbc .car .honda .values import CruiseButtons , VISUAL_HUD , HONDA_BOSCH , HONDA_BOSCH_RADARLESS , HONDA_NIDEC_ALT_PCM_ACCEL , HONDA_BOSCH_1000 , \
9
+ CarControllerParams , SERIAL_STEERING , LKAS_LIMITS
9
10
from opendbc .car .interfaces import CarControllerBase
10
11
11
12
VisualAlert = structs .CarControl .HUDControl .VisualAlert
@@ -18,7 +19,7 @@ def compute_gb_honda_bosch(accel, speed):
18
19
19
20
20
21
def compute_gb_honda_nidec (accel , speed ):
21
- newaccel = np . interp ( accel , [- 3.5 , 0 , 2 ] , [- 14 , 0 , 8 ] )
22
+ newaccel = interp ( accel , [- 3.5 , 0 , 2 ] , [- 14 , 0 , 8 ] )
22
23
creep_brake = 0.0
23
24
creep_speed = 2.3
24
25
creep_brake_value = 0.15
@@ -121,8 +122,7 @@ def __init__(self, dbc_names, CP):
121
122
def update (self , CC , CS , now_nanos ):
122
123
actuators = CC .actuators
123
124
hud_control = CC .hudControl
124
- conversion = CV .KPH_TO_MS # MVL
125
- # hondacan.get_cruise_speed_conversion(self.CP.carFingerprint, CS.is_metric)
125
+ conversion = CV .KPH_TO_MS if CS .is_metric_cruise else CV .MPH_TO_MS
126
126
hud_v_cruise = hud_control .setSpeed / conversion if hud_control .speedVisible else 255
127
127
pcm_cancel_cmd = CC .cruiseControl .cancel
128
128
@@ -150,6 +150,11 @@ def update(self, CC, CS, now_nanos):
150
150
151
151
# **** process the car messages ****
152
152
153
+ if (CS .CP .carFingerprint in SERIAL_STEERING ):
154
+ limited_torque = apply_driver_steer_torque_limits (limited_torque , self .last_torque , CS .out .steeringTorque , LKAS_LIMITS )
155
+ self .last_torque = limited_torque
156
+ self .apply_steer_over_max_counter = 0
157
+
153
158
# steer torque is converted back to CAN reference (positive when steering right)
154
159
apply_torque = int (np .interp (- limited_torque * self .params .STEER_MAX ,
155
160
self .params .STEER_LOOKUP_BP , self .params .STEER_LOOKUP_V ))
@@ -163,7 +168,7 @@ def update(self, CC, CS, now_nanos):
163
168
can_sends .append (make_tester_present_msg (0x18DAB0F1 , 1 , suppress_response = True ))
164
169
165
170
# Send steering command.
166
- can_sends .append (hondacan .create_steering_control (self .packer , self .CAN , apply_torque , CC .latActive , self .CP .carfingerprint ))
171
+ can_sends .append (hondacan .create_steering_control (self .packer , self .CAN , apply_torque , CC .latActive , self .CP .carFingerprint ))
167
172
168
173
# wind brake from air resistance decel at high speed
169
174
wind_brake = np .interp (CS .out .vEgo , [0.0 , 2.3 , 35.0 ], [0.001 , 0.002 , 0.15 ])
@@ -196,7 +201,7 @@ def update(self, CC, CS, now_nanos):
196
201
197
202
if not self .CP .openpilotLongitudinalControl :
198
203
if self .frame % 2 == 0 and self .CP .carFingerprint not in HONDA_BOSCH_RADARLESS : # radarless cars don't have supplemental message
199
- can_sends .append (hondacan .create_bosch_supplemental_1 (self .packer , self .CAN ))
204
+ can_sends .append (hondacan .create_bosch_supplemental_1 (self .packer , self .CAN , self . CP . carFingerprint ))
200
205
# If using stock ACC, spam cancel command to kill gas when OP disengages.
201
206
if pcm_cancel_cmd :
202
207
can_sends .append (hondacan .spam_buttons_command (self .packer , self .CAN , CruiseButtons .CANCEL , self .CP .carFingerprint ))
@@ -210,7 +215,10 @@ def update(self, CC, CS, now_nanos):
210
215
211
216
if self .CP .carFingerprint in HONDA_BOSCH :
212
217
self .accel = float (np .clip (accel , self .params .BOSCH_ACCEL_MIN , self .params .BOSCH_ACCEL_MAX ))
213
- self .gas = float (np .interp (accel , self .params .BOSCH_GAS_LOOKUP_BP , self .params .BOSCH_GAS_LOOKUP_V ))
218
+ if self .CP .carFingerprint in HONDA_BOSCH_1000 :
219
+ self .gas = float (np .interp (accel , self .params .BOSCH_GAS_LOOKUP_BP , self .params .BOSCH_1000_GAS_LOOKUP_V ))
220
+ else :
221
+ self .gas = float (np .interp (accel , self .params .BOSCH_GAS_LOOKUP_BP , self .params .BOSCH_GAS_LOOKUP_V ))
214
222
215
223
stopping = actuators .longControlState == LongCtrlState .stopping
216
224
self .stopping_counter = self .stopping_counter + 1 if stopping else 0
0 commit comments