Skip to content

Commit c025652

Browse files
author
zhou jielei
committed
Merge branch 'master' of https://github.com/commaai/opendbc
2 parents 07fa98f + 8864b9b commit c025652

File tree

138 files changed

+2031
-1450
lines changed

Some content is hidden

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

138 files changed

+2031
-1450
lines changed

.github/workflows/test_models_trigger.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
submodules: 'true'
3838

3939
- name: bump opendbc
40+
if: steps.check_comment.outputs.result == 'true'
4041
run: |
4142
cd opendbc_repo
4243
git fetch origin pull/${{ github.event.issue.number }}/head

.github/workflows/tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
matrix:
1616
include:
1717
- os: ${{ github.repository == 'commaai/opendbc' && 'namespace-profile-amd64-8x16' || 'ubuntu-24.04' }}
18-
- os: ${{ github.repository == 'commaai/opendbc' && 'namespace-profile-macos-8x14' || 'macos-latest' }}
18+
- os: macos-latest
1919
steps:
2020
- uses: commaai/timeout@v1
2121
- uses: actions/checkout@v4
@@ -93,6 +93,8 @@ jobs:
9393
name: Safety mutation tests
9494
runs-on: ${{ github.repository == 'commaai/opendbc' && 'namespace-profile-amd64-8x16' || 'ubuntu-latest' }}
9595
timeout-minutes: 20
96+
env:
97+
GIT_REF: ${{ github.event_name == 'push' && github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' && github.event.before || 'origin/${{ github.event.repository.default_branch }}' }}
9698
steps:
9799
- uses: actions/checkout@v4
98100
with:
@@ -102,4 +104,4 @@ jobs:
102104
run: |
103105
source setup.sh
104106
scons -j8
105-
GIT_REF=${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.event.before || 'origin/master' }} cd opendbc/safety/tests && ./mutation.sh
107+
cd opendbc/safety/tests && ./mutation.sh

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ opendbc/can/packer_pyx.cpp
2424
opendbc/can/parser_pyx.cpp
2525
opendbc/can/packer_pyx.html
2626
opendbc/can/parser_pyx.html
27-
opendbc/dbc/*_generated.dbc
27+
opendbc/dbc/*_generated.dbc
28+
29+
cppcheck-addon-ctu-file-list
30+
opendbc/safety/tests/coverage-out

docs/CARS.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
|Ford|Escape Plug-in Hybrid 2020-22|Co-Pilot360 Assist+|[Upstream](#upstream)|
4141
|Ford|Explorer 2020-24|Co-Pilot360 Assist+|[Upstream](#upstream)|
4242
|Ford|Explorer Hybrid 2020-24|Co-Pilot360 Assist+|[Upstream](#upstream)|
43-
|Ford|F-150 2021-23|Co-Pilot360 Assist 2.0|[Under review](#upstream)|
44-
|Ford|F-150 Hybrid 2021-23|Co-Pilot360 Assist 2.0|[Under review](#upstream)|
43+
|Ford|F-150 2021-23|Co-Pilot360 Assist 2.0|[Upstream](#upstream)|
44+
|Ford|F-150 Hybrid 2021-23|Co-Pilot360 Assist 2.0|[Upstream](#upstream)|
4545
|Ford|Focus 2018|Adaptive Cruise Control with Lane Centering|[Upstream](#upstream)|
4646
|Ford|Focus Hybrid 2018|Adaptive Cruise Control with Lane Centering|[Upstream](#upstream)|
4747
|Ford|Kuga 2020-22|Adaptive Cruise Control with Lane Centering|[Upstream](#upstream)|
@@ -51,8 +51,8 @@
5151
|Ford|Maverick 2023-24|Co-Pilot360 Assist|[Upstream](#upstream)|
5252
|Ford|Maverick Hybrid 2022|LARIAT Luxury|[Upstream](#upstream)|
5353
|Ford|Maverick Hybrid 2023-24|Co-Pilot360 Assist|[Upstream](#upstream)|
54-
|Ford|Mustang Mach-E 2021-23|All|[Under review](#upstream)|
55-
|Ford|Ranger 2024|Adaptive Cruise Control with Lane Centering|[Under review](#upstream)|
54+
|Ford|Mustang Mach-E 2021-23|All|[Upstream](#upstream)|
55+
|Ford|Ranger 2024|Adaptive Cruise Control with Lane Centering|[Upstream](#upstream)|
5656
|Genesis|G70 2018|All|[Upstream](#upstream)|
5757
|Genesis|G70 2019-21|All|[Upstream](#upstream)|
5858
|Genesis|G70 2022-23|All|[Upstream](#upstream)|
@@ -92,8 +92,7 @@
9292
|Honda|Inspire 2018|All|[Upstream](#upstream)|
9393
|Honda|Odyssey 2018-20|Honda Sensing|[Upstream](#upstream)|
9494
|Honda|Odyssey 2021-25|All|[Community](#community)|
95-
|Honda|Odyssey RC5 for JPN|All|[Upstream](#upstream)|
96-
|Honda|Passport 2019-23|All|[Upstream](#upstream)|
95+
|Honda|Passport 2019-25|All|[Upstream](#upstream)|
9796
|Honda|Pilot 2016-22|Honda Sensing|[Upstream](#upstream)|
9897
|Honda|Pilot 2023-24|All|[Community](#community)|
9998
|Honda|Ridgeline 2017-25|Honda Sensing|[Upstream](#upstream)|
@@ -160,7 +159,7 @@
160159
|Kia|Niro EV 2020|All|[Upstream](#upstream)|
161160
|Kia|Niro EV 2021|All|[Upstream](#upstream)|
162161
|Kia|Niro EV 2022|All|[Upstream](#upstream)|
163-
|Kia|Niro EV 2023|All|[Upstream](#upstream)|
162+
|Kia|Niro EV 2023-24|All|[Upstream](#upstream)|
164163
|Kia|Niro Hybrid 2018|All|[Upstream](#upstream)|
165164
|Kia|Niro Hybrid 2021|Smart Cruise Control (SCC)|[Upstream](#upstream)|
166165
|Kia|Niro Hybrid 2022|Smart Cruise Control (SCC)|[Upstream](#upstream)|
@@ -304,7 +303,7 @@
304303
|Toyota|RAV4 2017-18|All|[Upstream](#upstream)|
305304
|Toyota|RAV4 2019-21|All|[Upstream](#upstream)|
306305
|Toyota|RAV4 2022|All|[Upstream](#upstream)|
307-
|Toyota|RAV4 2023-24|All|[Upstream](#upstream)|
306+
|Toyota|RAV4 2023-25|All|[Upstream](#upstream)|
308307
|Toyota|RAV4 Hybrid 2016|Toyota Safety Sense P|[Upstream](#upstream)|
309308
|Toyota|RAV4 Hybrid 2017-18|All|[Upstream](#upstream)|
310309
|Toyota|RAV4 Hybrid 2019-21|All|[Upstream](#upstream)|

opendbc/can/common.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ cdef extern from "common.h":
8080
cdef cppclass CANParser:
8181
bool can_valid
8282
bool bus_timeout
83-
CANParser(int, string, vector[pair[uint32_t, int]]) except +
84-
set[uint32_t] update(vector[CanData]&) except +
85-
MessageState *getMessageState(uint32_t address)
83+
CANParser(int, string, vector[pair[uint32_t, int]]) except + nogil
84+
set[uint32_t] update(vector[CanData]&) except + nogil
85+
MessageState *getMessageState(uint32_t address) nogil
8686

8787
cdef cppclass CANPacker:
8888
CANPacker(string)

opendbc/can/dbc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ ChecksumState* get_checksum(const std::string& dbc_name) {
5757
s = new ChecksumState({8, -1, 7, -1, false, TOYOTA_CHECKSUM, &toyota_checksum});
5858
} else if (startswith(dbc_name, "hyundai_canfd_generated")) {
5959
s = new ChecksumState({16, -1, 0, -1, true, HKG_CAN_FD_CHECKSUM, &hkg_can_fd_checksum});
60-
} else if (startswith(dbc_name, {"vw_mqb_2010", "vw_mqbevo", "vw_meb"})) {
60+
} else if (startswith(dbc_name, {"vw_mqb", "vw_mqbevo", "vw_meb"})) {
6161
s = new ChecksumState({8, 4, 0, 0, true, VOLKSWAGEN_MQB_MEB_CHECKSUM, &volkswagen_mqb_meb_checksum});
62-
} else if (startswith(dbc_name, "vw_golf_mk4")) {
62+
} else if (startswith(dbc_name, "vw_pq")) {
6363
s = new ChecksumState({8, 4, 0, -1, true, XOR_CHECKSUM, &xor_checksum});
6464
} else if (startswith(dbc_name, "subaru_global_")) {
6565
s = new ChecksumState({8, -1, 0, -1, true, SUBARU_CHECKSUM, &subaru_checksum});

opendbc/can/parser_pyx.pyx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from libcpp.pair cimport pair
55
from libcpp.string cimport string
66
from libcpp.vector cimport vector
7-
from libc.stdint cimport uint32_t
7+
from libc.stdint cimport uint32_t, int
88

99
from .common cimport CANParser as cpp_CANParser
1010
from .common cimport dbc_lookup, Msg, DBC, CanData
@@ -61,11 +61,19 @@ cdef class CANParser:
6161
self.ts_nanos[address] = {name: 0.0 for name in signal_names}
6262
self.ts_nanos[name] = self.ts_nanos[address]
6363

64-
self.can = new cpp_CANParser(bus, dbc_name, message_v)
64+
cdef string cpp_dbc_name
65+
if isinstance(dbc_name, str):
66+
cpp_dbc_name = (<str>dbc_name).encode('utf-8')
67+
else:
68+
cpp_dbc_name = dbc_name # Assume bytes
69+
cdef int cpp_bus = bus
70+
with nogil:
71+
self.can = new cpp_CANParser(cpp_bus, cpp_dbc_name, message_v)
6572

6673
def __dealloc__(self):
6774
if self.can:
68-
del self.can
75+
with nogil:
76+
del self.can
6977

7078
def update_strings(self, strings, sendcan=False):
7179
# input format:
@@ -95,13 +103,16 @@ cdef class CANParser:
95103
except TypeError:
96104
raise RuntimeError("invalid parameter")
97105

98-
updated_addrs = self.can.update(can_data_array)
106+
with nogil:
107+
updated_addrs = self.can.update(can_data_array)
108+
99109
for addr in updated_addrs:
100110
vl = self.vl[addr]
101111
vl_all = self.vl_all[addr]
102112
ts_nanos = self.ts_nanos[addr]
103113

104-
state = self.can.getMessageState(addr)
114+
with nogil:
115+
state = self.can.getMessageState(addr)
105116
for i in range(state.parse_sigs.size()):
106117
name = <unicode>state.parse_sigs[i].name
107118
vl[name] = state.vals[i]
@@ -112,11 +123,17 @@ cdef class CANParser:
112123

113124
@property
114125
def can_valid(self):
115-
return self.can.can_valid
126+
cdef bint valid
127+
with nogil:
128+
valid = self.can.can_valid
129+
return valid
116130

117131
@property
118132
def bus_timeout(self):
119-
return self.can.bus_timeout
133+
cdef bint timeout
134+
with nogil:
135+
timeout = self.can.bus_timeout
136+
return timeout
120137

121138

122139
cdef class CANDefine():

opendbc/can/tests/test_checksums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_honda_checksum(self):
9393
def verify_volkswagen_mqb_crc(self, subtests, msg_name: str, msg_addr: int, test_messages: list[bytes], counter_field: str = 'COUNTER'):
9494
"""Test AUTOSAR E2E Profile 2 CRCs"""
9595
assert len(test_messages) == 16 # All counter values must be tested
96-
self.verify_checksum(subtests, "vw_mqb_2010", msg_name, msg_addr, test_messages, counter_field=counter_field)
96+
self.verify_checksum(subtests, "vw_mqb", msg_name, msg_addr, test_messages, counter_field=counter_field)
9797

9898
def test_volkswagen_mqb_crc_lwi_01(self, subtests):
9999
self.verify_volkswagen_mqb_crc(subtests, "LWI_01", 0x86, [

opendbc/car/CARS_template.md

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

3-
# Support Information for {{car_docs_with_extras | length}} Known Cars
3+
# Support Information for {{all_car_docs | length}} Known Cars
44

55
|{{ExtraCarsColumn | map(attribute='value') | join('|') | replace(hardware_col_name, wide_hardware_col_name)}}|
66
|---|---|---|{% for _ in range((ExtraCarsColumn | length) - 3) %}{{':---:|'}}{% endfor +%}
7-
{% for car_docs in car_docs_with_extras %}
7+
{% for car_docs in all_car_docs %}
88
|{% for column in ExtraCarsColumn %}{{car_docs.get_extra_cars_column(column)}}|{% endfor %}
99

1010
{% endfor %}

opendbc/car/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,16 @@ class Bus(StrEnum):
9898
ap_party = auto()
9999

100100

101-
def apply_driver_steer_torque_limits(apply_torque, apply_torque_last, driver_torque, LIMITS):
101+
def apply_driver_steer_torque_limits(apply_torque: int, apply_torque_last: int, driver_torque: float, LIMITS, steer_max: int = None):
102+
# some safety modes utilize a dynamic max steer
103+
if steer_max is None:
104+
steer_max = LIMITS.STEER_MAX
102105

103106
# limits due to driver torque
104-
driver_max_torque = LIMITS.STEER_MAX + (LIMITS.STEER_DRIVER_ALLOWANCE + driver_torque * LIMITS.STEER_DRIVER_FACTOR) * LIMITS.STEER_DRIVER_MULTIPLIER
105-
driver_min_torque = -LIMITS.STEER_MAX + (-LIMITS.STEER_DRIVER_ALLOWANCE + driver_torque * LIMITS.STEER_DRIVER_FACTOR) * LIMITS.STEER_DRIVER_MULTIPLIER
106-
max_steer_allowed = max(min(LIMITS.STEER_MAX, driver_max_torque), 0)
107-
min_steer_allowed = min(max(-LIMITS.STEER_MAX, driver_min_torque), 0)
107+
driver_max_torque = steer_max + (LIMITS.STEER_DRIVER_ALLOWANCE + driver_torque * LIMITS.STEER_DRIVER_FACTOR) * LIMITS.STEER_DRIVER_MULTIPLIER
108+
driver_min_torque = -steer_max + (-LIMITS.STEER_DRIVER_ALLOWANCE + driver_torque * LIMITS.STEER_DRIVER_FACTOR) * LIMITS.STEER_DRIVER_MULTIPLIER
109+
max_steer_allowed = max(min(steer_max, driver_max_torque), 0)
110+
min_steer_allowed = min(max(-steer_max, driver_min_torque), 0)
108111
apply_torque = np.clip(apply_torque, min_steer_allowed, max_steer_allowed)
109112

110113
# slow rate if steer torque increases in magnitude

0 commit comments

Comments
 (0)