mirror of
https://jihulab.com/mr-one/openpilot.git
synced 2026-10-26 20:43:49 +08:00
test: sync common utilities from master-dev #2066 (stage 1c)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from openpilot.common.api.comma_connect import CommaConnectApi
|
||||
from openpilot.common.api.comma_connect import API_HOST as API_HOST, CommaConnectApi
|
||||
|
||||
|
||||
class Api:
|
||||
|
||||
@@ -16,6 +16,10 @@ class CV:
|
||||
DEG_TO_RAD = np.pi / 180.
|
||||
RAD_TO_DEG = 1. / DEG_TO_RAD
|
||||
|
||||
# Length
|
||||
METER_TO_FOOT = 3.28084
|
||||
METER_TO_MILE = 1. / 1609.344
|
||||
|
||||
# Mass
|
||||
LB_TO_KG = 0.453592
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
|
||||
WEBBING_ICCID_PREFIX = "8985235"
|
||||
|
||||
|
||||
class LPAError(RuntimeError):
|
||||
pass
|
||||
@@ -19,7 +21,7 @@ class Profile:
|
||||
|
||||
@property
|
||||
def is_comma(self) -> bool:
|
||||
return self.provider == 'Webbing' and self.iccid.startswith('8985235')
|
||||
return self.provider == 'Webbing' and self.iccid.startswith(WEBBING_ICCID_PREFIX)
|
||||
|
||||
@property
|
||||
def display_name(self) -> str:
|
||||
|
||||
@@ -27,16 +27,6 @@ def gpio_read(pin: int) -> bool | None:
|
||||
|
||||
return val
|
||||
|
||||
def gpio_export(pin: int) -> None:
|
||||
if os.path.isdir(f"/sys/class/gpio/gpio{pin}"):
|
||||
return
|
||||
|
||||
try:
|
||||
with open("/sys/class/gpio/export", 'w') as f:
|
||||
f.write(str(pin))
|
||||
except Exception:
|
||||
print(f"Failed to export gpio {pin}")
|
||||
|
||||
@cache
|
||||
def get_irq_action(irq: int) -> list[str]:
|
||||
try:
|
||||
|
||||
@@ -91,8 +91,13 @@ class Ratekeeper:
|
||||
self.avg_dt.add_value(self._last_monitor_time - prev)
|
||||
|
||||
lagged = False
|
||||
remaining = self._next_frame_time - time.monotonic()
|
||||
self._next_frame_time += self._interval
|
||||
now = time.monotonic()
|
||||
remaining = self._next_frame_time - now
|
||||
if remaining < -self._interval:
|
||||
# more than a frame behind (e.g. a stall): resync instead of running catch-up frames back-to-back
|
||||
self._next_frame_time = now + self._interval
|
||||
else:
|
||||
self._next_frame_time += self._interval
|
||||
if self._print_delay_threshold is not None and remaining < -self._print_delay_threshold:
|
||||
print(f"{self._process_name} lagging by {-remaining * 1000:.2f} ms")
|
||||
lagged = True
|
||||
|
||||
@@ -5,7 +5,6 @@ import contextlib
|
||||
import subprocess
|
||||
import time
|
||||
import functools
|
||||
from subprocess import Popen, PIPE, TimeoutExpired
|
||||
import zstandard as zstd
|
||||
|
||||
LOG_COMPRESSION_LEVEL = 10 # little benefit up to level 15. level ~17 is a small step change
|
||||
@@ -157,20 +156,6 @@ def run_cmd_default(cmd: list[str], default: str = "", cwd=None, env=None) -> st
|
||||
return default
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def managed_proc(cmd: list[str], env: dict[str, str]):
|
||||
proc = Popen(cmd, env=env, stdout=PIPE, stderr=PIPE)
|
||||
try:
|
||||
yield proc
|
||||
finally:
|
||||
if proc.poll() is None:
|
||||
proc.terminate()
|
||||
try:
|
||||
proc.wait(timeout=5)
|
||||
except TimeoutExpired:
|
||||
proc.kill()
|
||||
|
||||
|
||||
def tabulate(tabular_data, headers=(), tablefmt="simple", floatfmt="g", stralign="left", numalign=None):
|
||||
rows = [list(row) for row in tabular_data]
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMMA_VERSION "0.11.2"
|
||||
#define COMMA_VERSION "0.11.3"
|
||||
|
||||
Reference in New Issue
Block a user