Skip to content

Commit

Permalink
Merge branch 'upstream/openpilot/master' into sync-20240220
Browse files Browse the repository at this point in the history
# Conflicts:
#	cereal
#	common/version.h
#	selfdrive/controls/controlsd.py
#	selfdrive/thermald/power_monitoring.py
  • Loading branch information
sunnyhaibin committed Feb 24, 2024
2 parents bbbca41 + db57a21 commit 8945fff
Show file tree
Hide file tree
Showing 38 changed files with 354 additions and 201 deletions.
6 changes: 5 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Version 0.9.6 (2024-02-22)
Version 0.9.7 (2024-XX-XX)
========================
* New driving model

Version 0.9.6 (2024-02-27)
========================
* New driving model
* Vision model trained on more data
Expand Down
2 changes: 1 addition & 1 deletion cereal
2 changes: 1 addition & 1 deletion common/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define COMMA_VERSION "0.9.6.0"
#define COMMA_VERSION "0.9.6.1"
5 changes: 5 additions & 0 deletions launch_chffrplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function agnos_init {
# set success flag for current boot slot
sudo abctl --set_success

# TODO: do this without udev in AGNOS
# udev does this, but sometimes we startup faster
sudo chgrp gpu /dev/adsprpc-smd /dev/ion /dev/kgsl-3d0
sudo chmod 660 /dev/adsprpc-smd /dev/ion /dev/kgsl-3d0

# Check if AGNOS update is required
if [ $(< /VERSION) != "$AGNOS_VERSION" ]; then
AGNOS_PY="$DIR/system/hardware/tici/agnos.py"
Expand Down
11 changes: 9 additions & 2 deletions selfdrive/athena/athenad.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,17 @@ def retry_upload(tid: int, end_event: threading.Event, increase_count: bool = Tr
break


def cb(sm, item, tid, sz: int, cur: int) -> None:
def cb(sm, item, tid, end_event: threading.Event, sz: int, cur: int) -> None:
# Abort transfer if connection changed to metered after starting upload
# or if athenad is shutting down to re-connect the websocket
sm.update(0)
metered = sm['deviceState'].networkMetered
if metered and (not item.allow_cellular):
raise AbortTransferException

if end_event.is_set():
raise AbortTransferException

cur_upload_items[tid] = replace(item, progress=cur / sz if sz else 1)


Expand Down Expand Up @@ -252,7 +256,7 @@ def upload_handler(end_event: threading.Event) -> None:
sz = -1

cloudlog.event("athena.upload_handler.upload_start", fn=fn, sz=sz, network_type=network_type, metered=metered, retry_count=item.retry_count)
response = _do_upload(item, partial(cb, sm, item, tid))
response = _do_upload(item, partial(cb, sm, item, tid, end_event))

if response.status_code not in (200, 201, 401, 403, 412):
cloudlog.event("athena.upload_handler.retry", status_code=response.status_code, fn=fn, sz=sz, network_type=network_type, metered=metered)
Expand Down Expand Up @@ -746,6 +750,9 @@ def ws_manage(ws: WebSocket, end_event: threading.Event) -> None:
onroad_prev = onroad

if sock is not None:
# While not sending data, onroad, we can expect to time out in 7 + (7 * 2) = 21s
# offroad, we can expect to time out in 30 + (10 * 3) = 60s
# FIXME: TCP_USER_TIMEOUT is effectively 2x for some reason (32s), so it's mostly unused
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, 16000 if onroad else 0)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 7 if onroad else 30)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 7 if onroad else 10)
Expand Down
1 change: 1 addition & 0 deletions selfdrive/athena/tests/test_athenad.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def test_upload_handler(self, host):
time.sleep(0.1)

# TODO: verify that upload actually succeeded
# TODO: also check that end_event and metered network raises AbortTransferException
self.assertEqual(athenad.upload_queue.qsize(), 0)

@parameterized.expand([(500, True), (412, False)])
Expand Down
10 changes: 6 additions & 4 deletions selfdrive/athena/tests/test_athenad_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from openpilot.selfdrive.manager.helpers import write_onroad_params
from openpilot.system.hardware import TICI

TIMEOUT_TOLERANCE = 20 # seconds


def wifi_radio(on: bool) -> None:
if not TICI:
Expand Down Expand Up @@ -55,15 +57,15 @@ def tearDown(self) -> None:
self.exit_event.set()
self.athenad.join()

@mock.patch('openpilot.selfdrive.athena.athenad.create_connection', autospec=True)
@mock.patch('openpilot.selfdrive.athena.athenad.create_connection', new_callable=lambda: mock.MagicMock(wraps=athenad.create_connection))
def assertTimeout(self, reconnect_time: float, mock_create_connection: mock.MagicMock) -> None:
self.athenad.start()

time.sleep(1)
mock_create_connection.assert_called_once()
mock_create_connection.reset_mock()

# check normal behaviour
# check normal behaviour, server pings on connection
with self.subTest("Wi-Fi: receives ping"), Timeout(70, "no ping received"):
while not self._received_ping():
time.sleep(0.1)
Expand Down Expand Up @@ -92,12 +94,12 @@ def assertTimeout(self, reconnect_time: float, mock_create_connection: mock.Magi
@unittest.skipIf(not TICI, "only run on desk")
def test_offroad(self) -> None:
write_onroad_params(False, self.params)
self.assertTimeout(100) # expect approx 90s
self.assertTimeout(60 + TIMEOUT_TOLERANCE) # based using TCP keepalive settings

@unittest.skipIf(not TICI, "only run on desk")
def test_onroad(self) -> None:
write_onroad_params(True, self.params)
self.assertTimeout(30) # expect 20-30s
self.assertTimeout(21 + TIMEOUT_TOLERANCE)


if __name__ == "__main__":
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/boardd/pandad.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def main() -> NoReturn:
cloudlog.event("pandad.flash_and_connect", count=count)
params.remove("PandaSignatures")

# TODO: remove this in the next AGNOS
# wait until USB is up before counting
if time.monotonic() < 25.:
no_internal_panda_count = 0

# Handle missing internal panda
if no_internal_panda_count > 0:
if no_internal_panda_count == 3:
Expand Down
39 changes: 37 additions & 2 deletions selfdrive/car/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# functions common among cars
from collections import namedtuple
from typing import Dict, List, Optional
from dataclasses import dataclass
from enum import ReprEnum
from typing import Dict, List, Optional, Union

import capnp

from cereal import car
from openpilot.common.numpy_fast import clip, interp
from openpilot.selfdrive.car.docs_definitions import CarInfo


# kg of standard extra cargo to count for drive, gas, etc...
Expand Down Expand Up @@ -73,7 +76,9 @@ def scale_tire_stiffness(mass, wheelbase, center_to_front, tire_stiffness_factor
return tire_stiffness_front, tire_stiffness_rear


def dbc_dict(pt_dbc, radar_dbc, chassis_dbc=None, body_dbc=None) -> Dict[str, str]:
DbcDict = Dict[str, str]

def dbc_dict(pt_dbc, radar_dbc, chassis_dbc=None, body_dbc=None) -> DbcDict:
return {'pt': pt_dbc, 'radar': radar_dbc, 'chassis': chassis_dbc, 'body': body_dbc}


Expand Down Expand Up @@ -236,3 +241,33 @@ def update(self, current_value, current_counter):
self.previous_value = current_value

return self.rate


CarInfos = Union[CarInfo, List[CarInfo]]

@dataclass(order=True)
class PlatformConfig:
platform_str: str
car_info: CarInfos
dbc_dict: DbcDict

def __hash__(self) -> int:
return hash(self.platform_str)


class Platforms(str, ReprEnum):
config: PlatformConfig

def __new__(cls, platform_config: PlatformConfig):
member = str.__new__(cls, platform_config.platform_str)
member.config = platform_config
member._value_ = platform_config.platform_str
return member

@classmethod
def create_dbc_map(cls) -> Dict[str, DbcDict]:
return {p.config.platform_str: p.config.dbc_dict for p in cls}

@classmethod
def create_carinfo_map(cls) -> Dict[str, CarInfos]:
return {p.config.platform_str: p.config.car_info for p in cls}
24 changes: 9 additions & 15 deletions selfdrive/car/body/values.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from enum import StrEnum
from typing import Dict

from cereal import car
from openpilot.selfdrive.car import dbc_dict
from openpilot.selfdrive.car import PlatformConfig, Platforms, dbc_dict
from openpilot.selfdrive.car.docs_definitions import CarInfo
from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries

Expand All @@ -22,13 +19,12 @@ def __init__(self, CP):
pass


class CAR(StrEnum):
BODY = "COMMA BODY"


CAR_INFO: Dict[str, CarInfo] = {
CAR.BODY: CarInfo("comma body", package="All"),
}
class CAR(Platforms):
BODY = PlatformConfig(
"COMMA BODY",
CarInfo("comma body", package="All"),
dbc_dict('comma_body', None),
)


FW_QUERY_CONFIG = FwQueryConfig(
Expand All @@ -41,7 +37,5 @@ class CAR(StrEnum):
],
)


DBC = {
CAR.BODY: dbc_dict('comma_body', None),
}
CAR_INFO = CAR.create_carinfo_map()
DBC = CAR.create_dbc_map()
1 change: 1 addition & 0 deletions selfdrive/car/chrysler/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
b'68527383AD',
b'68527387AE',
b'68527403AC',
b'68546047AF',
b'68631938AA',
b'68631942AA',
],
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/car/ford/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ def init_make(self, CP: car.CarParams):
requests=[
# CAN and CAN FD queries are combined.
# FIXME: For CAN FD, ECUs respond with frames larger than 8 bytes on the powertrain bus
Request(
[StdQueries.TESTER_PRESENT_REQUEST, StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST],
[StdQueries.TESTER_PRESENT_RESPONSE, StdQueries.MANUFACTURER_SOFTWARE_VERSION_RESPONSE],
logging=True,
),
Request(
[StdQueries.TESTER_PRESENT_REQUEST, StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST],
[StdQueries.TESTER_PRESENT_RESPONSE, StdQueries.MANUFACTURER_SOFTWARE_VERSION_RESPONSE],
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/car/subaru/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,17 +509,20 @@
(Ecu.fwdCamera, 0x787, None): [
b'\x04!\x01\x1eD\x07!\x00\x04,',
b'\x04!\x08\x01.\x07!\x08\x022',
b'\r!\x08\x017\n!\x08\x003',
],
(Ecu.engine, 0x7e0, None): [
b'\xd5"`0\x07',
b'\xd5"a0\x07',
b'\xf1"`q\x07',
b'\xf1"aq\x07',
b'\xfa"ap\x07',
],
(Ecu.transmission, 0x7e1, None): [
b'\x1d\x86B0\x00',
b'\x1d\xf6B0\x00',
b'\x1e\x86B0\x00',
b'\x1e\x86F0\x00',
b'\x1e\xf6D0\x00',
],
},
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/subaru/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def init_make(self, CP: car.CarParams):
CAR.LEGACY_PREGLOBAL: SubaruCarInfo("Subaru Legacy 2015-18"),
CAR.OUTBACK_PREGLOBAL: SubaruCarInfo("Subaru Outback 2015-17"),
CAR.OUTBACK_PREGLOBAL_2018: SubaruCarInfo("Subaru Outback 2018-19"),
CAR.FORESTER_2022: SubaruCarInfo("Subaru Forester 2022-23", "All", car_parts=CarParts.common([CarHarness.subaru_c])),
CAR.FORESTER_2022: SubaruCarInfo("Subaru Forester 2022-24", "All", car_parts=CarParts.common([CarHarness.subaru_c])),
CAR.OUTBACK_2023: SubaruCarInfo("Subaru Outback 2023", "All", car_parts=CarParts.common([CarHarness.subaru_d])),
CAR.ASCENT_2023: SubaruCarInfo("Subaru Ascent 2023", "All", car_parts=CarParts.common([CarHarness.subaru_d])),
}
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/car/tests/test_fw_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ def fake_get_ecu_addrs(*_, timeout):
print(f'get_vin {name} case, query time={self.total_time / self.N} seconds')

def test_fw_query_timing(self):
total_ref_time = {1: 5.95, 2: 6.85}
total_ref_time = {1: 6.05, 2: 6.95}
brand_ref_times = {
1: {
'gm': 0.5,
'body': 0.1,
'chrysler': 0.3,
'ford': 0.1,
'ford': 0.2,
'honda': 0.55,
'hyundai': 1.05,
'mazda': 0.1,
Expand All @@ -280,7 +280,7 @@ def test_fw_query_timing(self):
'volkswagen': 0.2,
},
2: {
'ford': 0.2,
'ford': 0.3,
'hyundai': 1.85,
}
}
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/car/volkswagen/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@
],
(Ecu.srs, 0x715, None): [
b'\xf1\x873Q0959655AC\xf1\x890200\xf1\x82\r11120011100010022212110200',
b'\xf1\x873Q0959655AK\xf1\x890306\xf1\x82\r31210031210021033733310331',
b'\xf1\x873Q0959655AP\xf1\x890305\xf1\x82\r11110011110011213331312131',
b'\xf1\x873Q0959655AQ\xf1\x890200\xf1\x82\r11120011100010312212113100',
b'\xf1\x873Q0959655AS\xf1\x890200\xf1\x82\r11120011100010022212110200',
Expand All @@ -1062,6 +1063,7 @@
(Ecu.fwdRadar, 0x757, None): [
b'\xf1\x875Q0907572D \xf1\x890304\xf1\x82\x0101',
b'\xf1\x875Q0907572F \xf1\x890400\xf1\x82\x0101',
b'\xf1\x875Q0907572H \xf1\x890620',
b'\xf1\x875Q0907572J \xf1\x890654',
b'\xf1\x875Q0907572K \xf1\x890402\xf1\x82\x0101',
b'\xf1\x875Q0907572P \xf1\x890682',
Expand Down
Loading

0 comments on commit 8945fff

Please sign in to comment.