mirror of https://github.com/commaai/openpilot.git
parent
73e4aa24b9
commit
3358745103
|
@ -7,7 +7,7 @@ from openpilot.system.version import get_version
|
|||
|
||||
API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com')
|
||||
|
||||
class Api():
|
||||
class Api:
|
||||
def __init__(self, dongle_id):
|
||||
self.dongle_id = dongle_id
|
||||
with open(Paths.persist_root()+'/comma/id_rsa') as f:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
from functools import lru_cache
|
||||
from functools import cache
|
||||
|
||||
def gpio_init(pin: int, output: bool) -> None:
|
||||
try:
|
||||
|
@ -35,7 +35,7 @@ def gpio_export(pin: int) -> None:
|
|||
except Exception:
|
||||
print(f"Failed to export gpio {pin}")
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def get_irq_action(irq: int) -> list[str]:
|
||||
try:
|
||||
with open(f"/sys/kernel/irq/{irq}/actions") as f:
|
||||
|
|
|
@ -3,7 +3,7 @@ import subprocess
|
|||
from openpilot.common.basedir import BASEDIR
|
||||
|
||||
|
||||
class Spinner():
|
||||
class Spinner:
|
||||
def __init__(self):
|
||||
try:
|
||||
self.spinner_proc = subprocess.Popen(["./spinner"],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import numpy as np
|
||||
|
||||
class RunningStat():
|
||||
class RunningStat:
|
||||
# tracks realtime mean and standard deviation without storing any data
|
||||
def __init__(self, priors=None, max_trackable=-1):
|
||||
self.max_trackable = max_trackable
|
||||
|
@ -51,7 +51,7 @@ class RunningStat():
|
|||
def params_to_save(self):
|
||||
return [self.M, self.S, self.n]
|
||||
|
||||
class RunningStatFilter():
|
||||
class RunningStatFilter:
|
||||
def __init__(self, raw_priors=None, filtered_priors=None, max_trackable=-1):
|
||||
self.raw_stat = RunningStat(raw_priors, -1)
|
||||
self.filtered_stat = RunningStat(filtered_priors, max_trackable)
|
||||
|
|
|
@ -184,7 +184,7 @@ build-backend = "poetry.core.masonry.api"
|
|||
# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
|
||||
[tool.ruff]
|
||||
indent-width = 2
|
||||
lint.select = ["E", "F", "W", "PIE", "C4", "ISC", "NPY", "RUF008", "RUF100", "A", "B", "TID251"]
|
||||
lint.select = ["E", "F", "W", "PIE", "C4", "ISC", "NPY", "UP", "RUF008", "RUF100", "A", "B", "TID251"]
|
||||
lint.ignore = [
|
||||
"E741",
|
||||
"E402",
|
||||
|
@ -193,6 +193,7 @@ lint.ignore = [
|
|||
"B027",
|
||||
"B024",
|
||||
"NPY002", # new numpy random syntax is worse
|
||||
"UP038", # (x, y) -> x|y for isinstance
|
||||
]
|
||||
line-length = 160
|
||||
target-version="py311"
|
||||
|
|
|
@ -128,7 +128,7 @@ def gen_lat_ocp():
|
|||
return ocp
|
||||
|
||||
|
||||
class LateralMpc():
|
||||
class LateralMpc:
|
||||
def __init__(self, x0=None):
|
||||
if x0 is None:
|
||||
x0 = np.zeros(X_DIM)
|
||||
|
|
|
@ -4,7 +4,7 @@ from numbers import Number
|
|||
from openpilot.common.numpy_fast import clip, interp
|
||||
|
||||
|
||||
class PIDController():
|
||||
class PIDController:
|
||||
def __init__(self, k_p, k_i, k_f=0., k_d=0., pos_limit=1e308, neg_limit=-1e308, rate=100):
|
||||
self._k_p = k_p
|
||||
self._k_i = k_i
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import importlib
|
||||
import math
|
||||
from collections import deque
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
import capnp
|
||||
from cereal import messaging, log, car
|
||||
|
@ -208,7 +208,7 @@ class RadarD:
|
|||
|
||||
self.ready = False
|
||||
|
||||
def update(self, sm: messaging.SubMaster, rr: Optional[car.RadarData]):
|
||||
def update(self, sm: messaging.SubMaster, rr):
|
||||
self.ready = sm.seen['modelV2']
|
||||
self.current_time = 1e-9*max(sm.logMonoTime.values())
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ def run_following_distance_simulation(v_lead, t_end=100.0, e2e=False, personalit
|
|||
log.LongitudinalPersonality.standard,
|
||||
log.LongitudinalPersonality.aggressive],
|
||||
[0,10,35])) # speed
|
||||
class TestFollowingDistance():
|
||||
class TestFollowingDistance:
|
||||
def test_following_distance(self):
|
||||
v_lead = float(self.speed)
|
||||
simulation_steady_state = run_following_distance_simulation(v_lead, e2e=self.e2e, personality=self.personality)
|
||||
|
|
|
@ -139,7 +139,7 @@ if __name__ == "__main__":
|
|||
# so fib a little and say that same tester did the programming
|
||||
current_date = date.today()
|
||||
formatted_date = current_date.strftime('%y-%m-%d')
|
||||
year, month, day = [int(part) for part in formatted_date.split('-')]
|
||||
year, month, day = (int(part) for part in formatted_date.split('-'))
|
||||
prog_date = bytes([year, month, day])
|
||||
uds_client.write_data_by_identifier(DATA_IDENTIFIER_TYPE.PROGRAMMING_DATE, prog_date)
|
||||
tester_num = uds_client.read_data_by_identifier(DATA_IDENTIFIER_TYPE.CALIBRATION_REPAIR_SHOP_CODE_OR_CALIBRATION_EQUIPMENT_SERIAL_NUMBER)
|
||||
|
|
|
@ -28,7 +28,7 @@ def _slice(n):
|
|||
return s
|
||||
|
||||
|
||||
class States():
|
||||
class States:
|
||||
# Vehicle model params
|
||||
STIFFNESS = _slice(1) # [-]
|
||||
STEER_RATIO = _slice(1) # [-]
|
||||
|
|
|
@ -20,7 +20,7 @@ def numpy2eigenstring(arr):
|
|||
return f"(Eigen::VectorXd({len(arr)}) << {arr_str}).finished()"
|
||||
|
||||
|
||||
class States():
|
||||
class States:
|
||||
ECEF_POS = slice(0, 3) # x, y and z in ECEF in meters
|
||||
ECEF_ORIENTATION = slice(3, 7) # quat for pose of phone in ecef
|
||||
ECEF_VELOCITY = slice(7, 10) # ecef velocity in m/s
|
||||
|
@ -39,7 +39,7 @@ class States():
|
|||
ACC_BIAS_ERR = slice(18, 21)
|
||||
|
||||
|
||||
class LiveKalman():
|
||||
class LiveKalman:
|
||||
name = 'live'
|
||||
|
||||
initial_x = np.array([3.88e6, -3.37e6, 3.76e6,
|
||||
|
|
|
@ -206,9 +206,8 @@ def main(demo=False):
|
|||
continue
|
||||
|
||||
if abs(meta_main.timestamp_sof - meta_extra.timestamp_sof) > 10000000:
|
||||
cloudlog.error("frames out of sync! main: {} ({:.5f}), extra: {} ({:.5f})".format(
|
||||
meta_main.frame_id, meta_main.timestamp_sof / 1e9,
|
||||
meta_extra.frame_id, meta_extra.timestamp_sof / 1e9))
|
||||
cloudlog.error(f"frames out of sync! main: {meta_main.frame_id} ({meta_main.timestamp_sof / 1e9:.5f}),\
|
||||
extra: {meta_extra.frame_id} ({meta_extra.timestamp_sof / 1e9:.5f})")
|
||||
|
||||
else:
|
||||
# Use single camera
|
||||
|
|
|
@ -15,7 +15,7 @@ EventName = car.CarEvent.EventName
|
|||
# We recommend that you do not change these numbers from the defaults.
|
||||
# ******************************************************************************************
|
||||
|
||||
class DRIVER_MONITOR_SETTINGS():
|
||||
class DRIVER_MONITOR_SETTINGS:
|
||||
def __init__(self):
|
||||
self._DT_DMON = DT_DMON
|
||||
# ref (page15-16): https://eur-lex.europa.eu/legal-content/EN/TXT/PDF/?uri=CELEX:42018X1947&rid=2
|
||||
|
@ -102,7 +102,7 @@ def face_orientation_from_net(angles_desc, pos_desc, rpy_calib):
|
|||
yaw -= rpy_calib[2]
|
||||
return roll_net, pitch, yaw
|
||||
|
||||
class DriverPose():
|
||||
class DriverPose:
|
||||
def __init__(self, max_trackable):
|
||||
self.yaw = 0.
|
||||
self.pitch = 0.
|
||||
|
@ -116,12 +116,12 @@ class DriverPose():
|
|||
self.cfactor_pitch = 1.
|
||||
self.cfactor_yaw = 1.
|
||||
|
||||
class DriverBlink():
|
||||
class DriverBlink:
|
||||
def __init__(self):
|
||||
self.left_blink = 0.
|
||||
self.right_blink = 0.
|
||||
|
||||
class DriverStatus():
|
||||
class DriverStatus:
|
||||
def __init__(self, rhd_saved=False, settings=None, always_on=False):
|
||||
if settings is None:
|
||||
settings = DRIVER_MONITOR_SETTINGS()
|
||||
|
|
|
@ -4,7 +4,7 @@ import zmq
|
|||
import time
|
||||
from pathlib import Path
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime, UTC
|
||||
from typing import NoReturn
|
||||
|
||||
from openpilot.common.params import Params
|
||||
|
@ -133,7 +133,7 @@ def main() -> NoReturn:
|
|||
# flush when started state changes or after FLUSH_TIME_S
|
||||
if (time.monotonic() > last_flush_time + STATS_FLUSH_TIME_S) or (sm['deviceState'].started != started_prev):
|
||||
result = ""
|
||||
current_time = datetime.utcnow().replace(tzinfo=timezone.utc)
|
||||
current_time = datetime.utcnow().replace(tzinfo=UTC)
|
||||
tags['started'] = sm['deviceState'].started
|
||||
|
||||
for key, value in gauges.items():
|
||||
|
|
|
@ -83,7 +83,7 @@ class Plant:
|
|||
|
||||
lead = log.RadarState.LeadData.new_message()
|
||||
lead.dRel = float(d_rel)
|
||||
lead.yRel = float(0.0)
|
||||
lead.yRel = 0.0
|
||||
lead.vRel = float(v_rel)
|
||||
lead.aRel = float(a_lead - self.acceleration)
|
||||
lead.vLead = float(v_lead)
|
||||
|
|
|
@ -93,7 +93,7 @@ if __name__ == "__main__":
|
|||
|
||||
if pix_hash != ref_hash:
|
||||
print("result changed! please check kernel")
|
||||
print("ref: %s" % ref_hash)
|
||||
print("new: %s" % pix_hash)
|
||||
print(f"ref: {ref_hash}")
|
||||
print(f"new: {pix_hash}")
|
||||
else:
|
||||
print("test passed")
|
||||
|
|
|
@ -8,7 +8,7 @@ class ReplayDone(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class SubSocket():
|
||||
class SubSocket:
|
||||
def __init__(self, msgs, trigger):
|
||||
self.i = 0
|
||||
self.trigger = trigger
|
||||
|
@ -28,7 +28,7 @@ class SubSocket():
|
|||
return msg
|
||||
|
||||
|
||||
class PubSocket():
|
||||
class PubSocket:
|
||||
def send(self, data):
|
||||
pass
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class MockResponse:
|
|||
self.status_code = status_code
|
||||
|
||||
|
||||
class EchoSocket():
|
||||
class EchoSocket:
|
||||
def __init__(self, port):
|
||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.socket.bind(('127.0.0.1', port))
|
||||
|
@ -34,7 +34,7 @@ class EchoSocket():
|
|||
self.socket.close()
|
||||
|
||||
|
||||
class MockApi():
|
||||
class MockApi:
|
||||
def __init__(self, dongle_id):
|
||||
pass
|
||||
|
||||
|
@ -42,7 +42,7 @@ class MockApi():
|
|||
return "fake-token"
|
||||
|
||||
|
||||
class MockWebsocket():
|
||||
class MockWebsocket:
|
||||
sock = socket.socket()
|
||||
|
||||
def __init__(self, recv_queue, send_queue):
|
||||
|
|
|
@ -28,12 +28,12 @@ def create_random_file(file_path: Path, size_mb: float, lock: bool = False, uplo
|
|||
if upload_xattr is not None:
|
||||
setxattr(str(file_path), uploader.UPLOAD_ATTR_NAME, upload_xattr)
|
||||
|
||||
class MockResponse():
|
||||
class MockResponse:
|
||||
def __init__(self, text, status_code):
|
||||
self.text = text
|
||||
self.status_code = status_code
|
||||
|
||||
class MockApi():
|
||||
class MockApi:
|
||||
def __init__(self, dongle_id):
|
||||
pass
|
||||
|
||||
|
@ -43,7 +43,7 @@ class MockApi():
|
|||
def get_token(self):
|
||||
return "fake-token"
|
||||
|
||||
class MockApiIgnore():
|
||||
class MockApiIgnore:
|
||||
def __init__(self, dongle_id):
|
||||
pass
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ def get_assistnow_messages(token: bytes) -> list[bytes]:
|
|||
return msgs
|
||||
|
||||
|
||||
class TTYPigeon():
|
||||
class TTYPigeon:
|
||||
def __init__(self):
|
||||
self.tty = serial.VTIMESerial(UBLOX_TTY, baudrate=9600, timeout=0)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import pathlib
|
||||
import tarfile
|
||||
from typing import IO, Callable
|
||||
from typing import IO
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
def include_default(_) -> bool:
|
||||
|
|
|
@ -27,7 +27,7 @@ def get_version(path: str = BASEDIR) -> str:
|
|||
|
||||
|
||||
def get_release_notes(path: str = BASEDIR) -> str:
|
||||
with open(os.path.join(path, "RELEASES.md"), "r") as f:
|
||||
with open(os.path.join(path, "RELEASES.md")) as f:
|
||||
return f.read().split('\n\n', 1)[0]
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ from parameterized import parameterized_class
|
|||
([], []),
|
||||
])
|
||||
@pytest.mark.asyncio
|
||||
class TestWebrtcdProc():
|
||||
class TestWebrtcdProc:
|
||||
async def assertCompletesWithTimeout(self, awaitable, timeout=1):
|
||||
try:
|
||||
async with asyncio.timeout(timeout):
|
||||
|
|
|
@ -2,7 +2,7 @@ import os
|
|||
import requests
|
||||
API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com')
|
||||
|
||||
class CommaApi():
|
||||
class CommaApi:
|
||||
def __init__(self, token=None):
|
||||
self.session = requests.Session()
|
||||
self.session.headers['User-agent'] = 'OpenpilotTools'
|
||||
|
|
Loading…
Reference in New Issue