Skip to content

Commit 9804230

Browse files
authored
Merge branch 'master' into odyssey-singapore
2 parents 9c559d6 + 1f68add commit 9804230

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+914
-1034
lines changed

SConscript

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
Import("env")
2-
3-
SConscript(['opendbc/dbc/SConscript'], exports={'env': env})
1+
SConscript(['opendbc/dbc/SConscript'])
42

53
# test files
64
if GetOption('extras'):

SConstruct

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,11 @@
1-
import os
2-
import subprocess
3-
import platform
4-
5-
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
6-
if platform.system() == "Darwin":
7-
arch = "Darwin"
8-
9-
cpppath = [
10-
'#',
11-
'/usr/lib/include',
12-
]
13-
141
AddOption('--minimal',
152
action='store_false',
163
dest='extras',
174
default=True,
185
help='the minimum build. no tests, tools, etc.')
196

20-
AddOption('--asan',
21-
action='store_true',
22-
help='turn on ASAN')
23-
24-
# safety options
257
AddOption('--ubsan',
268
action='store_true',
279
help='turn on UBSan')
2810

29-
AddOption('--mutation',
30-
action='store_true',
31-
help='generate mutation-ready code')
32-
33-
ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] if GetOption('asan') else []
34-
ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else []
35-
36-
env = Environment(
37-
ENV=os.environ,
38-
CC='gcc',
39-
CXX='g++',
40-
CCFLAGS=[
41-
"-g",
42-
"-fPIC",
43-
"-O2",
44-
"-Wunused",
45-
"-Werror",
46-
"-Wshadow",
47-
"-Wno-vla-cxx-extension",
48-
"-Wno-unknown-warning-option", # for compatibility across compiler versions
49-
] + ccflags_asan,
50-
LDFLAGS=ldflags_asan,
51-
LINKFLAGS=ldflags_asan,
52-
CFLAGS="-std=gnu11",
53-
CXXFLAGS=["-std=c++1z"],
54-
CPPPATH=cpppath,
55-
tools=["default", "compilation_db"]
56-
)
57-
if arch != "Darwin":
58-
env.Append(CCFLAGS=["-fmax-errors=1", ])
59-
60-
env.CompilationDatabase('compile_commands.json')
61-
62-
Export('env', 'arch')
63-
6411
SConscript(['SConscript'])

docs/CARS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--- AUTOGENERATED FROM selfdrive/car/CARS_template.md, DO NOT EDIT. --->
22

3-
# Support Information for 380 Known Cars
3+
# Support Information for 383 Known Cars
44

55
|Make|Model|Package|Support Level|
66
|---|---|---|:---:|
@@ -9,13 +9,16 @@
99
|Acura|Integra 2023-25|All|[Community](#community)|
1010
|Acura|MDX 2015-16|Advance Package|[Community](#community)|
1111
|Acura|MDX 2017-20|All|[Community](#community)|
12+
|Acura|MDX 2022-24|All|[Community](#community)|
1213
|Acura|MDX 2025|All except Type S|[Upstream](#upstream)|
1314
|Acura|RDX 2016-18|AcuraWatch Plus or Advance Package|[Upstream](#upstream)|
1415
|Acura|RDX 2019-21|All|[Upstream](#upstream)|
1516
|Acura|RDX 2022-25|All|[Community](#community)|
1617
|Acura|RLX 2017|Advance Package or Technology Package|[Community](#community)|
1718
|Acura|TLX 2015-17|Advance Package|[Community](#community)|
1819
|Acura|TLX 2018-20|All|[Community](#community)|
20+
|Acura|TLX 2021|All|[Upstream](#upstream)|
21+
|Acura|TLX 2022-23|All|[Community](#community)|
1922
|Acura|ZDX 2024|All|[Not compatible](#can-bus-security)|
2023
|Audi|A3 2014-19|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|
2124
|Audi|A3 Sportback e-tron 2017-18|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|

opendbc/car/common/filter_simple.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,43 @@ class FirstOrderFilter:
22
# first order filter
33
def __init__(self, x0, rc, dt, initialized=True):
44
self.x = x0
5-
self.dt = dt
5+
self._dt = dt
66
self.update_alpha(rc)
77
self.initialized = initialized
88

9+
def update_dt(self, dt):
10+
self._dt = dt
11+
self.update_alpha(self._rc)
12+
913
def update_alpha(self, rc):
10-
self.alpha = self.dt / (rc + self.dt)
14+
self._rc = rc
15+
self._alpha = self._dt / (self._rc + self._dt)
1116

1217
def update(self, x):
1318
if self.initialized:
14-
self.x = (1. - self.alpha) * self.x + self.alpha * x
19+
self.x = (1. - self._alpha) * self.x + self._alpha * x
1520
else:
1621
self.initialized = True
1722
self.x = x
1823
return self.x
24+
25+
26+
class HighPassFilter:
27+
# technically a band-pass filter
28+
def __init__(self, x0, rc1, rc2, dt, initialized=True):
29+
self.x = x0
30+
self._f1 = FirstOrderFilter(x0, rc1, dt, initialized)
31+
self._f2 = FirstOrderFilter(x0, rc2, dt, initialized)
32+
assert rc2 > rc1, "rc2 must be greater than rc1"
33+
34+
def update_dt(self, dt):
35+
self._f1.update_dt(dt)
36+
self._f2.update_dt(dt)
37+
38+
def update_alpha(self, rc1, rc2):
39+
self._f1.update_alpha(rc1)
40+
self._f2.update_alpha(rc2)
41+
42+
def update(self, x):
43+
self.x = self._f1.update(x) - self._f2.update(x)
44+
return self.x

opendbc/car/honda/carcontroller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from opendbc.car import Bus, DT_CTRL, rate_limit, make_tester_present_msg, structs
55
from opendbc.car.honda import hondacan
66
from opendbc.car.honda.values import CAR, CruiseButtons, HONDA_BOSCH, HONDA_BOSCH_CANFD, HONDA_BOSCH_RADARLESS, \
7-
HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams
7+
HONDA_BOSCH_TJA_CONTROL, HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams
88
from opendbc.car.interfaces import CarControllerBase
99

1010
VisualAlert = structs.CarControl.HUDControl.VisualAlert
@@ -94,6 +94,7 @@ def __init__(self, dbc_names, CP):
9494
self.packer = CANPacker(dbc_names[Bus.pt])
9595
self.params = CarControllerParams(CP)
9696
self.CAN = hondacan.CanBus(CP)
97+
self.tja_control = CP.carFingerprint in HONDA_BOSCH_TJA_CONTROL
9798

9899
self.braking = False
99100
self.brake_steady = 0.
@@ -151,7 +152,7 @@ def update(self, CC, CS, now_nanos):
151152
can_sends.append(make_tester_present_msg(0x18DAB0F1, 1, suppress_response=True))
152153

153154
# Send steering command.
154-
can_sends.append(hondacan.create_steering_control(self.packer, self.CAN, apply_torque, CC.latActive))
155+
can_sends.append(hondacan.create_steering_control(self.packer, self.CAN, apply_torque, CC.latActive, self.tja_control))
155156

156157
# wind brake from air resistance decel at high speed
157158
wind_brake = np.interp(CS.out.vEgo, [0.0, 2.3, 35.0], [0.001, 0.002, 0.15])

opendbc/car/honda/hondacan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ def create_acc_commands(packer, CAN, enabled, active, accel, gas, stopping_count
114114
return commands
115115

116116

117-
def create_steering_control(packer, CAN, apply_torque, lkas_active):
117+
def create_steering_control(packer, CAN, apply_torque, lkas_active, tja_control):
118118
values = {
119119
"STEER_TORQUE": apply_torque if lkas_active else 0,
120120
"STEER_TORQUE_REQUEST": lkas_active,
121+
"STEER_DOWN_TO_ZERO": lkas_active and tja_control,
121122
}
122123
return packer.make_can_msg("STEERING_CONTROL", CAN.lkas, values)
123124

opendbc/car/honda/values.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ class HondaFlags(IntFlag):
7878
BOSCH_ALT_RADAR = 512
7979
ALLOW_MANUAL_TRANS = 1024
8080
HYBRID = 2048
81-
# reserving 4096 for hybrid brakehold
82-
NO_CARSPEED = 8192 # Some foreign models do not have carspeed
81+
BOSCH_TJA_CONTROL = 4096
82+
# reserving 8192 for hybrid brakehold
83+
NO_CARSPEED = 16384 # Some foreign models do not have carspeed
8384

8485

8586
# Car button codes
@@ -368,6 +369,7 @@ class CAR(Platforms):
368369
HONDA_BOSCH_RADARLESS = CAR.with_flags(HondaFlags.BOSCH_RADARLESS)
369370
HONDA_BOSCH_CANFD = CAR.with_flags(HondaFlags.BOSCH_CANFD)
370371
HONDA_BOSCH_ALT_RADAR = CAR.with_flags(HondaFlags.BOSCH_ALT_RADAR)
372+
HONDA_BOSCH_TJA_CONTROL = CAR.with_flags(HondaFlags.BOSCH_TJA_CONTROL)
371373

372374

373375
DBC = CAR.create_dbc_map()

opendbc/car/tests/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ class CarTestRoute(NamedTuple):
225225
CarTestRoute("7e34a988419b5307/2019-12-18--19-13-30", TOYOTA.TOYOTA_RAV4_TSS2), # hybrid
226226
CarTestRoute("2475fb3eb2ffcc2e/2022-04-29--12-46-23", TOYOTA.TOYOTA_RAV4_TSS2_2022), # hybrid
227227
CarTestRoute("20ba9ade056a8c7b/2021-02-08--21-57-35", TOYOTA.TOYOTA_RAV4_PRIME), # SecOC
228+
CarTestRoute("41ba5b181f29435d/00000001--e3ae76382f", TOYOTA.TOYOTA_RAV4_PRIME), # SecOC longitudinal
228229
CarTestRoute("8bfb000e03b2a257/00000004--f9eee5f52e", TOYOTA.TOYOTA_SIENNA_4TH_GEN), # SecOC
229230
CarTestRoute("0b54d0594d924cd9/00000057--b6206a3205", TOYOTA.TOYOTA_YARIS), # SecOC
230231
CarTestRoute("7a31f030957b9c85/2023-04-01--14-12-51", TOYOTA.LEXUS_ES),

opendbc/car/toyota/carcontroller.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from opendbc.car.lateral import apply_meas_steer_torque_limits, apply_std_steer_angle_limits, common_fault_avoidance
55
from opendbc.car.can_definitions import CanData
66
from opendbc.car.carlog import carlog
7-
from opendbc.car.common.filter_simple import FirstOrderFilter
7+
from opendbc.car.common.filter_simple import FirstOrderFilter, HighPassFilter
88
from opendbc.car.common.pid import PIDController
99
from opendbc.car.secoc import add_mac, build_sync_mac
1010
from opendbc.car.interfaces import CarControllerBase
@@ -65,8 +65,8 @@ def __init__(self, dbc_names, CP):
6565
# *** start long control state ***
6666
self.long_pid = get_long_tune(self.CP, self.params)
6767
self.aego = FirstOrderFilter(0.0, 0.25, DT_CTRL * 3)
68-
self.pitch = FirstOrderFilter(0, 0.25, DT_CTRL)
69-
self.pitch_slow = FirstOrderFilter(0, 1.5, DT_CTRL)
68+
self.pitch = FirstOrderFilter(0, 0.5, DT_CTRL)
69+
self.pitch_hp = HighPassFilter(0.0, 0.25, 1.5, DT_CTRL)
7070

7171
self.accel = 0
7272
self.prev_accel = 0
@@ -76,6 +76,7 @@ def __init__(self, dbc_names, CP):
7676

7777
self.secoc_lka_message_counter = 0
7878
self.secoc_lta_message_counter = 0
79+
self.secoc_acc_message_counter = 0
7980
self.secoc_prev_reset_counter = 0
8081

8182
def update(self, CC, CS, now_nanos):
@@ -87,7 +88,7 @@ def update(self, CC, CS, now_nanos):
8788

8889
if len(CC.orientationNED) == 3:
8990
self.pitch.update(CC.orientationNED[1])
90-
self.pitch_slow.update(CC.orientationNED[1])
91+
self.pitch_hp.update(CC.orientationNED[1])
9192

9293
# *** control msgs ***
9394
can_sends = []
@@ -97,6 +98,7 @@ def update(self, CC, CS, now_nanos):
9798
if CS.secoc_synchronization['RESET_CNT'] != self.secoc_prev_reset_counter:
9899
self.secoc_lka_message_counter = 0
99100
self.secoc_lta_message_counter = 0
101+
self.secoc_acc_message_counter = 0
100102
self.secoc_prev_reset_counter = CS.secoc_synchronization['RESET_CNT']
101103

102104
expected_mac = build_sync_mac(self.secoc_key, int(CS.secoc_synchronization['TRIP_CNT']), int(CS.secoc_synchronization['RESET_CNT']))
@@ -228,8 +230,7 @@ def update(self, CC, CS, now_nanos):
228230
if not stopping:
229231
# Toyota's PCM slowly responds to changes in pitch. On change, we amplify our
230232
# acceleration request to compensate for the undershoot and following overshoot
231-
high_pass_pitch = self.pitch.x - self.pitch_slow.x
232-
pitch_compensation = float(np.clip(math.sin(high_pass_pitch) * ACCELERATION_DUE_TO_GRAVITY,
233+
pitch_compensation = float(np.clip(math.sin(self.pitch_hp.x) * ACCELERATION_DUE_TO_GRAVITY,
233234
-MAX_PITCH_COMPENSATION, MAX_PITCH_COMPENSATION))
234235
pcm_accel_cmd += pitch_compensation
235236

@@ -250,8 +251,19 @@ def update(self, CC, CS, now_nanos):
250251

251252
pcm_accel_cmd = float(np.clip(pcm_accel_cmd, self.params.ACCEL_MIN, self.params.ACCEL_MAX))
252253

253-
can_sends.append(toyotacan.create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.permit_braking, self.standstill_req, lead,
254+
main_accel_cmd = 0. if self.CP.flags & ToyotaFlags.SECOC.value else pcm_accel_cmd
255+
can_sends.append(toyotacan.create_accel_command(self.packer, main_accel_cmd, pcm_cancel_cmd, self.permit_braking, self.standstill_req, lead,
254256
CS.acc_type, fcw_alert, self.distance_button))
257+
if self.CP.flags & ToyotaFlags.SECOC.value:
258+
acc_cmd_2 = toyotacan.create_accel_command_2(self.packer, pcm_accel_cmd)
259+
acc_cmd_2 = add_mac(self.secoc_key,
260+
int(CS.secoc_synchronization['TRIP_CNT']),
261+
int(CS.secoc_synchronization['RESET_CNT']),
262+
self.secoc_acc_message_counter,
263+
acc_cmd_2)
264+
self.secoc_acc_message_counter += 1
265+
can_sends.append(acc_cmd_2)
266+
255267
self.accel = pcm_accel_cmd
256268

257269
else:

opendbc/car/toyota/carstate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from opendbc.car.common.filter_simple import FirstOrderFilter
77
from opendbc.car.interfaces import CarStateBase
88
from opendbc.car.toyota.values import ToyotaFlags, CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, \
9-
TSS2_CAR, RADAR_ACC_CAR, EPS_SCALE, UNSUPPORTED_DSU_CAR
9+
TSS2_CAR, RADAR_ACC_CAR, EPS_SCALE, UNSUPPORTED_DSU_CAR, \
10+
SECOC_CAR
1011

1112
ButtonType = structs.CarState.ButtonEvent.Type
1213
SteerControlType = structs.CarParams.SteerControlType
@@ -190,14 +191,14 @@ def update(self, can_parsers) -> structs.CarState:
190191
buttonEvents.extend(create_button_events(1, 0, {1: ButtonType.lkas}) +
191192
create_button_events(0, 1, {1: ButtonType.lkas}))
192193

193-
if self.CP.carFingerprint not in RADAR_ACC_CAR:
194+
if self.CP.carFingerprint not in (RADAR_ACC_CAR | SECOC_CAR):
194195
# distance button is wired to the ACC module (camera or radar)
195196
prev_distance_button = self.distance_button
196197
self.distance_button = cp_acc.vl["ACC_CONTROL"]["DISTANCE"]
197198

198199
buttonEvents += create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise})
199-
ret.buttonEvents = buttonEvents
200200

201+
ret.buttonEvents = buttonEvents
201202
return ret
202203

203204
@staticmethod

0 commit comments

Comments
 (0)