Skip to content

Commit 5408af4

Browse files
authored
Merge branch 'commaai:master' into master
2 parents 19d10cb + 3ff5371 commit 5408af4

File tree

10 files changed

+53
-53
lines changed

10 files changed

+53
-53
lines changed

opendbc/car/rivian/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, alpha_lo
2424
ret.steerControlType = structs.CarParams.SteerControlType.torque
2525
ret.radarUnavailable = True
2626

27-
# TODO: pending finding/handling missing set speed and fixing up radar parser
27+
# TODO: pending finding/handling missing set speed
2828
ret.alphaLongitudinalAvailable = False
2929
if alpha_long:
3030
ret.openpilotLongitudinalControl = True

opendbc/car/rivian/radar_interface.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,27 @@ def _update(self, updated_messages):
5050
for addr in range(RADAR_START_ADDR, RADAR_START_ADDR + RADAR_MSG_COUNT):
5151
msg = self.rcp.vl[f"RADAR_TRACK_{addr:x}"]
5252

53-
if addr not in self.pts:
54-
self.pts[addr] = structs.RadarData.RadarPoint()
55-
self.pts[addr].trackId = self.track_id
56-
self.track_id += 1
53+
# STATE: 1=New, 2=New_updated, 3=Updated, 4=Coasting, 7=New_coasting
54+
valid = msg['STATE'] in (1, 2, 3, 4, 7)
55+
56+
# Rivian's Short Range Radar (SSR) detects close stationary objects like guardrails, which cause phantom braking.
57+
# MODE: 1=SRR, 2=LRR, 3=SRR_and_LRR
58+
valid = valid and msg['MODE'] in (2, 3)
5759

58-
valid = msg['STATE'] in (3, 4) and msg['STATE_2'] == 1
5960
if valid:
61+
if addr not in self.pts or msg['STATE'] in (1, 2, 7):
62+
self.pts[addr] = structs.RadarData.RadarPoint()
63+
self.pts[addr].trackId = self.track_id
64+
self.track_id += 1
65+
66+
self.pts[addr].measured = msg['STATE'] in (2, 3)
6067
azimuth = math.radians(msg['AZIMUTH'])
61-
self.pts[addr].measured = True
6268
self.pts[addr].dRel = math.cos(azimuth) * msg['LONG_DIST']
6369
self.pts[addr].yRel = 0.5 * -math.sin(azimuth) * msg['LONG_DIST']
6470
self.pts[addr].vRel = msg['REL_SPEED']
6571
self.pts[addr].aRel = float('nan')
6672
self.pts[addr].yvRel = float('nan')
67-
68-
else:
73+
elif addr in self.pts:
6974
del self.pts[addr]
7075

7176
ret.points = list(self.pts.values())

opendbc/car/tesla/fingerprints.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
b'TeMYG4_Legacy3Y_0.0.0 (2),Y4P003.02.0',
3535
b'TeMYG4_Legacy3Y_0.0.0 (5),Y4003.03.2',
3636
b'TeMYG4_Legacy3Y_0.0.0 (5),Y4P003.03.2',
37-
b'TeMYG4_Main_0.0.0 (77),Y4003.05.4',
3837
b'TeMYG4_SingleECU_0.0.0 (28),Y4S002.23.0',
3938
b'TeMYG4_SingleECU_0.0.0 (33),Y4S002.26',
4039
],

opendbc/car/toyota/carcontroller.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,25 @@ def update(self, CC, CS, now_nanos):
170170

171171
# *** gas and brake ***
172172

173-
# on entering standstill, send standstill request
174-
if CS.out.standstill and not self.last_standstill and (self.CP.carFingerprint not in NO_STOP_TIMER_CAR):
175-
self.standstill_req = True
176-
if CS.pcm_acc_status != 8:
177-
# pcm entered standstill or it's disabled
178-
self.standstill_req = False
173+
# on entering standstill, send standstill request for older TSS-P cars that aren't designed to stay engaged at a stop
174+
if self.CP.carFingerprint not in NO_STOP_TIMER_CAR:
175+
if CS.out.standstill and not self.last_standstill:
176+
self.standstill_req = True
177+
if CS.pcm_acc_status != 8:
178+
# pcm entered standstill or it's disabled
179+
self.standstill_req = False
180+
181+
else:
182+
# if user engages at a stop with foot on brake, PCM starts in a special cruise standstill mode. on resume press,
183+
# brakes can take a while to ramp up causing a lurch forward. prevent resume press until planner wants to move.
184+
# don't use CC.cruiseControl.resume since it is gated on CS.cruiseState.standstill which goes false for 3s after resume press
185+
# TODO: hybrids do not have this issue and can stay stopped after resume press, whitelist them
186+
should_resume = actuators.accel > 0
187+
if should_resume:
188+
self.standstill_req = False
189+
190+
if not should_resume and CS.out.cruiseState.standstill:
191+
self.standstill_req = True
179192

180193
self.last_standstill = CS.out.standstill
181194

opendbc/dbc/generator/rivian/rivian_mando_front_radar.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,21 @@
4444
BU_: XXX
4545
""")
4646

47-
# note: 0x501/0x502 seem to be special in 0x5XX range
4847
for a in range(0x500, 0x500 + 32):
4948
f.write(f"""
5049
BO_ {a} RADAR_TRACK_{a:x}: 8 RADAR
5150
SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX
5251
SG_ COUNTER : 11|4@0+ (1,0) [0|15] "" XXX
5352
SG_ UNKNOWN_1 : 23|8@0- (1,0) [-128|127] "" XXX
54-
SG_ AZIMUTH : 28|10@0- (0.1,0) [-61.2|62.1] "" XXX
53+
SG_ AZIMUTH : 28|10@0- (0.1,0) [-51.2|51.1] "" XXX
5554
SG_ STATE : 31|3@0+ (1,0) [0|7] "" XXX
5655
SG_ LONG_DIST : 34|11@0+ (0.1,0) [0|204.7] "" XXX
57-
SG_ STATE_2 : 55|1@0+ (1,0) [0|1] "" XXX
58-
SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX
56+
SG_ MODE : 55|2@0+ (1,0) [0|3] "" XXX
57+
SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "m/s" XXX
58+
""")
59+
60+
for a in range(0x500, 0x500 + 32):
61+
f.write(f"""
62+
VAL_ {a} STATE 0 "Empty" 1 "New" 2 "New_updated" 3 "Updated" 4 "Coasting" 7 "New_coasting" ;
63+
VAL_ {a} MODE 0 "None" 1 "SRR" 2 "LRR" 3 "SRR_and_LRR" ;
5964
""")

opendbc/safety/modes/gm.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,12 @@ static safety_config gm_init(uint16_t param) {
198198
static const CanMsg GM_CAM_TX_MSGS[] = {{0x180, 0, 4, .check_relay = true}, // pt bus
199199
{0x1E1, 2, 7, .check_relay = false}, {0x184, 2, 8, .check_relay = true}}; // camera bus
200200

201-
gm_hw = GET_FLAG(param, GM_PARAM_HW_CAM) ? GM_CAM : GM_ASCM;
202-
203-
if (gm_hw == GM_ASCM) {
204-
gm_long_limits = &GM_ASCM_LONG_LIMITS;
205-
} else if (gm_hw == GM_CAM) {
201+
if (GET_FLAG(param, GM_PARAM_HW_CAM)) {
202+
gm_hw = GM_CAM;
206203
gm_long_limits = &GM_CAM_LONG_LIMITS;
207204
} else {
205+
gm_hw = GM_ASCM;
206+
gm_long_limits = &GM_ASCM_LONG_LIMITS;
208207
}
209208

210209
bool gm_cam_long = false;

opendbc/safety/modes/psa.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,7 @@ static uint8_t psa_get_counter(const CANPacket_t *msg) {
2727
}
2828

2929
static uint32_t psa_get_checksum(const CANPacket_t *msg) {
30-
uint8_t chksum = 0;
31-
if (msg->addr == PSA_HS2_DAT_MDD_CMD_452) {
32-
chksum = msg->data[5] & 0xFU;
33-
} else if (msg->addr == PSA_HS2_DYN_ABR_38D) {
34-
chksum = msg->data[5] & 0xFU;
35-
} else {
36-
}
37-
return chksum;
30+
return msg->data[5] & 0xFU;
3831
}
3932

4033
static uint8_t _psa_compute_checksum(const CANPacket_t *msg, uint8_t chk_ini, int chk_pos) {

opendbc/safety/modes/rivian.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,13 @@
33
#include "opendbc/safety/declarations.h"
44

55
static uint8_t rivian_get_counter(const CANPacket_t *msg) {
6-
uint8_t cnt = 0;
7-
if ((msg->addr == 0x208U) || (msg->addr == 0x150U)) {
8-
// Signal: ESP_Status_Counter, VDM_PropStatus_Counter
9-
cnt = msg->data[1] & 0xFU;
10-
}
11-
return cnt;
6+
// Signal: ESP_Status_Counter, VDM_PropStatus_Counter
7+
return msg->data[1] & 0xFU;
128
}
139

1410
static uint32_t rivian_get_checksum(const CANPacket_t *msg) {
15-
uint8_t chksum = 0;
16-
if ((msg->addr == 0x208U) || (msg->addr == 0x150U)) {
17-
// Signal: ESP_Status_Checksum, VDM_PropStatus_Checksum
18-
chksum = msg->data[0];
19-
} else {
20-
}
21-
return chksum;
11+
// Signal: ESP_Status_Checksum, VDM_PropStatus_Checksum
12+
return msg->data[0];
2213
}
2314

2415
static uint8_t _rivian_compute_checksum(const CANPacket_t *msg, uint8_t poly, uint8_t xor_output) {

opendbc/safety/modes/toyota.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,7 @@ static uint32_t toyota_get_checksum(const CANPacket_t *msg) {
7777
}
7878

7979
static bool toyota_get_quality_flag_valid(const CANPacket_t *msg) {
80-
81-
bool valid = false;
82-
if (msg->addr == 0x260U) {
83-
valid = !GET_BIT(msg, 3U); // STEER_ANGLE_INITIALIZING
84-
}
85-
return valid;
80+
return !GET_BIT(msg, 3U); // STEER_ANGLE_INITIALIZING
8681
}
8782

8883
static void toyota_rx_hook(const CANPacket_t *msg) {

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "CAN bus databases and tools"
55
license = { file = "LICENSE" }
66
authors = [{ name = "Vehicle Researcher", email = "user@comma.ai" }]
77
readme = "README.md"
8-
requires-python = ">=3.9,<3.13" # pycapnp doesn't work with 3.13
8+
requires-python = ">=3.11,<3.13" # pycapnp doesn't work with 3.13
99

1010
urls = { "homepage" = "https://github.com/commaai/opendbc" }
1111

0 commit comments

Comments
 (0)