mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-26 16:32:06 +08:00
+1
-1
@@ -52,7 +52,7 @@ def config_realtime_process(cores: Union[int, List[int]], priority: int) -> None
|
||||
|
||||
|
||||
class Ratekeeper:
|
||||
def __init__(self, rate: int, print_delay_threshold: Optional[float] = 0.0) -> None:
|
||||
def __init__(self, rate: float, print_delay_threshold: Optional[float] = 0.0) -> None:
|
||||
"""Rate in Hz for ratekeeping. print_delay_threshold must be nonnegative."""
|
||||
self._interval = 1. / rate
|
||||
self._next_frame_time = sec_since_boot() + self._interval
|
||||
|
||||
@@ -439,7 +439,7 @@ def startLocalProxy(global_end_event, remote_ws_uri, local_port):
|
||||
ssock, csock = socket.socketpair()
|
||||
local_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
local_sock.connect(('127.0.0.1', local_port))
|
||||
local_sock.setblocking(0)
|
||||
local_sock.setblocking(False)
|
||||
|
||||
proxy_end_event = threading.Event()
|
||||
threads = [
|
||||
|
||||
@@ -112,10 +112,10 @@ class CarController:
|
||||
self.apply_brake_last = 0
|
||||
self.last_pump_ts = 0.
|
||||
|
||||
self.accel = 0
|
||||
self.speed = 0
|
||||
self.gas = 0
|
||||
self.brake = 0
|
||||
self.accel = 0.0
|
||||
self.speed = 0.0
|
||||
self.gas = 0.0
|
||||
self.brake = 0.0
|
||||
|
||||
def update(self, CC, CS):
|
||||
actuators = CC.actuators
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import math
|
||||
from numbers import Number
|
||||
from typing import SupportsFloat
|
||||
|
||||
from cereal import car, log
|
||||
from common.numpy_fast import clip
|
||||
@@ -17,6 +17,7 @@ from selfdrive.car.car_helpers import get_car, get_startup_event, get_one_can
|
||||
from selfdrive.controls.lib.lane_planner import CAMERA_OFFSET
|
||||
from selfdrive.controls.lib.drive_helpers import update_v_cruise, initialize_v_cruise
|
||||
from selfdrive.controls.lib.drive_helpers import get_lag_adjusted_curvature
|
||||
from selfdrive.controls.lib.latcontrol import LatControl
|
||||
from selfdrive.controls.lib.longcontrol import LongControl
|
||||
from selfdrive.controls.lib.latcontrol_pid import LatControlPID
|
||||
from selfdrive.controls.lib.latcontrol_indi import LatControlINDI
|
||||
@@ -137,6 +138,7 @@ class Controls:
|
||||
self.LoC = LongControl(self.CP)
|
||||
self.VM = VehicleModel(self.CP)
|
||||
|
||||
self.LaC: LatControl
|
||||
if self.CP.steerControlType == car.CarParams.SteerControlType.angle:
|
||||
self.LaC = LatControlAngle(self.CP, self.CI)
|
||||
elif self.CP.lateralTuning.which() == 'pid':
|
||||
@@ -607,7 +609,7 @@ class Controls:
|
||||
# Ensure no NaNs/Infs
|
||||
for p in ACTUATOR_FIELDS:
|
||||
attr = getattr(actuators, p)
|
||||
if not isinstance(attr, Number):
|
||||
if not isinstance(attr, SupportsFloat):
|
||||
continue
|
||||
|
||||
if not math.isfinite(attr):
|
||||
|
||||
@@ -108,7 +108,7 @@ void localizer_handle_msg_bytes(Localizer_t localizer, const char *data, size_t
|
||||
|
||||
class TestLocationdProc(unittest.TestCase):
|
||||
MAX_WAITS = 1000
|
||||
LLD_MSGS = {'gpsLocationExternal', 'cameraOdometry', 'carState', 'sensorEvents', 'liveCalibration'}
|
||||
LLD_MSGS = ['gpsLocationExternal', 'cameraOdometry', 'carState', 'sensorEvents', 'liveCalibration']
|
||||
|
||||
def setUp(self):
|
||||
random.seed(123489234)
|
||||
|
||||
@@ -69,8 +69,8 @@ class Uploader():
|
||||
self.immediate_count = 0
|
||||
|
||||
# stats for last successfully uploaded file
|
||||
self.last_time = 0
|
||||
self.last_speed = 0
|
||||
self.last_time = 0.0
|
||||
self.last_speed = 0.0
|
||||
self.last_filename = ""
|
||||
|
||||
self.immediate_folders = ["crash/", "boot/"]
|
||||
|
||||
@@ -4,7 +4,7 @@ from common.xattr import getxattr as getattr1
|
||||
from common.xattr import setxattr as setattr1
|
||||
|
||||
cached_attributes: Dict[Tuple, bytes] = {}
|
||||
def getxattr(path: str, attr_name: bytes) -> bytes:
|
||||
def getxattr(path: str, attr_name: str) -> bytes:
|
||||
if (path, attr_name) not in cached_attributes:
|
||||
response = getattr1(path, attr_name)
|
||||
cached_attributes[(path, attr_name)] = response
|
||||
|
||||
@@ -23,9 +23,9 @@ def save_thneed(jdat, fn):
|
||||
if 'data' in o:
|
||||
new_weights.append(o['data'])
|
||||
del o['data']
|
||||
new_weights = b''.join(new_weights)
|
||||
new_weights_bytes = b''.join(new_weights)
|
||||
with open(fn, "wb") as f:
|
||||
j = json.dumps(jdat, ensure_ascii=False).encode('latin_1')
|
||||
f.write(struct.pack("I", len(j)))
|
||||
f.write(j)
|
||||
f.write(new_weights)
|
||||
f.write(new_weights_bytes)
|
||||
|
||||
@@ -61,8 +61,8 @@ def model_replay(lr, frs):
|
||||
|
||||
log_msgs = []
|
||||
last_desire = None
|
||||
recv_cnt = defaultdict(lambda: 0)
|
||||
frame_idxs = defaultdict(lambda: 0)
|
||||
recv_cnt = defaultdict(int)
|
||||
frame_idxs = defaultdict(int)
|
||||
|
||||
# init modeld with valid calibration
|
||||
cal_msgs = [msg for msg in lr if msg.which() == "liveCalibration"]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from typing import Any
|
||||
from typing import Any, Dict
|
||||
|
||||
from selfdrive.car.car_helpers import interface_names
|
||||
from selfdrive.test.openpilotci import get_url, upload_file
|
||||
@@ -94,7 +94,7 @@ def format_diff(results, ref_commit):
|
||||
diff1 += f"\t\t{diff}\n"
|
||||
failed = True
|
||||
elif len(diff):
|
||||
cnt = {}
|
||||
cnt: Dict[str, int] = {}
|
||||
for d in diff:
|
||||
diff2 += f"\t{str(d)}\n"
|
||||
|
||||
|
||||
+2
-2
@@ -46,8 +46,8 @@ class ClientRedirectHandler(BaseHTTPRequestHandler):
|
||||
return
|
||||
|
||||
query = self.path.split('?', 1)[-1]
|
||||
query = parse_qs(query, keep_blank_values=True)
|
||||
self.server.query_params = query
|
||||
query_parsed = parse_qs(query, keep_blank_values=True)
|
||||
self.server.query_params = query_parsed
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/plain')
|
||||
|
||||
@@ -35,7 +35,7 @@ def replay(route, segment, loop):
|
||||
frame_idx = {m.roadEncodeIdx.frameId: m.roadEncodeIdx.segmentId for m in msgs if m.which() == 'roadEncodeIdx' and m.roadEncodeIdx.type == 'fullHEVC'}
|
||||
|
||||
socks = {}
|
||||
lag = 0
|
||||
lag = 0.0
|
||||
i = 0
|
||||
max_i = len(msgs) - 2
|
||||
|
||||
@@ -66,7 +66,7 @@ def replay(route, segment, loop):
|
||||
lag += (next_msg.logMonoTime - msg.logMonoTime) / 1e9
|
||||
lag -= time.time() - start_time
|
||||
|
||||
dt = max(lag, 0)
|
||||
dt = max(lag, 0.0)
|
||||
lag -= dt
|
||||
time.sleep(dt)
|
||||
|
||||
|
||||
+4
-4
@@ -44,8 +44,8 @@ def parse_args(add_args=None):
|
||||
|
||||
class VehicleState:
|
||||
def __init__(self):
|
||||
self.speed = 0
|
||||
self.angle = 0
|
||||
self.speed = 0.0
|
||||
self.angle = 0.0
|
||||
self.bearing_deg = 0.0
|
||||
self.vel = carla.Vector3D()
|
||||
self.cruise_button = 0
|
||||
@@ -111,7 +111,7 @@ class Camerad:
|
||||
rgb_cl = cl_array.to_device(self.queue, rgb)
|
||||
yuv_cl = cl_array.empty_like(rgb_cl)
|
||||
self.krnl(self.queue, (np.int32(self.Wdiv4), np.int32(self.Hdiv4)), None, rgb_cl.data, yuv_cl.data).wait()
|
||||
yuv = np.resize(yuv_cl.get(), np.int32(rgb.size / 2))
|
||||
yuv = np.resize(yuv_cl.get(), rgb.size // 2)
|
||||
eof = int(frame_id * 0.05 * 1e9)
|
||||
|
||||
# TODO: remove RGB send once the last RGB vipc subscriber is removed
|
||||
@@ -397,7 +397,7 @@ class CarlaBridge:
|
||||
|
||||
cruise_button = 0
|
||||
throttle_out = steer_out = brake_out = 0.0
|
||||
throttle_op = steer_op = brake_op = 0
|
||||
throttle_op = steer_op = brake_op = 0.0
|
||||
throttle_manual = steer_manual = brake_manual = 0.0
|
||||
|
||||
# --------------Step 1-------------------------------
|
||||
|
||||
Reference in New Issue
Block a user