From 85d8d0eddd91baabb6bbef59a9d1f8463b70dc90 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Mon, 12 Aug 2024 01:22:52 +0800 Subject: [PATCH 1/9] spinner: fix missing colon in QProgressBar border style (#33258) fix border style --- selfdrive/ui/qt/spinner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/spinner.cc b/selfdrive/ui/qt/spinner.cc index 2404efa668..4bb697d9e8 100644 --- a/selfdrive/ui/qt/spinner.cc +++ b/selfdrive/ui/qt/spinner.cc @@ -83,7 +83,7 @@ Spinner::Spinner(QWidget *parent) : QWidget(parent) { QProgressBar { background-color: #373737; width: 1000px; - border solid white; + border: 1px solid white; border-radius: 10px; } QProgressBar::chunk { From 118932acd3ba74cabcfeebd7993f94e5dcbbcda5 Mon Sep 17 00:00:00 2001 From: Jimmy <9859727+Quantizr@users.noreply.github.com> Date: Sun, 11 Aug 2024 15:10:14 -0700 Subject: [PATCH 2/9] Add testing closet to LogReader source (#33242) * add testing closet to logreader source * check source availability * use internal_source_available --- tools/lib/filereader.py | 6 +++--- tools/lib/logreader.py | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/lib/filereader.py b/tools/lib/filereader.py index 3bfdc75feb..963d7a8cdb 100644 --- a/tools/lib/filereader.py +++ b/tools/lib/filereader.py @@ -7,10 +7,10 @@ from openpilot.tools.lib.url_file import URLFile DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/") -def internal_source_available(): +def internal_source_available(url=DATA_ENDPOINT): try: - hostname = urlparse(DATA_ENDPOINT).hostname - port = urlparse(DATA_ENDPOINT).port or 80 + hostname = urlparse(url).hostname + port = urlparse(url).port or 80 with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as s: s.connect((hostname, port)) return True diff --git a/tools/lib/logreader.py b/tools/lib/logreader.py index 2487cb2825..815bd4b796 100755 --- a/tools/lib/logreader.py +++ b/tools/lib/logreader.py @@ -174,6 +174,12 @@ def comma_car_segments_source(sr: SegmentRange, mode=ReadMode.RLOG) -> LogPaths: return [get_comma_segments_url(sr.route_name, seg) for seg in sr.seg_idxs] +def testing_closet_source(sr: SegmentRange, mode=ReadMode.RLOG) -> LogPaths: + if not internal_source_available('http://testing.comma.life'): + raise InternalUnavailableException + return [f"http://testing.comma.life/download/{sr.route_name.replace('|', '/')}/{seg}/rlog" for seg in sr.seg_idxs] + + def direct_source(file_or_url: str) -> LogPaths: return [file_or_url] @@ -195,7 +201,7 @@ def auto_source(sr: SegmentRange, mode=ReadMode.RLOG) -> LogPaths: if mode == ReadMode.SANITIZED: return comma_car_segments_source(sr, mode) - SOURCES: list[Source] = [internal_source, internal_source_zst, openpilotci_source, comma_api_source, comma_car_segments_source,] + SOURCES: list[Source] = [internal_source, internal_source_zst, openpilotci_source, comma_api_source, comma_car_segments_source, testing_closet_source,] exceptions = {} # for automatic fallback modes, auto_source needs to first check if rlogs exist for any source From 82c2ec7208af2083c2a9f91eef3edf7682bc06e0 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 11 Aug 2024 15:47:27 -0700 Subject: [PATCH 3/9] no more gh discussions --- .github/ISSUE_TEMPLATE/config.yml | 13 +++++-------- tools/cabana/README.md | 2 -- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 45a8af0aaf..9e9f6af61d 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,14 +1,11 @@ blank_issues_enabled: false contact_links: + - name: Join the Discord + url: https://discord.comma.ai + about: The community Discord is for both openpilot development and experience discussion - name: Report model bugs - url: https://github.com/commaai/openpilot/discussions/categories/model-feedback - about: Provide feedback for the driving or driver monitoring models - - name: Discussions - url: https://github.com/commaai/openpilot/discussions - about: For questions and general discussion about openpilot + url: https://discord.com/channels/469524606043160576/1254834193066623017 + about: Feedback for the driving and driver monitoring models goes in the #driving-feedback in Discord - name: Community Wiki url: https://github.com/commaai/openpilot/wiki about: Check out our community wiki - - name: Community Discord - url: https://discord.comma.ai - about: Check out our community discord diff --git a/tools/cabana/README.md b/tools/cabana/README.md index dbbdd8020c..27829979c0 100644 --- a/tools/cabana/README.md +++ b/tools/cabana/README.md @@ -96,5 +96,3 @@ cabana ## Additional Information For more information, see the [openpilot wiki](https://github.com/commaai/openpilot/wiki/Cabana) - -If you encounter any issues or have feature requests, please contribute bug reports or discussions at: [new cabana feedback](https://github.com/commaai/openpilot/discussions/26091) \ No newline at end of file From 2dab8b31f20503b2eaf0d11302da31759d9867e2 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 11 Aug 2024 21:12:46 -0500 Subject: [PATCH 4/9] Fix some car typing (#33256) * ?? * fix these * more typing and some fixes * fix * rm this for now * fix --- selfdrive/car/hyundai/carcontroller.py | 3 ++- selfdrive/car/interfaces.py | 24 +++++++++++++---------- selfdrive/car/mock/carstate.py | 5 ++++- selfdrive/car/subaru/tests/test_subaru.py | 6 ------ 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 0e3a3f0afd..e121faa790 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -4,6 +4,7 @@ from openpilot.selfdrive.car import DT_CTRL, apply_driver_steer_torque_limits, c from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.helpers import clip from openpilot.selfdrive.car.hyundai import hyundaicanfd, hyundaican +from openpilot.selfdrive.car.hyundai.carstate import CarState from openpilot.selfdrive.car.hyundai.hyundaicanfd import CanBus from openpilot.selfdrive.car.hyundai.values import HyundaiFlags, Buttons, CarControllerParams, CANFD_CAR, CAR from openpilot.selfdrive.car.interfaces import CarControllerBase @@ -169,7 +170,7 @@ class CarController(CarControllerBase): self.frame += 1 return new_actuators, can_sends - def create_button_messages(self, CC: car.CarControl, CS: car.CarState, use_clu11: bool): + def create_button_messages(self, CC: car.CarControl, CS: CarState, use_clu11: bool): can_sends = [] if use_clu11: if CC.cruiseControl.cancel: diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index 4e434ec386..4707ade718 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -87,7 +87,7 @@ def get_torque_params(): # generic car and radar interfaces class CarInterfaceBase(ABC): - def __init__(self, CP, CarController, CarState): + def __init__(self, CP: car.CarParams, CarController, CarState): self.CP = CP self.frame = 0 @@ -97,7 +97,7 @@ class CarInterfaceBase(ABC): self.silent_steer_warning = True self.v_ego_cluster_seen = False - self.CS = CarState(CP) + self.CS: CarStateBase = CarState(CP) self.cp = self.CS.get_can_parser(CP) self.cp_cam = self.CS.get_cam_can_parser(CP) self.cp_adas = self.CS.get_adas_can_parser(CP) @@ -116,7 +116,7 @@ class CarInterfaceBase(ABC): return ACCEL_MIN, ACCEL_MAX @classmethod - def get_non_essential_params(cls, candidate: str): + def get_non_essential_params(cls, candidate: str) -> car.CarParams: """ Parameters essential to controlling the car may be incomplete or wrong without FW versions or fingerprints. """ @@ -151,7 +151,7 @@ class CarInterfaceBase(ABC): @staticmethod @abstractmethod def _get_params(ret: car.CarParams, candidate, fingerprint: dict[int, dict[int, int]], - car_fw: list[car.CarParams.CarFw], experimental_long: bool, docs: bool): + car_fw: list[car.CarParams.CarFw], experimental_long: bool, docs: bool) -> car.CarParams: raise NotImplementedError @staticmethod @@ -211,7 +211,7 @@ class CarInterfaceBase(ABC): return ret @staticmethod - def configure_torque_tune(candidate, tune, steering_angle_deadzone_deg=0.0, use_steering_angle=True): + def configure_torque_tune(candidate: str, tune: car.CarParams.LateralTuning, steering_angle_deadzone_deg: float = 0.0, use_steering_angle: bool = True): params = get_torque_params()[candidate] tune.init('torque') @@ -342,10 +342,10 @@ class CarInterfaceBase(ABC): class RadarInterfaceBase(ABC): - def __init__(self, CP): + def __init__(self, CP: car.CarParams): self.CP = CP self.rcp = None - self.pts = {} + self.pts: dict[int, car.RadarData.RadarPoint] = {} self.delay = 0 self.radar_ts = CP.radarTimeStep self.frame = 0 @@ -358,7 +358,7 @@ class RadarInterfaceBase(ABC): class CarStateBase(ABC): - def __init__(self, CP): + def __init__(self, CP: car.CarParams): self.CP = CP self.car_fingerprint = CP.carFingerprint self.out = car.CarState.new_message() @@ -380,6 +380,10 @@ class CarStateBase(ABC): K = get_kalman_gain(DT_CTRL, np.array(A), np.array(C), np.array(Q), R) self.v_ego_kf = KF1D(x0=x0, A=A, C=C[0], K=K) + @abstractmethod + def update(self, *args) -> car.CarState: + pass + def update_speed_kf(self, v_ego_raw): if abs(v_ego_raw - self.v_ego_kf.x[0][0]) > 2.0: # Prevent large accelerations when car starts at non zero speed self.v_ego_kf.set_x([[v_ego_raw], [0.0]]) @@ -462,12 +466,12 @@ class CarStateBase(ABC): class CarControllerBase(ABC): - def __init__(self, dbc_name: str, CP): + def __init__(self, dbc_name: str, CP: car.CarParams): self.CP = CP self.frame = 0 @abstractmethod - def update(self, CC: car.CarControl.Actuators, CS: car.CarState, now_nanos: int) -> tuple[car.CarControl.Actuators, list[CanData]]: + def update(self, CC: car.CarControl, CS: CarStateBase, now_nanos: int) -> tuple[car.CarControl.Actuators, list[CanData]]: pass diff --git a/selfdrive/car/mock/carstate.py b/selfdrive/car/mock/carstate.py index ece908b51c..41a298e24e 100644 --- a/selfdrive/car/mock/carstate.py +++ b/selfdrive/car/mock/carstate.py @@ -1,4 +1,7 @@ +from cereal import car from openpilot.selfdrive.car.interfaces import CarStateBase + class CarState(CarStateBase): - pass + def update(self, *args) -> car.CarState: + pass diff --git a/selfdrive/car/subaru/tests/test_subaru.py b/selfdrive/car/subaru/tests/test_subaru.py index 33040442b6..f81c392679 100644 --- a/selfdrive/car/subaru/tests/test_subaru.py +++ b/selfdrive/car/subaru/tests/test_subaru.py @@ -1,10 +1,5 @@ -from cereal import car from openpilot.selfdrive.car.subaru.fingerprints import FW_VERSIONS -Ecu = car.CarParams.Ecu - -ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} - class TestSubaruFingerprint: def test_fw_version_format(self): @@ -13,4 +8,3 @@ class TestSubaruFingerprint: fw_size = len(fws[0]) for fw in fws: assert len(fw) == fw_size, f"{platform} {ecu}: {len(fw)} {fw_size}" - From d33035872894ec06d0ededafd512132928edf207 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 11 Aug 2024 22:24:43 -0500 Subject: [PATCH 5/9] Revert "spinner: fix missing colon in QProgressBar border style" (#33263) Revert "spinner: fix missing colon in QProgressBar border style (#33258)" This reverts commit 85d8d0eddd91baabb6bbef59a9d1f8463b70dc90. --- selfdrive/ui/qt/spinner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/spinner.cc b/selfdrive/ui/qt/spinner.cc index 4bb697d9e8..2404efa668 100644 --- a/selfdrive/ui/qt/spinner.cc +++ b/selfdrive/ui/qt/spinner.cc @@ -83,7 +83,7 @@ Spinner::Spinner(QWidget *parent) : QWidget(parent) { QProgressBar { background-color: #373737; width: 1000px; - border: 1px solid white; + border solid white; border-radius: 10px; } QProgressBar::chunk { From 093c09a7373868a77d8f9e56f7f26304601855dc Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 11 Aug 2024 22:25:08 -0500 Subject: [PATCH 6/9] move the body events to card (#33262) * move the body events to card * rm import --- selfdrive/car/body/interface.py | 10 +--------- selfdrive/car/card.py | 6 ++++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/selfdrive/car/body/interface.py b/selfdrive/car/body/interface.py index 50564d3ed8..29d55c934b 100644 --- a/selfdrive/car/body/interface.py +++ b/selfdrive/car/body/interface.py @@ -1,6 +1,6 @@ import math from cereal import car -from openpilot.selfdrive.car import DT_CTRL, get_safety_config +from openpilot.selfdrive.car import get_safety_config from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.car.body.values import SPEED_FROM_RPM @@ -27,12 +27,4 @@ class CarInterface(CarInterfaceBase): def _update(self, c): ret = self.CS.update(self.cp) - # wait for everything to init first - if self.frame > int(5. / DT_CTRL): - # body always wants to enable - ret.init('events', 1) - ret.events[0].name = car.CarEvent.EventName.pcmEnable - ret.events[0].enable = True - self.frame += 1 - return ret diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index d091f31042..0f26681a05 100755 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -159,6 +159,12 @@ class Car: self.events.add_from_msg(CS.events) + if self.CP.notCar: + # wait for everything to init first + if self.sm.frame > int(5. / DT_CTRL) and self.initialized_prev: + # body always wants to enable + self.events.add(EventName.pcmEnable) + # Disable on rising edge of accelerator or brake. Also disable on brake when speed > 0 if (CS.gasPressed and not self.CS_prev.gasPressed and self.disengage_on_accelerator) or \ (CS.brakePressed and (not self.CS_prev.brakePressed or not CS.standstill)) or \ From 96a4877e9f731441c253ab35f880b0c84dff22dd Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 11 Aug 2024 21:01:13 -0700 Subject: [PATCH 7/9] Update ui_preview.yaml --- .github/workflows/ui_preview.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ui_preview.yaml b/.github/workflows/ui_preview.yaml index bc19e23778..ebfee0de95 100644 --- a/.github/workflows/ui_preview.yaml +++ b/.github/workflows/ui_preview.yaml @@ -6,6 +6,7 @@ on: - 'master' paths: - 'selfdrive/ui/**' + workflow_dispatch: env: UI_JOB_NAME: "Create UI Report" From 4e122ed2d11785010377e023c979b258e622acb1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 11 Aug 2024 23:54:40 -0500 Subject: [PATCH 8/9] remove map from ui preview (#33265) * rm map from ui preview * fix --- .github/workflows/ui_preview.yaml | 3 +-- selfdrive/ui/tests/test_ui/run.py | 12 +----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ui_preview.yaml b/.github/workflows/ui_preview.yaml index ebfee0de95..c678abb276 100644 --- a/.github/workflows/ui_preview.yaml +++ b/.github/workflows/ui_preview.yaml @@ -79,11 +79,10 @@ jobs: - + - diff --git a/selfdrive/ui/tests/test_ui/run.py b/selfdrive/ui/tests/test_ui/run.py index 0b1d842499..15b97511bc 100644 --- a/selfdrive/ui/tests/test_ui/run.py +++ b/selfdrive/ui/tests/test_ui/run.py @@ -13,7 +13,6 @@ from cereal import messaging, car, log from msgq.visionipc import VisionIpcServer, VisionStreamType from cereal.messaging import SubMaster, PubMaster -from openpilot.common.mock import mock_messages from openpilot.common.params import Params from openpilot.common.realtime import DT_MDL from openpilot.common.transformations.camera import DEVICE_CAMERAS @@ -92,16 +91,8 @@ def setup_onroad(click, pm: PubMaster): pm.send(msg.which(), msg) server.send(cam_meta.stream, IMG_BYTES, cs.frameId, cs.timestampSof, cs.timestampEof) -@mock_messages(['liveLocationKalman']) -def setup_onroad_map(click, pm: PubMaster): - setup_onroad(click, pm) - - click(500, 500) - - time.sleep(UI_DELAY) # give time for the map to render - def setup_onroad_sidebar(click, pm: PubMaster): - setup_onroad_map(click, pm) + setup_onroad(click, pm) click(500, 500) CASES = { @@ -109,7 +100,6 @@ CASES = { "settings_device": setup_settings_device, "settings_network": setup_settings_network, "onroad": setup_onroad, - "onroad_map": setup_onroad_map, "onroad_sidebar": setup_onroad_sidebar } From 7ec998634097f062afe8fb584e34e4c8a1d9fb54 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 12 Aug 2024 01:12:42 -0500 Subject: [PATCH 9/9] carState: add invalid sensors field (#33266) * add to CS * add vehicleSensorsInvalid to CarState * fix ord * clean up --- cereal/car.capnp | 1 + selfdrive/car/ford/carstate.py | 4 +--- selfdrive/car/ford/interface.py | 2 -- selfdrive/car/interfaces.py | 2 ++ selfdrive/car/toyota/carstate.py | 4 ++++ selfdrive/car/toyota/interface.py | 5 ----- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cereal/car.capnp b/cereal/car.capnp index 3df23d9921..cbfb330c22 100644 --- a/cereal/car.capnp +++ b/cereal/car.capnp @@ -196,6 +196,7 @@ struct CarState { accFaulted @42 :Bool; carFaultedNonCritical @47 :Bool; # some ECU is faulted, but car remains controllable espActive @51 :Bool; + vehicleSensorsInvalid @52 :Bool; # invalid steering angle readings, etc. # cruise state cruiseState @10 :CruiseState; diff --git a/selfdrive/car/ford/carstate.py b/selfdrive/car/ford/carstate.py index ed707a5f78..5fe105482e 100644 --- a/selfdrive/car/ford/carstate.py +++ b/selfdrive/car/ford/carstate.py @@ -17,8 +17,6 @@ class CarState(CarStateBase): if CP.transmissionType == TransmissionType.automatic: self.shifter_values = can_define.dv["PowertrainData_10"]["TrnRng_D_Rq"] - self.vehicle_sensors_valid = False - self.prev_distance_button = 0 self.distance_button = 0 @@ -27,7 +25,7 @@ class CarState(CarStateBase): # Occasionally on startup, the ABS module recalibrates the steering pinion offset, so we need to block engagement # The vehicle usually recovers out of this state within a minute of normal driving - self.vehicle_sensors_valid = cp.vl["SteeringPinion_Data"]["StePinCompAnEst_D_Qf"] == 3 + ret.vehicleSensorsInvalid = cp.vl["SteeringPinion_Data"]["StePinCompAnEst_D_Qf"] != 3 # car speed ret.vEgoRaw = cp.vl["BrakeSysFeatures"]["Veh_V_ActlBrk"] * CV.KPH_TO_MS diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index b872be212b..5768d73e4b 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -73,8 +73,6 @@ class CarInterface(CarInterfaceBase): ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}) events = self.create_common_events(ret, extra_gears=[GearShifter.manumatic]) - if not self.CS.vehicle_sensors_valid: - events.add(car.CarEvent.EventName.vehicleSensorsInvalid) ret.events = events.to_msg() diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index 4707ade718..3d4bf543e0 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -300,6 +300,8 @@ class CarInterfaceBase(ABC): events.add(EventName.preEnableStandstill) if cs_out.gasPressed: events.add(EventName.gasPressedOverride) + if cs_out.vehicleSensorsInvalid: + events.add(EventName.vehicleSensorsInvalid) # Handle button presses for b in cs_out.buttonEvents: diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 6037585c90..7c2d0e6ce6 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -112,6 +112,10 @@ class CarState(CarStateBase): ret.steerFaultTemporary = ret.steerFaultTemporary or cp.vl["EPS_STATUS"]["LTA_STATE"] in TEMP_STEER_FAULTS ret.steerFaultPermanent = ret.steerFaultPermanent or cp.vl["EPS_STATUS"]["LTA_STATE"] in PERM_STEER_FAULTS + # Lane Tracing Assist control is unavailable (EPS_STATUS->LTA_STATE=0) until + # the more accurate angle sensor signal is initialized + ret.vehicleSensorsInvalid = not self.accurate_steer_angle_seen + if self.CP.carFingerprint in UNSUPPORTED_DSU_CAR: # TODO: find the bit likely in DSU_CRUISE that describes an ACC fault. one may also exist in CLUTCH ret.cruiseState.available = cp.vl["DSU_CRUISE"]["MAIN_ON"] != 0 diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 5b2a075ce8..5e356bfd49 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -154,11 +154,6 @@ class CarInterface(CarInterfaceBase): # events events = self.create_common_events(ret) - # Lane Tracing Assist control is unavailable (EPS_STATUS->LTA_STATE=0) until - # the more accurate angle sensor signal is initialized - if self.CP.steerControlType == SteerControlType.angle and not self.CS.accurate_steer_angle_seen: - events.add(EventName.vehicleSensorsInvalid) - if self.CP.openpilotLongitudinalControl: if ret.cruiseState.standstill and not ret.brakePressed: events.add(EventName.resumeRequired)