openpilot0/selfdrive/controls/controlsd.py

869 lines
37 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
import os
import math
import time
import threading
from typing import SupportsFloat
import cereal.messaging as messaging
from cereal import car, log
from cereal.visionipc import VisionIpcClient, VisionStreamType
from openpilot.common.conversions import Conversions as CV
from openpilot.common.git import get_short_branch
from openpilot.common.numpy_fast import clip
from openpilot.common.params import Params
from openpilot.common.realtime import config_realtime_process, Priority, Ratekeeper, DT_CTRL
from openpilot.common.swaglog import cloudlog
from openpilot.selfdrive.car.car_helpers import get_startup_event
from openpilot.selfdrive.car.card import CarD
from openpilot.selfdrive.controls.lib.alertmanager import AlertManager, set_offroad_alert
from openpilot.selfdrive.controls.lib.drive_helpers import VCruiseHelper, clip_curvature
from openpilot.selfdrive.controls.lib.events import Events, ET
from openpilot.selfdrive.controls.lib.latcontrol import LatControl, MIN_LATERAL_CONTROL_SPEED
from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID
from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle, STEER_ANGLE_SATURATION_THRESHOLD
from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque
from openpilot.selfdrive.controls.lib.longcontrol import LongControl
from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel
from openpilot.system.hardware import HARDWARE
SOFT_DISABLE_TIME = 3 # seconds
LDW_MIN_SPEED = 31 * CV.MPH_TO_MS
LANE_DEPARTURE_THRESHOLD = 0.1
CAMERA_OFFSET = 0.04
REPLAY = "REPLAY" in os.environ
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
2020-09-10 18:14:49 +08:00
SIMULATION = "SIMULATION" in os.environ
TESTING_CLOSET = "TESTING_CLOSET" in os.environ
IGNORE_PROCESSES = {"loggerd", "encoderd", "statsd"}
ThermalStatus = log.DeviceState.ThermalStatus
State = log.ControlsState.OpenpilotState
PandaType = log.PandaState.PandaType
Desire = log.Desire
LaneChangeState = log.LaneChangeState
LaneChangeDirection = log.LaneChangeDirection
EventName = car.CarEvent.EventName
ButtonType = car.CarState.ButtonEvent.Type
SafetyModel = car.CarParams.SafetyModel
IGNORED_SAFETY_MODES = (SafetyModel.silent, SafetyModel.noOutput)
CSID_MAP = {"1": EventName.roadCameraError, "2": EventName.wideRoadCameraError, "0": EventName.driverCameraError}
ACTUATOR_FIELDS = tuple(car.CarControl.Actuators.schema.fields.keys())
ACTIVE_STATES = (State.enabled, State.softDisabling, State.overriding)
ENABLED_STATES = (State.preEnabled, *ACTIVE_STATES)
class Controls:
def __init__(self, CI=None):
self.card = CarD(CI)
self.params = Params()
with car.CarParams.from_bytes(self.params.get("CarParams", block=True)) as msg:
# TODO: this shouldn't need to be a builder
self.CP = msg.as_builder()
self.CI = self.card.CI
# Ensure the current branch is cached, otherwise the first iteration of controlsd lags
self.branch = get_short_branch()
# Setup sockets
self.pm = messaging.PubMaster(['controlsState', 'carControl', 'onroadEvents'])
self.sensor_packets = ["accelerometer", "gyroscope"]
self.camera_packets = ["roadCameraState", "driverCameraState", "wideRoadCameraState"]
self.log_sock = messaging.sub_sock('androidLog')
ignore = self.sensor_packets + ['testJoystick']
if SIMULATION:
ignore += ['driverCameraState', 'managerState']
self.sm = messaging.SubMaster(['deviceState', 'pandaStates', 'peripheralState', 'modelV2', 'liveCalibration',
'carOutput', 'driverMonitoringState', 'longitudinalPlan', 'liveLocationKalman',
'managerState', 'liveParameters', 'radarState', 'liveTorqueParameters',
'testJoystick'] + self.camera_packets + self.sensor_packets,
ignore_alive=ignore, ignore_avg_freq=ignore+['radarState', 'testJoystick'], ignore_valid=['testJoystick', ],
frequency=int(1/DT_CTRL))
self.joystick_mode = self.params.get_bool("JoystickDebugMode")
# read params
self.disengage_on_accelerator = self.params.get_bool("DisengageOnAccelerator")
self.is_metric = self.params.get_bool("IsMetric")
self.is_ldw_enabled = self.params.get_bool("IsLdwEnabled")
# detect sound card presence and ensure successful init
sounds_available = HARDWARE.get_sound_card_online()
car_recognized = self.CP.carName != 'mock'
# cleanup old params
if not self.CP.experimentalLongitudinalAvailable:
self.params.remove("ExperimentalLongitudinalEnabled")
if not self.CP.openpilotLongitudinalControl:
self.params.remove("ExperimentalMode")
self.CC = car.CarControl.new_message()
self.CS_prev = car.CarState.new_message()
self.AM = AlertManager()
self.events = Events()
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':
self.LaC = LatControlPID(self.CP, self.CI)
elif self.CP.lateralTuning.which() == 'torque':
self.LaC = LatControlTorque(self.CP, self.CI)
self.initialized = False
self.state = State.disabled
self.enabled = False
self.active = False
self.soft_disable_timer = 0
self.mismatch_counter = 0
self.cruise_mismatch_counter = 0
self.last_blinker_frame = 0
self.last_steering_pressed_frame = 0
self.distance_traveled = 0
self.last_functional_fan_frame = 0
self.events_prev = []
self.current_alert_types = [ET.PERMANENT]
self.logged_comm_issue = None
self.not_running_prev = None
self.steer_limited = False
self.last_actuators = car.CarControl.Actuators.new_message()
self.desired_curvature = 0.0
self.experimental_mode = False
Move personality to controlsState (#31855) * start at param * start by sending personality * change to personality * POC: button changes personality * what's wrong with this? * fix * not really possible but fuzzy test catches this * there's always a typo * dang, we're dropping messages * clean up * no comment * bump * rename * not all cars yet * works but at what cost * clean up * inside settings * write param so we save the distance button changes * setChecked activates buttonToggled and already writes param! * don't need this, we update from longitudinalPlan on changes * some clean up * more * ui * allow some time for ui to receive and write param * plannerd: only track changes in case no ui * Revert "plannerd: only track changes in case no ui" This reverts commit 2b081aa6ceb92c67a621b74592b2292756d29871. * write in plannerd as well, I assume this is atomic? * don't write when setting checked (only user clicks) * better nane * more * Update selfdrive/controls/lib/longitudinal_planner.py Co-authored-by: Cameron Clough <cameronjclough@gmail.com> * doesn't write param now * ParamWatcher is nice * no debug * Update translations * fix * odd drain sock proc replay behavior * vanish * Revert "odd drain sock proc replay behavior" This reverts commit 29b70b39413e1852bb512155af6b6a94a5bd9454. * add GM * only if OP long * move personality to controlsState, since eventually it won't be exclusive to long planner more bump * diff without translations * fix * put nonblocking * CS should start at up to date personality always (no ui flicker) * update toggle on cereal message change * fix * fix that * ubmp * mypy doesn't know this is an int :( * update translations * fix the tests * revert ui * not here * migrate controlsState * Revert "migrate controlsState" - i see no reason we need to test with any specific personality This reverts commit 6063508f2df1a5623f113cda34dcd59a1f4b2ac9. * Update ref_commit --------- Co-authored-by: Cameron Clough <cameronjclough@gmail.com> old-commit-hash: 29e55f99a54d95215aa79ecf94a22363f82913a6
2024-03-13 15:57:57 +08:00
self.personality = self.read_personality_param()
self.v_cruise_helper = VCruiseHelper(self.CP)
self.recalibrating_seen = False
self.can_log_mono_time = 0
self.startup_event = get_startup_event(car_recognized, not self.CP.passive, len(self.CP.carFw) > 0)
if not sounds_available:
self.events.add(EventName.soundsUnavailable, static=True)
if not car_recognized:
self.events.add(EventName.carUnrecognized, static=True)
if len(self.CP.carFw) > 0:
set_offroad_alert("Offroad_CarUnrecognized", True)
else:
set_offroad_alert("Offroad_NoFirmware", True)
elif self.CP.passive:
self.events.add(EventName.dashcamMode, static=True)
# controlsd is driven by can recv, expected at 100Hz
self.rk = Ratekeeper(100, print_delay_threshold=None)
def set_initial_state(self):
if REPLAY:
controls_state = Params().get("ReplayControlsState")
if controls_state is not None:
with log.ControlsState.from_bytes(controls_state) as controls_state:
self.v_cruise_helper.v_cruise_kph = controls_state.vCruise
if any(ps.controlsAllowed for ps in self.sm['pandaStates']):
self.state = State.enabled
def update_events(self, CS):
"""Compute onroadEvents from carState"""
self.events.clear()
# Add joystick event, static on cars, dynamic on nonCars
if self.joystick_mode:
self.events.add(EventName.joystickDebug)
self.startup_event = None
# Add startup event
if self.startup_event is not None:
self.events.add(self.startup_event)
self.startup_event = None
# Don't add any more events if not initialized
if not self.initialized:
self.events.add(EventName.controlsInitializing)
return
# no more events while in dashcam mode
if self.CP.passive:
return
# Block resume if cruise never previously enabled
resume_pressed = any(be.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for be in CS.buttonEvents)
if not self.CP.pcmCruise and not self.v_cruise_helper.v_cruise_initialized and resume_pressed:
self.events.add(EventName.resumeBlocked)
Add Disengage on Accelerator Toggle (#23977) * Squashed commit of the following: commit 953bcf0ecf8d03f0fec9ce0d5442cc660ae2347d Merge: b4198608d efd04715e Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:58:06 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit b4198608dac9595bfeb9443f95cd6c5d385cd62d Merge: 24f90b2c8 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 14:32:54 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 24f90b2c8d6ae509c0776b6e33b743467aa08dee Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 14:07:52 2022 -0700 revert changes and get ready for override commit aa514df6b5e8431f0faa07f6b25eb5cb6c9f2749 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 20:52:24 2022 -0700 temporary commit c874e10c2555968c683f629c4582ab22e51d431f Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:30:13 2022 -0700 move gasPressed to controlsd commit fe670439dff5bc6dfc5963d79ca2febe0c5920c7 Merge: 49d3b6d11 c78701e47 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:15:48 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 49d3b6d1162893fa94b2294152f0718eeb4698ed Merge: 475b27e74 3e819bc5a Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 13:06:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 475b27e74fd6479f1d148e9ded1eca6ee476865c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 20:24:59 2022 -0700 update SAFETY.md commit 0798eadb82749e12ecbaa86f4e57b21bd3dbc7e8 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 17:52:06 2022 -0700 ⛽ ➡️ 🔋 bump commit d2b64b89cf8d7265bc90848b4e3a2276c9a4cb78 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 16:19:34 2022 -0700 these changes will be in border PR these changes will be border PR commit bed31e63de2244c161729773978fef8a9246ddb5 Merge: 491417640 603e07793 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 16:17:31 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 49141764098e3a701ff123ead52de4656b31db4d Merge: 9291e9f00 46ed8bb8e Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 19:00:26 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 9291e9f0045780669b2ffa7f08fb10373c03b070 Merge: 2aed64157 2c947f193 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Mar 18 19:03:13 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 2aed64157d6e9dc993d103a2c6abf7e643410562 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Mar 18 19:03:03 2022 -0700 Revert "send pre-enable state when gas is pressed" This reverts commit 8d82e697dc2efade307413e767d14b56b4d2d079. commit a219defe5342efa731a957b2ff4fd86292c1f239 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 17 12:50:46 2022 -0700 bump cereal commit 8d82e697dc2efade307413e767d14b56b4d2d079 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 16 22:40:13 2022 -0700 send pre-enable state when gas is pressed formatting and it's out forgot one allow gas press show toggle revert changes revert changes commit 5eb4d1ab1b77ac65bdd901f692ebfb848d5187ca Merge: bad1bdc74 d0ef25959 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 16 22:29:43 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit bad1bdc7428c5d8a4a765b259da504f0ade84424 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 23:03:56 2022 -0700 clean up a bit commit 7516ed9b786536a07f00a92b9c1742ca252a01d1 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:55:09 2022 -0700 these are null checks right now commit 408f5f1d633521b29b08d966c9b387fa79dff0d6 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:51:14 2022 -0700 should work commit be1978e29c03d8843cf073cc9ddf84020fd2b378 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:36:16 2022 -0700 stash commit f0bd4c47e9d27061c6cd3b88765a7c10995f42db Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:26:24 2022 -0700 this was flipped commit d5b6e30389a727e8559331acd706422e1b246f60 Merge: 820b19894 c814c1383 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:25:49 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 820b1989496225df1f66f39b477f1e9402db1b19 Merge: 91763f9ff 6d2483ff9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 14 23:39:34 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 91763f9ff4321986babce1a7b1272fcf64c8f753 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Feb 24 20:15:26 2022 -0800 add icon from jozef 🔥 commit 1885c9e2bacd9351c7e421b1436dcbfbde238436 Merge: 1f591736a eae207a84 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Feb 24 20:08:07 2022 -0800 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 1f591736a2767b1ed892c29ec5000cc7348f01c7 Merge: 465811f0b ebf5b27a7 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Sat Feb 12 10:24:29 2022 -0500 Merge branch 'master' into disengage-on-gas commit 465811f0b4776e43a289398e4d4369362b7da58c Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 11:20:32 2022 -0500 Add param to process replay commit 0344363a533505435cff87eb33356b2364a4156f Merge: 700efcb3f 1175355b7 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Fri Feb 11 11:07:31 2022 -0500 Merge branch 'master' into disengage-on-gas commit 700efcb3f444092f99ef10e9908f83402429d742 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 11:04:39 2022 -0500 Add param to unsafeMode commit 220ce272fee1f7f5ace2a04052605a6e4f95712b Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:54:16 2022 -0500 Add param to unsafeMode commit d273bb78acbc23ee5255e461fa71b2f0400a5e03 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:52:22 2022 -0500 Resolve conflicts commit 1a85afd60c2f0d3140dfa8e7cd574d6b88abd5e3 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:51:50 2022 -0500 Resolve conflicts commit e3be32afc2bb2423d29e2b4f85b3cff3fe72aab9 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:51:08 2022 -0500 Resolve conflicts commit f27203af3afe612173bf9a63e15c57118598b5b8 Author: Jason Wen <haibin.wen3@gmail.com> Date: Wed Jan 19 00:30:09 2022 -0500 Add param to process replay commit 04c0ad1a54f4fea5efe74b3203d9bdbd693b64a6 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Wed Jan 19 00:28:49 2022 -0500 Update interfaces.py Co-authored-by: Willem Melching <willem.melching@gmail.com> commit 99cf13caeb4d9f2c95c25e1e78b6e353ea508cb6 Author: Jason Wen <haibin.wen3@gmail.com> Date: Sat Jan 15 00:03:38 2022 -0500 Fix missing params lib commit 2230254ca709625d591b0c73d1a6022c450f6ef6 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Jan 14 23:38:46 2022 -0500 Disengage on gas toggle commit 87475e02cb63cc39c9b16edc67f303e02d17e6ef Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Jan 14 23:24:00 2022 -0500 Disengage on gas toggle * bump * use ALTERNATIVE_EXPERIENCE * or it * de-bump * update refs * update refs! * you can just ctrl+click ALTERNATIVE_EXPERIENCE! * already have a params * update text old-commit-hash: f1f40c117a65294e27f93f953a772c43078bdceb
2022-04-05 12:59:52 +08:00
# 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 \
(CS.regenBraking and (not self.CS_prev.regenBraking or not CS.standstill)):
self.events.add(EventName.pedalPressed)
if CS.brakePressed and CS.standstill:
self.events.add(EventName.preEnableStandstill)
Add Disengage on Accelerator Toggle (#23977) * Squashed commit of the following: commit 953bcf0ecf8d03f0fec9ce0d5442cc660ae2347d Merge: b4198608d efd04715e Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:58:06 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit b4198608dac9595bfeb9443f95cd6c5d385cd62d Merge: 24f90b2c8 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 14:32:54 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 24f90b2c8d6ae509c0776b6e33b743467aa08dee Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 14:07:52 2022 -0700 revert changes and get ready for override commit aa514df6b5e8431f0faa07f6b25eb5cb6c9f2749 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 20:52:24 2022 -0700 temporary commit c874e10c2555968c683f629c4582ab22e51d431f Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:30:13 2022 -0700 move gasPressed to controlsd commit fe670439dff5bc6dfc5963d79ca2febe0c5920c7 Merge: 49d3b6d11 c78701e47 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:15:48 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 49d3b6d1162893fa94b2294152f0718eeb4698ed Merge: 475b27e74 3e819bc5a Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 13:06:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 475b27e74fd6479f1d148e9ded1eca6ee476865c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 20:24:59 2022 -0700 update SAFETY.md commit 0798eadb82749e12ecbaa86f4e57b21bd3dbc7e8 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 17:52:06 2022 -0700 ⛽ ➡️ 🔋 bump commit d2b64b89cf8d7265bc90848b4e3a2276c9a4cb78 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 16:19:34 2022 -0700 these changes will be in border PR these changes will be border PR commit bed31e63de2244c161729773978fef8a9246ddb5 Merge: 491417640 603e07793 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 16:17:31 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 49141764098e3a701ff123ead52de4656b31db4d Merge: 9291e9f00 46ed8bb8e Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 19:00:26 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 9291e9f0045780669b2ffa7f08fb10373c03b070 Merge: 2aed64157 2c947f193 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Mar 18 19:03:13 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 2aed64157d6e9dc993d103a2c6abf7e643410562 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Mar 18 19:03:03 2022 -0700 Revert "send pre-enable state when gas is pressed" This reverts commit 8d82e697dc2efade307413e767d14b56b4d2d079. commit a219defe5342efa731a957b2ff4fd86292c1f239 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 17 12:50:46 2022 -0700 bump cereal commit 8d82e697dc2efade307413e767d14b56b4d2d079 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 16 22:40:13 2022 -0700 send pre-enable state when gas is pressed formatting and it's out forgot one allow gas press show toggle revert changes revert changes commit 5eb4d1ab1b77ac65bdd901f692ebfb848d5187ca Merge: bad1bdc74 d0ef25959 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 16 22:29:43 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit bad1bdc7428c5d8a4a765b259da504f0ade84424 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 23:03:56 2022 -0700 clean up a bit commit 7516ed9b786536a07f00a92b9c1742ca252a01d1 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:55:09 2022 -0700 these are null checks right now commit 408f5f1d633521b29b08d966c9b387fa79dff0d6 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:51:14 2022 -0700 should work commit be1978e29c03d8843cf073cc9ddf84020fd2b378 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:36:16 2022 -0700 stash commit f0bd4c47e9d27061c6cd3b88765a7c10995f42db Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:26:24 2022 -0700 this was flipped commit d5b6e30389a727e8559331acd706422e1b246f60 Merge: 820b19894 c814c1383 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:25:49 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 820b1989496225df1f66f39b477f1e9402db1b19 Merge: 91763f9ff 6d2483ff9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 14 23:39:34 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 91763f9ff4321986babce1a7b1272fcf64c8f753 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Feb 24 20:15:26 2022 -0800 add icon from jozef 🔥 commit 1885c9e2bacd9351c7e421b1436dcbfbde238436 Merge: 1f591736a eae207a84 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Feb 24 20:08:07 2022 -0800 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 1f591736a2767b1ed892c29ec5000cc7348f01c7 Merge: 465811f0b ebf5b27a7 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Sat Feb 12 10:24:29 2022 -0500 Merge branch 'master' into disengage-on-gas commit 465811f0b4776e43a289398e4d4369362b7da58c Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 11:20:32 2022 -0500 Add param to process replay commit 0344363a533505435cff87eb33356b2364a4156f Merge: 700efcb3f 1175355b7 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Fri Feb 11 11:07:31 2022 -0500 Merge branch 'master' into disengage-on-gas commit 700efcb3f444092f99ef10e9908f83402429d742 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 11:04:39 2022 -0500 Add param to unsafeMode commit 220ce272fee1f7f5ace2a04052605a6e4f95712b Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:54:16 2022 -0500 Add param to unsafeMode commit d273bb78acbc23ee5255e461fa71b2f0400a5e03 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:52:22 2022 -0500 Resolve conflicts commit 1a85afd60c2f0d3140dfa8e7cd574d6b88abd5e3 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:51:50 2022 -0500 Resolve conflicts commit e3be32afc2bb2423d29e2b4f85b3cff3fe72aab9 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:51:08 2022 -0500 Resolve conflicts commit f27203af3afe612173bf9a63e15c57118598b5b8 Author: Jason Wen <haibin.wen3@gmail.com> Date: Wed Jan 19 00:30:09 2022 -0500 Add param to process replay commit 04c0ad1a54f4fea5efe74b3203d9bdbd693b64a6 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Wed Jan 19 00:28:49 2022 -0500 Update interfaces.py Co-authored-by: Willem Melching <willem.melching@gmail.com> commit 99cf13caeb4d9f2c95c25e1e78b6e353ea508cb6 Author: Jason Wen <haibin.wen3@gmail.com> Date: Sat Jan 15 00:03:38 2022 -0500 Fix missing params lib commit 2230254ca709625d591b0c73d1a6022c450f6ef6 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Jan 14 23:38:46 2022 -0500 Disengage on gas toggle commit 87475e02cb63cc39c9b16edc67f303e02d17e6ef Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Jan 14 23:24:00 2022 -0500 Disengage on gas toggle * bump * use ALTERNATIVE_EXPERIENCE * or it * de-bump * update refs * update refs! * you can just ctrl+click ALTERNATIVE_EXPERIENCE! * already have a params * update text old-commit-hash: f1f40c117a65294e27f93f953a772c43078bdceb
2022-04-05 12:59:52 +08:00
if CS.gasPressed:
self.events.add(EventName.gasPressedOverride)
Add Disengage on Accelerator Toggle (#23977) * Squashed commit of the following: commit 953bcf0ecf8d03f0fec9ce0d5442cc660ae2347d Merge: b4198608d efd04715e Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:58:06 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit b4198608dac9595bfeb9443f95cd6c5d385cd62d Merge: 24f90b2c8 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 14:32:54 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 24f90b2c8d6ae509c0776b6e33b743467aa08dee Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 14:07:52 2022 -0700 revert changes and get ready for override commit aa514df6b5e8431f0faa07f6b25eb5cb6c9f2749 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 20:52:24 2022 -0700 temporary commit c874e10c2555968c683f629c4582ab22e51d431f Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:30:13 2022 -0700 move gasPressed to controlsd commit fe670439dff5bc6dfc5963d79ca2febe0c5920c7 Merge: 49d3b6d11 c78701e47 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:15:48 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 49d3b6d1162893fa94b2294152f0718eeb4698ed Merge: 475b27e74 3e819bc5a Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 13:06:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 475b27e74fd6479f1d148e9ded1eca6ee476865c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 20:24:59 2022 -0700 update SAFETY.md commit 0798eadb82749e12ecbaa86f4e57b21bd3dbc7e8 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 17:52:06 2022 -0700 ⛽ ➡️ 🔋 bump commit d2b64b89cf8d7265bc90848b4e3a2276c9a4cb78 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 16:19:34 2022 -0700 these changes will be in border PR these changes will be border PR commit bed31e63de2244c161729773978fef8a9246ddb5 Merge: 491417640 603e07793 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 16:17:31 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 49141764098e3a701ff123ead52de4656b31db4d Merge: 9291e9f00 46ed8bb8e Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 19:00:26 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 9291e9f0045780669b2ffa7f08fb10373c03b070 Merge: 2aed64157 2c947f193 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Mar 18 19:03:13 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 2aed64157d6e9dc993d103a2c6abf7e643410562 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Mar 18 19:03:03 2022 -0700 Revert "send pre-enable state when gas is pressed" This reverts commit 8d82e697dc2efade307413e767d14b56b4d2d079. commit a219defe5342efa731a957b2ff4fd86292c1f239 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 17 12:50:46 2022 -0700 bump cereal commit 8d82e697dc2efade307413e767d14b56b4d2d079 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 16 22:40:13 2022 -0700 send pre-enable state when gas is pressed formatting and it's out forgot one allow gas press show toggle revert changes revert changes commit 5eb4d1ab1b77ac65bdd901f692ebfb848d5187ca Merge: bad1bdc74 d0ef25959 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 16 22:29:43 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit bad1bdc7428c5d8a4a765b259da504f0ade84424 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 23:03:56 2022 -0700 clean up a bit commit 7516ed9b786536a07f00a92b9c1742ca252a01d1 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:55:09 2022 -0700 these are null checks right now commit 408f5f1d633521b29b08d966c9b387fa79dff0d6 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:51:14 2022 -0700 should work commit be1978e29c03d8843cf073cc9ddf84020fd2b378 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:36:16 2022 -0700 stash commit f0bd4c47e9d27061c6cd3b88765a7c10995f42db Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:26:24 2022 -0700 this was flipped commit d5b6e30389a727e8559331acd706422e1b246f60 Merge: 820b19894 c814c1383 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 15 22:25:49 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 820b1989496225df1f66f39b477f1e9402db1b19 Merge: 91763f9ff 6d2483ff9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 14 23:39:34 2022 -0700 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 91763f9ff4321986babce1a7b1272fcf64c8f753 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Feb 24 20:15:26 2022 -0800 add icon from jozef 🔥 commit 1885c9e2bacd9351c7e421b1436dcbfbde238436 Merge: 1f591736a eae207a84 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Feb 24 20:08:07 2022 -0800 Merge remote-tracking branch 'upstream/master' into disengage-on-gas commit 1f591736a2767b1ed892c29ec5000cc7348f01c7 Merge: 465811f0b ebf5b27a7 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Sat Feb 12 10:24:29 2022 -0500 Merge branch 'master' into disengage-on-gas commit 465811f0b4776e43a289398e4d4369362b7da58c Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 11:20:32 2022 -0500 Add param to process replay commit 0344363a533505435cff87eb33356b2364a4156f Merge: 700efcb3f 1175355b7 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Fri Feb 11 11:07:31 2022 -0500 Merge branch 'master' into disengage-on-gas commit 700efcb3f444092f99ef10e9908f83402429d742 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 11:04:39 2022 -0500 Add param to unsafeMode commit 220ce272fee1f7f5ace2a04052605a6e4f95712b Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:54:16 2022 -0500 Add param to unsafeMode commit d273bb78acbc23ee5255e461fa71b2f0400a5e03 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:52:22 2022 -0500 Resolve conflicts commit 1a85afd60c2f0d3140dfa8e7cd574d6b88abd5e3 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:51:50 2022 -0500 Resolve conflicts commit e3be32afc2bb2423d29e2b4f85b3cff3fe72aab9 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Feb 11 10:51:08 2022 -0500 Resolve conflicts commit f27203af3afe612173bf9a63e15c57118598b5b8 Author: Jason Wen <haibin.wen3@gmail.com> Date: Wed Jan 19 00:30:09 2022 -0500 Add param to process replay commit 04c0ad1a54f4fea5efe74b3203d9bdbd693b64a6 Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Wed Jan 19 00:28:49 2022 -0500 Update interfaces.py Co-authored-by: Willem Melching <willem.melching@gmail.com> commit 99cf13caeb4d9f2c95c25e1e78b6e353ea508cb6 Author: Jason Wen <haibin.wen3@gmail.com> Date: Sat Jan 15 00:03:38 2022 -0500 Fix missing params lib commit 2230254ca709625d591b0c73d1a6022c450f6ef6 Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Jan 14 23:38:46 2022 -0500 Disengage on gas toggle commit 87475e02cb63cc39c9b16edc67f303e02d17e6ef Author: Jason Wen <haibin.wen3@gmail.com> Date: Fri Jan 14 23:24:00 2022 -0500 Disengage on gas toggle * bump * use ALTERNATIVE_EXPERIENCE * or it * de-bump * update refs * update refs! * you can just ctrl+click ALTERNATIVE_EXPERIENCE! * already have a params * update text old-commit-hash: f1f40c117a65294e27f93f953a772c43078bdceb
2022-04-05 12:59:52 +08:00
if not self.CP.notCar:
self.events.add_from_msg(self.sm['driverMonitoringState'].events)
# Add car events, ignore if CAN isn't valid
if CS.canValid:
self.events.add_from_msg(CS.events)
# Create events for temperature, disk space, and memory
if self.sm['deviceState'].thermalStatus >= ThermalStatus.red:
self.events.add(EventName.overheat)
if self.sm['deviceState'].freeSpacePercent < 7 and not SIMULATION:
# under 7% of space free no enable allowed
self.events.add(EventName.outOfSpace)
if self.sm['deviceState'].memoryUsagePercent > 90 and not SIMULATION:
self.events.add(EventName.lowMemory)
# TODO: enable this once loggerd CPU usage is more reasonable
#cpus = list(self.sm['deviceState'].cpuUsagePercent)
#if max(cpus, default=0) > 95 and not SIMULATION:
# self.events.add(EventName.highCpuUsage)
# Alert if fan isn't spinning for 5 seconds
if self.sm['peripheralState'].pandaType != log.PandaState.PandaType.unknown:
if self.sm['peripheralState'].fanSpeedRpm < 500 and self.sm['deviceState'].fanSpeedPercentDesired > 50:
# allow enough time for the fan controller in the panda to recover from stalls
if (self.sm.frame - self.last_functional_fan_frame) * DT_CTRL > 15.0:
self.events.add(EventName.fanMalfunction)
else:
self.last_functional_fan_frame = self.sm.frame
# Handle calibration status
cal_status = self.sm['liveCalibration'].calStatus
if cal_status != log.LiveCalibrationData.Status.calibrated:
if cal_status == log.LiveCalibrationData.Status.uncalibrated:
self.events.add(EventName.calibrationIncomplete)
elif cal_status == log.LiveCalibrationData.Status.recalibrating:
if not self.recalibrating_seen:
set_offroad_alert("Offroad_Recalibration", True)
self.recalibrating_seen = True
self.events.add(EventName.calibrationRecalibrating)
else:
self.events.add(EventName.calibrationInvalid)
# Handle lane change
if self.sm['modelV2'].meta.laneChangeState == LaneChangeState.preLaneChange:
direction = self.sm['modelV2'].meta.laneChangeDirection
if (CS.leftBlindspot and direction == LaneChangeDirection.left) or \
(CS.rightBlindspot and direction == LaneChangeDirection.right):
self.events.add(EventName.laneChangeBlocked)
else:
if direction == LaneChangeDirection.left:
self.events.add(EventName.preLaneChangeLeft)
else:
self.events.add(EventName.preLaneChangeRight)
elif self.sm['modelV2'].meta.laneChangeState in (LaneChangeState.laneChangeStarting,
LaneChangeState.laneChangeFinishing):
self.events.add(EventName.laneChange)
for i, pandaState in enumerate(self.sm['pandaStates']):
# All pandas must match the list of safetyConfigs, and if outside this list, must be silent or noOutput
if i < len(self.CP.safetyConfigs):
safety_mismatch = pandaState.safetyModel != self.CP.safetyConfigs[i].safetyModel or \
pandaState.safetyParam != self.CP.safetyConfigs[i].safetyParam or \
pandaState.alternativeExperience != self.CP.alternativeExperience
else:
safety_mismatch = pandaState.safetyModel not in IGNORED_SAFETY_MODES
# safety mismatch allows some time for boardd to set the safety mode and publish it back from panda
if (safety_mismatch and self.sm.frame*DT_CTRL > 10.) or pandaState.safetyRxChecksInvalid or self.mismatch_counter >= 200:
self.events.add(EventName.controlsMismatch)
if log.PandaState.FaultType.relayMalfunction in pandaState.faults:
self.events.add(EventName.relayMalfunction)
# Handle HW and system malfunctions
# Order is very intentional here. Be careful when modifying this.
# All events here should at least have NO_ENTRY and SOFT_DISABLE.
num_events = len(self.events)
not_running = {p.name for p in self.sm['managerState'].processes if not p.running and p.shouldBeRunning}
if self.sm.recv_frame['managerState'] and (not_running - IGNORE_PROCESSES):
self.events.add(EventName.processNotRunning)
if not_running != self.not_running_prev:
cloudlog.event("process_not_running", not_running=not_running, error=True)
self.not_running_prev = not_running
else:
if not SIMULATION and not self.rk.lagging:
if not self.sm.all_alive(self.camera_packets):
self.events.add(EventName.cameraMalfunction)
elif not self.sm.all_freq_ok(self.camera_packets):
self.events.add(EventName.cameraFrameRate)
if not REPLAY and self.rk.lagging:
self.events.add(EventName.controlsdLagging)
if len(self.sm['radarState'].radarErrors) or (not self.rk.lagging and not self.sm.all_checks(['radarState'])):
self.events.add(EventName.radarFault)
if not self.sm.valid['pandaStates']:
self.events.add(EventName.usbError)
if CS.canTimeout:
self.events.add(EventName.canBusMissing)
elif not CS.canValid:
self.events.add(EventName.canError)
# generic catch-all. ideally, a more specific event should be added above instead
has_disable_events = self.events.contains(ET.NO_ENTRY) and (self.events.contains(ET.SOFT_DISABLE) or self.events.contains(ET.IMMEDIATE_DISABLE))
no_system_errors = (not has_disable_events) or (len(self.events) == num_events)
if (not self.sm.all_checks() or self.card.can_rcv_timeout) and no_system_errors:
if not self.sm.all_alive():
self.events.add(EventName.commIssue)
elif not self.sm.all_freq_ok():
self.events.add(EventName.commIssueAvgFreq)
else: # invalid or can_rcv_timeout.
self.events.add(EventName.commIssue)
logs = {
'invalid': [s for s, valid in self.sm.valid.items() if not valid],
'not_alive': [s for s, alive in self.sm.alive.items() if not alive],
'not_freq_ok': [s for s, freq_ok in self.sm.freq_ok.items() if not freq_ok],
'can_rcv_timeout': self.card.can_rcv_timeout,
}
if logs != self.logged_comm_issue:
cloudlog.event("commIssue", error=True, **logs)
self.logged_comm_issue = logs
else:
self.logged_comm_issue = None
if not (self.CP.notCar and self.joystick_mode):
if not self.sm['liveLocationKalman'].posenetOK:
self.events.add(EventName.posenetInvalid)
if not self.sm['liveLocationKalman'].deviceStable:
self.events.add(EventName.deviceFalling)
if not self.sm['liveLocationKalman'].inputsOK:
self.events.add(EventName.locationdTemporaryError)
if not self.sm['liveParameters'].valid and not TESTING_CLOSET and (not SIMULATION or REPLAY):
self.events.add(EventName.paramsdTemporaryError)
# conservative HW alert. if the data or frequency are off, locationd will throw an error
if any((self.sm.frame - self.sm.recv_frame[s])*DT_CTRL > 10. for s in self.sensor_packets):
self.events.add(EventName.sensorDataInvalid)
if not REPLAY:
# Check for mismatch between openpilot and car's PCM
cruise_mismatch = CS.cruiseState.enabled and (not self.enabled or not self.CP.pcmCruise)
self.cruise_mismatch_counter = self.cruise_mismatch_counter + 1 if cruise_mismatch else 0
if self.cruise_mismatch_counter > int(6. / DT_CTRL):
self.events.add(EventName.cruiseMismatch)
# Check for FCW
stock_long_is_braking = self.enabled and not self.CP.openpilotLongitudinalControl and CS.aEgo < -1.25
model_fcw = self.sm['modelV2'].meta.hardBrakePredicted and not CS.brakePressed and not stock_long_is_braking
planner_fcw = self.sm['longitudinalPlan'].fcw and self.enabled
if planner_fcw or model_fcw:
self.events.add(EventName.fcw)
for m in messaging.drain_sock(self.log_sock, wait_for_one=False):
try:
msg = m.androidLog.message
if any(err in msg for err in ("ERROR_CRC", "ERROR_ECC", "ERROR_STREAM_UNDERFLOW", "APPLY FAILED")):
csid = msg.split("CSID:")[-1].split(" ")[0]
evt = CSID_MAP.get(csid, None)
if evt is not None:
self.events.add(evt)
except UnicodeDecodeError:
pass
# TODO: fix simulator
if not SIMULATION or REPLAY:
# Not show in first 1 km to allow for driving out of garage. This event shows after 5 minutes
if not self.sm['liveLocationKalman'].gpsOK and self.sm['liveLocationKalman'].inputsOK and (self.distance_traveled > 1000):
self.events.add(EventName.noGps)
if self.sm['liveLocationKalman'].gpsOK:
self.distance_traveled = 0
self.distance_traveled += CS.vEgo * DT_CTRL
if self.sm['modelV2'].frameDropPerc > 20:
self.events.add(EventName.modeldLagging)
def data_sample(self):
"""Receive data from sockets and update carState"""
CS = self.card.state_update()
self.sm.update(0)
if not self.initialized:
all_valid = CS.canValid and self.sm.all_checks()
timed_out = self.sm.frame * DT_CTRL > 6.
if all_valid or timed_out or (SIMULATION and not REPLAY):
available_streams = VisionIpcClient.available_streams("camerad", block=False)
if VisionStreamType.VISION_STREAM_ROAD not in available_streams:
self.sm.ignore_alive.append('roadCameraState')
if VisionStreamType.VISION_STREAM_WIDE_ROAD not in available_streams:
self.sm.ignore_alive.append('wideRoadCameraState')
if not self.CP.passive:
self.card.initialize()
self.initialized = True
self.set_initial_state()
self.params.put_bool_nonblocking("ControlsReady", True)
cloudlog.event(
"controlsd.initialized",
dt=self.sm.frame*DT_CTRL,
timeout=timed_out,
canValid=CS.canValid,
invalid=[s for s, valid in self.sm.valid.items() if not valid],
not_alive=[s for s, alive in self.sm.alive.items() if not alive],
not_freq_ok=[s for s, freq_ok in self.sm.freq_ok.items() if not freq_ok],
error=True,
)
# When the panda and controlsd do not agree on controls_allowed
# we want to disengage openpilot. However the status from the panda goes through
# another socket other than the CAN messages and one can arrive earlier than the other.
# Therefore we allow a mismatch for two samples, then we trigger the disengagement.
if not self.enabled:
self.mismatch_counter = 0
# All pandas not in silent mode must have controlsAllowed when openpilot is enabled
if self.enabled and any(not ps.controlsAllowed for ps in self.sm['pandaStates']
if ps.safetyModel not in IGNORED_SAFETY_MODES):
self.mismatch_counter += 1
return CS
def state_transition(self, CS):
"""Compute conditional state transitions and execute actions on state transitions"""
self.v_cruise_helper.update_v_cruise(CS, self.enabled, self.is_metric)
# decrement the soft disable timer at every step, as it's reset on
# entrance in SOFT_DISABLING state
self.soft_disable_timer = max(0, self.soft_disable_timer - 1)
self.current_alert_types = [ET.PERMANENT]
controlsState: add override state with grey border (#24030) * Squashed commit of the following: commit f0cf822666fb8f78a486d721fe474e8f37da6970 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:24:00 2022 -0700 clean up commit 4364bdb79b1b055daa7542267eb3f37740723fd4 Merge: d448664cf e85f82af3 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:21:41 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit d448664cfdacbdfd3c99f8e12d96f2ba7b24abb5 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:20:44 2022 -0700 revert tests changes commit 40ab8c2d912ccbeb12286ca272e3737656388ac8 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:03:39 2022 -0700 sort commit 5abd4448b420e91eda57e3c4edb6794893dab42f Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:59 2022 -0700 bump cereal commit fcffc42082b1460676554924461c63c881c31501 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:25 2022 -0700 pass in CI commit f47dd63bc597e18c05d2d9365eb996c13ec70c17 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 12:06:00 2022 -0700 update refs commit f1c54e16ccfa37f770b422ad77e2fc940f8ea7f2 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:51:04 2022 -0700 move to tuple commit bebafc6ed223a67e59daa7c2105f8cb28c4f9c5f Merge: b0578dc54 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:45:19 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit b0578dc54f9d943e0ab2182b0b79d076129468a7 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:44:37 2022 -0700 make global variables of states in controlsd make global variables of states in controlsd commit 32b7e293e88f001ef44c9197dfc68b7240ae129e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:41:41 2022 -0700 test individual event types fix commit 1fbf66fc8ba7e5a0a25d34a1f30a2cb3ccb86a02 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:03:09 2022 -0700 clean up test state machine test state machine commit 33856bef69b1c2e637e58032b1358f275a6cd6bb Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:59:05 2022 -0700 clean up commit d64cd664980edd6cff0038379a5c3965409ebda0 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:40:25 2022 -0700 test few more things commit 72a3e57a9a8813b348a8ae9648e283983f7ba56b Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:17:22 2022 -0700 default transitions commit ce0051fde8296dab6417d9ef175fdf039d09a8f3 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:21 2022 -0700 remove commit 56de4f8a87e9b96dd99739772da1dddaa873ceb1 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:15 2022 -0700 this way we can test any combo of event types commit bdfd47738e5a3c0e22817047cc2d804ca0fe2785 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 21:36:33 2022 -0700 add some state machine tests commit 81a72d1773b204cc984fb0631ac30fb00555962d Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:43:03 2022 -0700 update refs commit 00018708714b156c29f963011a6193fa9028b308 Merge: fa97ffa67 fa934d846 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:31:51 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit fa97ffa67eec1556b2b255ee68bdf46fc101596e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:30:23 2022 -0700 revert todo commit b0dcd49b0b0254a4754ddc5ea61618246686327d Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:07:11 2022 -0700 move back commit ef12853ceed8c8aa37b16af406e510d172269226 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 29 23:09:05 2022 -0700 bump cereal commit 2658f557e2fac79563b74385b8676a659f31f7dc Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:54:48 2022 -0700 fix commit ed2db85acd34cd78017c6bae0db5df3356c2c19c Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:47:18 2022 -0700 add alert to pass unit tests commit dc970f55f5f69ecbca7095099bd50ff21ba02610 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:26:18 2022 -0700 bump commit e9a3c73d61590120cc5e5c16a3d1a0bbbd51e19d Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:25:33 2022 -0700 normal commit 4ecfbf18d5e6436f9be6bd3b1c4ea3bca8c1a572 Merge: 47e0ad3cb 02b968ed9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:14:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit 47e0ad3cbe4fee81b7a6e4c284973c25b144ddf7 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:50:34 2022 -0700 only rename commit 8c46435630c1bfba5c5b911bc1d3c8d4b24c9fdd Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:49:26 2022 -0700 bump cereal commit eb48440843d6a4b09e1f34d8eb2ed4c7f7a8274c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:29:49 2022 -0700 fix commit 231afe3e6f211e866216a557f2ec2787760d2607 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:40 2022 -0700 clean up commit 7a3f49db1bdb58c8ef59a9376306ef1157ba2e57 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:10 2022 -0700 fix logic commit eab4f8b46e6c22033ac4ae433b6ba94e6a4ff322 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 21:05:05 2022 -0700 clean up commit 51e189a27268364e051c6d9231ae6f181ec7f95b Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 20:51:23 2022 -0700 override state testing * clean up old-commit-hash: 2624b4cb27f7f2bd184bac5dd7b2c718767da583
2022-04-05 09:02:27 +08:00
# ENABLED, SOFT DISABLING, PRE ENABLING, OVERRIDING
if self.state != State.disabled:
# user and immediate disable always have priority in a non-disabled state
if self.events.contains(ET.USER_DISABLE):
self.state = State.disabled
self.current_alert_types.append(ET.USER_DISABLE)
elif self.events.contains(ET.IMMEDIATE_DISABLE):
self.state = State.disabled
self.current_alert_types.append(ET.IMMEDIATE_DISABLE)
else:
# ENABLED
if self.state == State.enabled:
if self.events.contains(ET.SOFT_DISABLE):
self.state = State.softDisabling
self.soft_disable_timer = int(SOFT_DISABLE_TIME / DT_CTRL)
self.current_alert_types.append(ET.SOFT_DISABLE)
elif self.events.contains(ET.OVERRIDE_LATERAL) or self.events.contains(ET.OVERRIDE_LONGITUDINAL):
controlsState: add override state with grey border (#24030) * Squashed commit of the following: commit f0cf822666fb8f78a486d721fe474e8f37da6970 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:24:00 2022 -0700 clean up commit 4364bdb79b1b055daa7542267eb3f37740723fd4 Merge: d448664cf e85f82af3 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:21:41 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit d448664cfdacbdfd3c99f8e12d96f2ba7b24abb5 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:20:44 2022 -0700 revert tests changes commit 40ab8c2d912ccbeb12286ca272e3737656388ac8 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:03:39 2022 -0700 sort commit 5abd4448b420e91eda57e3c4edb6794893dab42f Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:59 2022 -0700 bump cereal commit fcffc42082b1460676554924461c63c881c31501 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:25 2022 -0700 pass in CI commit f47dd63bc597e18c05d2d9365eb996c13ec70c17 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 12:06:00 2022 -0700 update refs commit f1c54e16ccfa37f770b422ad77e2fc940f8ea7f2 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:51:04 2022 -0700 move to tuple commit bebafc6ed223a67e59daa7c2105f8cb28c4f9c5f Merge: b0578dc54 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:45:19 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit b0578dc54f9d943e0ab2182b0b79d076129468a7 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:44:37 2022 -0700 make global variables of states in controlsd make global variables of states in controlsd commit 32b7e293e88f001ef44c9197dfc68b7240ae129e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:41:41 2022 -0700 test individual event types fix commit 1fbf66fc8ba7e5a0a25d34a1f30a2cb3ccb86a02 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:03:09 2022 -0700 clean up test state machine test state machine commit 33856bef69b1c2e637e58032b1358f275a6cd6bb Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:59:05 2022 -0700 clean up commit d64cd664980edd6cff0038379a5c3965409ebda0 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:40:25 2022 -0700 test few more things commit 72a3e57a9a8813b348a8ae9648e283983f7ba56b Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:17:22 2022 -0700 default transitions commit ce0051fde8296dab6417d9ef175fdf039d09a8f3 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:21 2022 -0700 remove commit 56de4f8a87e9b96dd99739772da1dddaa873ceb1 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:15 2022 -0700 this way we can test any combo of event types commit bdfd47738e5a3c0e22817047cc2d804ca0fe2785 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 21:36:33 2022 -0700 add some state machine tests commit 81a72d1773b204cc984fb0631ac30fb00555962d Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:43:03 2022 -0700 update refs commit 00018708714b156c29f963011a6193fa9028b308 Merge: fa97ffa67 fa934d846 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:31:51 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit fa97ffa67eec1556b2b255ee68bdf46fc101596e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:30:23 2022 -0700 revert todo commit b0dcd49b0b0254a4754ddc5ea61618246686327d Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:07:11 2022 -0700 move back commit ef12853ceed8c8aa37b16af406e510d172269226 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 29 23:09:05 2022 -0700 bump cereal commit 2658f557e2fac79563b74385b8676a659f31f7dc Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:54:48 2022 -0700 fix commit ed2db85acd34cd78017c6bae0db5df3356c2c19c Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:47:18 2022 -0700 add alert to pass unit tests commit dc970f55f5f69ecbca7095099bd50ff21ba02610 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:26:18 2022 -0700 bump commit e9a3c73d61590120cc5e5c16a3d1a0bbbd51e19d Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:25:33 2022 -0700 normal commit 4ecfbf18d5e6436f9be6bd3b1c4ea3bca8c1a572 Merge: 47e0ad3cb 02b968ed9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:14:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit 47e0ad3cbe4fee81b7a6e4c284973c25b144ddf7 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:50:34 2022 -0700 only rename commit 8c46435630c1bfba5c5b911bc1d3c8d4b24c9fdd Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:49:26 2022 -0700 bump cereal commit eb48440843d6a4b09e1f34d8eb2ed4c7f7a8274c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:29:49 2022 -0700 fix commit 231afe3e6f211e866216a557f2ec2787760d2607 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:40 2022 -0700 clean up commit 7a3f49db1bdb58c8ef59a9376306ef1157ba2e57 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:10 2022 -0700 fix logic commit eab4f8b46e6c22033ac4ae433b6ba94e6a4ff322 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 21:05:05 2022 -0700 clean up commit 51e189a27268364e051c6d9231ae6f181ec7f95b Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 20:51:23 2022 -0700 override state testing * clean up old-commit-hash: 2624b4cb27f7f2bd184bac5dd7b2c718767da583
2022-04-05 09:02:27 +08:00
self.state = State.overriding
self.current_alert_types += [ET.OVERRIDE_LATERAL, ET.OVERRIDE_LONGITUDINAL]
controlsState: add override state with grey border (#24030) * Squashed commit of the following: commit f0cf822666fb8f78a486d721fe474e8f37da6970 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:24:00 2022 -0700 clean up commit 4364bdb79b1b055daa7542267eb3f37740723fd4 Merge: d448664cf e85f82af3 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:21:41 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit d448664cfdacbdfd3c99f8e12d96f2ba7b24abb5 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:20:44 2022 -0700 revert tests changes commit 40ab8c2d912ccbeb12286ca272e3737656388ac8 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:03:39 2022 -0700 sort commit 5abd4448b420e91eda57e3c4edb6794893dab42f Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:59 2022 -0700 bump cereal commit fcffc42082b1460676554924461c63c881c31501 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:25 2022 -0700 pass in CI commit f47dd63bc597e18c05d2d9365eb996c13ec70c17 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 12:06:00 2022 -0700 update refs commit f1c54e16ccfa37f770b422ad77e2fc940f8ea7f2 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:51:04 2022 -0700 move to tuple commit bebafc6ed223a67e59daa7c2105f8cb28c4f9c5f Merge: b0578dc54 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:45:19 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit b0578dc54f9d943e0ab2182b0b79d076129468a7 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:44:37 2022 -0700 make global variables of states in controlsd make global variables of states in controlsd commit 32b7e293e88f001ef44c9197dfc68b7240ae129e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:41:41 2022 -0700 test individual event types fix commit 1fbf66fc8ba7e5a0a25d34a1f30a2cb3ccb86a02 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:03:09 2022 -0700 clean up test state machine test state machine commit 33856bef69b1c2e637e58032b1358f275a6cd6bb Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:59:05 2022 -0700 clean up commit d64cd664980edd6cff0038379a5c3965409ebda0 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:40:25 2022 -0700 test few more things commit 72a3e57a9a8813b348a8ae9648e283983f7ba56b Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:17:22 2022 -0700 default transitions commit ce0051fde8296dab6417d9ef175fdf039d09a8f3 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:21 2022 -0700 remove commit 56de4f8a87e9b96dd99739772da1dddaa873ceb1 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:15 2022 -0700 this way we can test any combo of event types commit bdfd47738e5a3c0e22817047cc2d804ca0fe2785 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 21:36:33 2022 -0700 add some state machine tests commit 81a72d1773b204cc984fb0631ac30fb00555962d Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:43:03 2022 -0700 update refs commit 00018708714b156c29f963011a6193fa9028b308 Merge: fa97ffa67 fa934d846 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:31:51 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit fa97ffa67eec1556b2b255ee68bdf46fc101596e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:30:23 2022 -0700 revert todo commit b0dcd49b0b0254a4754ddc5ea61618246686327d Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:07:11 2022 -0700 move back commit ef12853ceed8c8aa37b16af406e510d172269226 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 29 23:09:05 2022 -0700 bump cereal commit 2658f557e2fac79563b74385b8676a659f31f7dc Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:54:48 2022 -0700 fix commit ed2db85acd34cd78017c6bae0db5df3356c2c19c Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:47:18 2022 -0700 add alert to pass unit tests commit dc970f55f5f69ecbca7095099bd50ff21ba02610 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:26:18 2022 -0700 bump commit e9a3c73d61590120cc5e5c16a3d1a0bbbd51e19d Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:25:33 2022 -0700 normal commit 4ecfbf18d5e6436f9be6bd3b1c4ea3bca8c1a572 Merge: 47e0ad3cb 02b968ed9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:14:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit 47e0ad3cbe4fee81b7a6e4c284973c25b144ddf7 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:50:34 2022 -0700 only rename commit 8c46435630c1bfba5c5b911bc1d3c8d4b24c9fdd Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:49:26 2022 -0700 bump cereal commit eb48440843d6a4b09e1f34d8eb2ed4c7f7a8274c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:29:49 2022 -0700 fix commit 231afe3e6f211e866216a557f2ec2787760d2607 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:40 2022 -0700 clean up commit 7a3f49db1bdb58c8ef59a9376306ef1157ba2e57 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:10 2022 -0700 fix logic commit eab4f8b46e6c22033ac4ae433b6ba94e6a4ff322 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 21:05:05 2022 -0700 clean up commit 51e189a27268364e051c6d9231ae6f181ec7f95b Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 20:51:23 2022 -0700 override state testing * clean up old-commit-hash: 2624b4cb27f7f2bd184bac5dd7b2c718767da583
2022-04-05 09:02:27 +08:00
# SOFT DISABLING
elif self.state == State.softDisabling:
if not self.events.contains(ET.SOFT_DISABLE):
# no more soft disabling condition, so go back to ENABLED
self.state = State.enabled
elif self.soft_disable_timer > 0:
self.current_alert_types.append(ET.SOFT_DISABLE)
elif self.soft_disable_timer <= 0:
self.state = State.disabled
# PRE ENABLING
elif self.state == State.preEnabled:
if not self.events.contains(ET.PRE_ENABLE):
self.state = State.enabled
else:
self.current_alert_types.append(ET.PRE_ENABLE)
controlsState: add override state with grey border (#24030) * Squashed commit of the following: commit f0cf822666fb8f78a486d721fe474e8f37da6970 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:24:00 2022 -0700 clean up commit 4364bdb79b1b055daa7542267eb3f37740723fd4 Merge: d448664cf e85f82af3 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:21:41 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit d448664cfdacbdfd3c99f8e12d96f2ba7b24abb5 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:20:44 2022 -0700 revert tests changes commit 40ab8c2d912ccbeb12286ca272e3737656388ac8 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:03:39 2022 -0700 sort commit 5abd4448b420e91eda57e3c4edb6794893dab42f Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:59 2022 -0700 bump cereal commit fcffc42082b1460676554924461c63c881c31501 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:25 2022 -0700 pass in CI commit f47dd63bc597e18c05d2d9365eb996c13ec70c17 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 12:06:00 2022 -0700 update refs commit f1c54e16ccfa37f770b422ad77e2fc940f8ea7f2 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:51:04 2022 -0700 move to tuple commit bebafc6ed223a67e59daa7c2105f8cb28c4f9c5f Merge: b0578dc54 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:45:19 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit b0578dc54f9d943e0ab2182b0b79d076129468a7 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:44:37 2022 -0700 make global variables of states in controlsd make global variables of states in controlsd commit 32b7e293e88f001ef44c9197dfc68b7240ae129e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:41:41 2022 -0700 test individual event types fix commit 1fbf66fc8ba7e5a0a25d34a1f30a2cb3ccb86a02 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:03:09 2022 -0700 clean up test state machine test state machine commit 33856bef69b1c2e637e58032b1358f275a6cd6bb Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:59:05 2022 -0700 clean up commit d64cd664980edd6cff0038379a5c3965409ebda0 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:40:25 2022 -0700 test few more things commit 72a3e57a9a8813b348a8ae9648e283983f7ba56b Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:17:22 2022 -0700 default transitions commit ce0051fde8296dab6417d9ef175fdf039d09a8f3 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:21 2022 -0700 remove commit 56de4f8a87e9b96dd99739772da1dddaa873ceb1 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:15 2022 -0700 this way we can test any combo of event types commit bdfd47738e5a3c0e22817047cc2d804ca0fe2785 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 21:36:33 2022 -0700 add some state machine tests commit 81a72d1773b204cc984fb0631ac30fb00555962d Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:43:03 2022 -0700 update refs commit 00018708714b156c29f963011a6193fa9028b308 Merge: fa97ffa67 fa934d846 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:31:51 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit fa97ffa67eec1556b2b255ee68bdf46fc101596e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:30:23 2022 -0700 revert todo commit b0dcd49b0b0254a4754ddc5ea61618246686327d Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:07:11 2022 -0700 move back commit ef12853ceed8c8aa37b16af406e510d172269226 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 29 23:09:05 2022 -0700 bump cereal commit 2658f557e2fac79563b74385b8676a659f31f7dc Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:54:48 2022 -0700 fix commit ed2db85acd34cd78017c6bae0db5df3356c2c19c Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:47:18 2022 -0700 add alert to pass unit tests commit dc970f55f5f69ecbca7095099bd50ff21ba02610 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:26:18 2022 -0700 bump commit e9a3c73d61590120cc5e5c16a3d1a0bbbd51e19d Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:25:33 2022 -0700 normal commit 4ecfbf18d5e6436f9be6bd3b1c4ea3bca8c1a572 Merge: 47e0ad3cb 02b968ed9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:14:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit 47e0ad3cbe4fee81b7a6e4c284973c25b144ddf7 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:50:34 2022 -0700 only rename commit 8c46435630c1bfba5c5b911bc1d3c8d4b24c9fdd Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:49:26 2022 -0700 bump cereal commit eb48440843d6a4b09e1f34d8eb2ed4c7f7a8274c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:29:49 2022 -0700 fix commit 231afe3e6f211e866216a557f2ec2787760d2607 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:40 2022 -0700 clean up commit 7a3f49db1bdb58c8ef59a9376306ef1157ba2e57 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:10 2022 -0700 fix logic commit eab4f8b46e6c22033ac4ae433b6ba94e6a4ff322 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 21:05:05 2022 -0700 clean up commit 51e189a27268364e051c6d9231ae6f181ec7f95b Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 20:51:23 2022 -0700 override state testing * clean up old-commit-hash: 2624b4cb27f7f2bd184bac5dd7b2c718767da583
2022-04-05 09:02:27 +08:00
# OVERRIDING
elif self.state == State.overriding:
if self.events.contains(ET.SOFT_DISABLE):
self.state = State.softDisabling
self.soft_disable_timer = int(SOFT_DISABLE_TIME / DT_CTRL)
self.current_alert_types.append(ET.SOFT_DISABLE)
elif not (self.events.contains(ET.OVERRIDE_LATERAL) or self.events.contains(ET.OVERRIDE_LONGITUDINAL)):
controlsState: add override state with grey border (#24030) * Squashed commit of the following: commit f0cf822666fb8f78a486d721fe474e8f37da6970 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:24:00 2022 -0700 clean up commit 4364bdb79b1b055daa7542267eb3f37740723fd4 Merge: d448664cf e85f82af3 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:21:41 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit d448664cfdacbdfd3c99f8e12d96f2ba7b24abb5 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:20:44 2022 -0700 revert tests changes commit 40ab8c2d912ccbeb12286ca272e3737656388ac8 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:03:39 2022 -0700 sort commit 5abd4448b420e91eda57e3c4edb6794893dab42f Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:59 2022 -0700 bump cereal commit fcffc42082b1460676554924461c63c881c31501 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:25 2022 -0700 pass in CI commit f47dd63bc597e18c05d2d9365eb996c13ec70c17 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 12:06:00 2022 -0700 update refs commit f1c54e16ccfa37f770b422ad77e2fc940f8ea7f2 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:51:04 2022 -0700 move to tuple commit bebafc6ed223a67e59daa7c2105f8cb28c4f9c5f Merge: b0578dc54 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:45:19 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit b0578dc54f9d943e0ab2182b0b79d076129468a7 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:44:37 2022 -0700 make global variables of states in controlsd make global variables of states in controlsd commit 32b7e293e88f001ef44c9197dfc68b7240ae129e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:41:41 2022 -0700 test individual event types fix commit 1fbf66fc8ba7e5a0a25d34a1f30a2cb3ccb86a02 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:03:09 2022 -0700 clean up test state machine test state machine commit 33856bef69b1c2e637e58032b1358f275a6cd6bb Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:59:05 2022 -0700 clean up commit d64cd664980edd6cff0038379a5c3965409ebda0 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:40:25 2022 -0700 test few more things commit 72a3e57a9a8813b348a8ae9648e283983f7ba56b Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:17:22 2022 -0700 default transitions commit ce0051fde8296dab6417d9ef175fdf039d09a8f3 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:21 2022 -0700 remove commit 56de4f8a87e9b96dd99739772da1dddaa873ceb1 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:15 2022 -0700 this way we can test any combo of event types commit bdfd47738e5a3c0e22817047cc2d804ca0fe2785 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 21:36:33 2022 -0700 add some state machine tests commit 81a72d1773b204cc984fb0631ac30fb00555962d Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:43:03 2022 -0700 update refs commit 00018708714b156c29f963011a6193fa9028b308 Merge: fa97ffa67 fa934d846 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:31:51 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit fa97ffa67eec1556b2b255ee68bdf46fc101596e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:30:23 2022 -0700 revert todo commit b0dcd49b0b0254a4754ddc5ea61618246686327d Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:07:11 2022 -0700 move back commit ef12853ceed8c8aa37b16af406e510d172269226 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 29 23:09:05 2022 -0700 bump cereal commit 2658f557e2fac79563b74385b8676a659f31f7dc Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:54:48 2022 -0700 fix commit ed2db85acd34cd78017c6bae0db5df3356c2c19c Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:47:18 2022 -0700 add alert to pass unit tests commit dc970f55f5f69ecbca7095099bd50ff21ba02610 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:26:18 2022 -0700 bump commit e9a3c73d61590120cc5e5c16a3d1a0bbbd51e19d Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:25:33 2022 -0700 normal commit 4ecfbf18d5e6436f9be6bd3b1c4ea3bca8c1a572 Merge: 47e0ad3cb 02b968ed9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:14:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit 47e0ad3cbe4fee81b7a6e4c284973c25b144ddf7 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:50:34 2022 -0700 only rename commit 8c46435630c1bfba5c5b911bc1d3c8d4b24c9fdd Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:49:26 2022 -0700 bump cereal commit eb48440843d6a4b09e1f34d8eb2ed4c7f7a8274c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:29:49 2022 -0700 fix commit 231afe3e6f211e866216a557f2ec2787760d2607 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:40 2022 -0700 clean up commit 7a3f49db1bdb58c8ef59a9376306ef1157ba2e57 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:10 2022 -0700 fix logic commit eab4f8b46e6c22033ac4ae433b6ba94e6a4ff322 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 21:05:05 2022 -0700 clean up commit 51e189a27268364e051c6d9231ae6f181ec7f95b Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 20:51:23 2022 -0700 override state testing * clean up old-commit-hash: 2624b4cb27f7f2bd184bac5dd7b2c718767da583
2022-04-05 09:02:27 +08:00
self.state = State.enabled
else:
self.current_alert_types += [ET.OVERRIDE_LATERAL, ET.OVERRIDE_LONGITUDINAL]
controlsState: add override state with grey border (#24030) * Squashed commit of the following: commit f0cf822666fb8f78a486d721fe474e8f37da6970 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:24:00 2022 -0700 clean up commit 4364bdb79b1b055daa7542267eb3f37740723fd4 Merge: d448664cf e85f82af3 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:21:41 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit d448664cfdacbdfd3c99f8e12d96f2ba7b24abb5 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:20:44 2022 -0700 revert tests changes commit 40ab8c2d912ccbeb12286ca272e3737656388ac8 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:03:39 2022 -0700 sort commit 5abd4448b420e91eda57e3c4edb6794893dab42f Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:59 2022 -0700 bump cereal commit fcffc42082b1460676554924461c63c881c31501 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:25 2022 -0700 pass in CI commit f47dd63bc597e18c05d2d9365eb996c13ec70c17 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 12:06:00 2022 -0700 update refs commit f1c54e16ccfa37f770b422ad77e2fc940f8ea7f2 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:51:04 2022 -0700 move to tuple commit bebafc6ed223a67e59daa7c2105f8cb28c4f9c5f Merge: b0578dc54 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:45:19 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit b0578dc54f9d943e0ab2182b0b79d076129468a7 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:44:37 2022 -0700 make global variables of states in controlsd make global variables of states in controlsd commit 32b7e293e88f001ef44c9197dfc68b7240ae129e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:41:41 2022 -0700 test individual event types fix commit 1fbf66fc8ba7e5a0a25d34a1f30a2cb3ccb86a02 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:03:09 2022 -0700 clean up test state machine test state machine commit 33856bef69b1c2e637e58032b1358f275a6cd6bb Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:59:05 2022 -0700 clean up commit d64cd664980edd6cff0038379a5c3965409ebda0 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:40:25 2022 -0700 test few more things commit 72a3e57a9a8813b348a8ae9648e283983f7ba56b Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:17:22 2022 -0700 default transitions commit ce0051fde8296dab6417d9ef175fdf039d09a8f3 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:21 2022 -0700 remove commit 56de4f8a87e9b96dd99739772da1dddaa873ceb1 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:15 2022 -0700 this way we can test any combo of event types commit bdfd47738e5a3c0e22817047cc2d804ca0fe2785 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 21:36:33 2022 -0700 add some state machine tests commit 81a72d1773b204cc984fb0631ac30fb00555962d Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:43:03 2022 -0700 update refs commit 00018708714b156c29f963011a6193fa9028b308 Merge: fa97ffa67 fa934d846 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:31:51 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit fa97ffa67eec1556b2b255ee68bdf46fc101596e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:30:23 2022 -0700 revert todo commit b0dcd49b0b0254a4754ddc5ea61618246686327d Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:07:11 2022 -0700 move back commit ef12853ceed8c8aa37b16af406e510d172269226 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 29 23:09:05 2022 -0700 bump cereal commit 2658f557e2fac79563b74385b8676a659f31f7dc Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:54:48 2022 -0700 fix commit ed2db85acd34cd78017c6bae0db5df3356c2c19c Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:47:18 2022 -0700 add alert to pass unit tests commit dc970f55f5f69ecbca7095099bd50ff21ba02610 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:26:18 2022 -0700 bump commit e9a3c73d61590120cc5e5c16a3d1a0bbbd51e19d Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:25:33 2022 -0700 normal commit 4ecfbf18d5e6436f9be6bd3b1c4ea3bca8c1a572 Merge: 47e0ad3cb 02b968ed9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:14:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit 47e0ad3cbe4fee81b7a6e4c284973c25b144ddf7 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:50:34 2022 -0700 only rename commit 8c46435630c1bfba5c5b911bc1d3c8d4b24c9fdd Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:49:26 2022 -0700 bump cereal commit eb48440843d6a4b09e1f34d8eb2ed4c7f7a8274c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:29:49 2022 -0700 fix commit 231afe3e6f211e866216a557f2ec2787760d2607 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:40 2022 -0700 clean up commit 7a3f49db1bdb58c8ef59a9376306ef1157ba2e57 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:10 2022 -0700 fix logic commit eab4f8b46e6c22033ac4ae433b6ba94e6a4ff322 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 21:05:05 2022 -0700 clean up commit 51e189a27268364e051c6d9231ae6f181ec7f95b Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 20:51:23 2022 -0700 override state testing * clean up old-commit-hash: 2624b4cb27f7f2bd184bac5dd7b2c718767da583
2022-04-05 09:02:27 +08:00
# DISABLED
elif self.state == State.disabled:
if self.events.contains(ET.ENABLE):
if self.events.contains(ET.NO_ENTRY):
self.current_alert_types.append(ET.NO_ENTRY)
else:
if self.events.contains(ET.PRE_ENABLE):
self.state = State.preEnabled
elif self.events.contains(ET.OVERRIDE_LATERAL) or self.events.contains(ET.OVERRIDE_LONGITUDINAL):
controlsState: add override state with grey border (#24030) * Squashed commit of the following: commit f0cf822666fb8f78a486d721fe474e8f37da6970 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:24:00 2022 -0700 clean up commit 4364bdb79b1b055daa7542267eb3f37740723fd4 Merge: d448664cf e85f82af3 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:21:41 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit d448664cfdacbdfd3c99f8e12d96f2ba7b24abb5 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Apr 4 17:20:44 2022 -0700 revert tests changes commit 40ab8c2d912ccbeb12286ca272e3737656388ac8 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:03:39 2022 -0700 sort commit 5abd4448b420e91eda57e3c4edb6794893dab42f Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:59 2022 -0700 bump cereal commit fcffc42082b1460676554924461c63c881c31501 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 19:02:25 2022 -0700 pass in CI commit f47dd63bc597e18c05d2d9365eb996c13ec70c17 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 12:06:00 2022 -0700 update refs commit f1c54e16ccfa37f770b422ad77e2fc940f8ea7f2 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:51:04 2022 -0700 move to tuple commit bebafc6ed223a67e59daa7c2105f8cb28c4f9c5f Merge: b0578dc54 0e983562d Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:45:19 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit b0578dc54f9d943e0ab2182b0b79d076129468a7 Author: Shane Smiskol <shane@smiskol.com> Date: Fri Apr 1 11:44:37 2022 -0700 make global variables of states in controlsd make global variables of states in controlsd commit 32b7e293e88f001ef44c9197dfc68b7240ae129e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:41:41 2022 -0700 test individual event types fix commit 1fbf66fc8ba7e5a0a25d34a1f30a2cb3ccb86a02 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 23:03:09 2022 -0700 clean up test state machine test state machine commit 33856bef69b1c2e637e58032b1358f275a6cd6bb Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:59:05 2022 -0700 clean up commit d64cd664980edd6cff0038379a5c3965409ebda0 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:40:25 2022 -0700 test few more things commit 72a3e57a9a8813b348a8ae9648e283983f7ba56b Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:17:22 2022 -0700 default transitions commit ce0051fde8296dab6417d9ef175fdf039d09a8f3 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:21 2022 -0700 remove commit 56de4f8a87e9b96dd99739772da1dddaa873ceb1 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 22:05:15 2022 -0700 this way we can test any combo of event types commit bdfd47738e5a3c0e22817047cc2d804ca0fe2785 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 21:36:33 2022 -0700 add some state machine tests commit 81a72d1773b204cc984fb0631ac30fb00555962d Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:43:03 2022 -0700 update refs commit 00018708714b156c29f963011a6193fa9028b308 Merge: fa97ffa67 fa934d846 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:31:51 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit fa97ffa67eec1556b2b255ee68bdf46fc101596e Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 31 17:30:23 2022 -0700 revert todo commit b0dcd49b0b0254a4754ddc5ea61618246686327d Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 30 00:07:11 2022 -0700 move back commit ef12853ceed8c8aa37b16af406e510d172269226 Author: Shane Smiskol <shane@smiskol.com> Date: Tue Mar 29 23:09:05 2022 -0700 bump cereal commit 2658f557e2fac79563b74385b8676a659f31f7dc Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:54:48 2022 -0700 fix commit ed2db85acd34cd78017c6bae0db5df3356c2c19c Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:47:18 2022 -0700 add alert to pass unit tests commit dc970f55f5f69ecbca7095099bd50ff21ba02610 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:26:18 2022 -0700 bump commit e9a3c73d61590120cc5e5c16a3d1a0bbbd51e19d Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:25:33 2022 -0700 normal commit 4ecfbf18d5e6436f9be6bd3b1c4ea3bca8c1a572 Merge: 47e0ad3cb 02b968ed9 Author: Shane Smiskol <shane@smiskol.com> Date: Mon Mar 28 20:14:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit 47e0ad3cbe4fee81b7a6e4c284973c25b144ddf7 Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:50:34 2022 -0700 only rename commit 8c46435630c1bfba5c5b911bc1d3c8d4b24c9fdd Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:49:26 2022 -0700 bump cereal commit eb48440843d6a4b09e1f34d8eb2ed4c7f7a8274c Author: Shane Smiskol <shane@smiskol.com> Date: Thu Mar 24 10:29:49 2022 -0700 fix commit 231afe3e6f211e866216a557f2ec2787760d2607 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:40 2022 -0700 clean up commit 7a3f49db1bdb58c8ef59a9376306ef1157ba2e57 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 23:57:10 2022 -0700 fix logic commit eab4f8b46e6c22033ac4ae433b6ba94e6a4ff322 Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 21:05:05 2022 -0700 clean up commit 51e189a27268364e051c6d9231ae6f181ec7f95b Author: Shane Smiskol <shane@smiskol.com> Date: Wed Mar 23 20:51:23 2022 -0700 override state testing * clean up old-commit-hash: 2624b4cb27f7f2bd184bac5dd7b2c718767da583
2022-04-05 09:02:27 +08:00
self.state = State.overriding
else:
self.state = State.enabled
self.current_alert_types.append(ET.ENABLE)
self.v_cruise_helper.initialize_v_cruise(CS, self.experimental_mode)
# Check if openpilot is engaged and actuators are enabled
self.enabled = self.state in ENABLED_STATES
self.active = self.state in ACTIVE_STATES
if self.active:
self.current_alert_types.append(ET.WARNING)
def state_control(self, CS):
"""Given the state, this function returns a CarControl packet"""
# Update VehicleModel
lp = self.sm['liveParameters']
x = max(lp.stiffnessFactor, 0.1)
sr = max(lp.steerRatio, 0.1)
self.VM.update_params(x, sr)
Live torque (#25456) * wip torqued * add basic logic * setup in manager * check sanity and publish msg * add first order filter to outputs * wire up controlsd, and update gains * rename intercept to offset * add cloudlog, live values are not updated * fix bugs, do not reset points for now * fix crashes * rename to main * fix bugs, works offline * fix float in cereal bug * add latacc filter * randomly choose points, approx for iid * add variable decay * local param to capnp instead of dict * verify works in replay * use torqued output in controlsd * use in controlsd; use points from past routes * controlsd bugfix * filter before updating gains, needs to be replaced * save all points to ensure smooth transition across routes, revert friction factor to 1.5 * add filters to prevent noisy low-speed data points; improve fit sanity * add engaged buffer * revert lat_acc thresh * use paramsd realtime process config * make latacc-to-torque generic, and overrideable * move freq to 4Hz, avoid storing in np.array, don't publish points in the message * float instead of np * remove constant while storing pts * rename slope, offset to lat_accet_factor, offset * resolve issues * use camelcase in all capnp params * use camelcase everywhere * reduce latacc threshold or sanity, add car_sane todo, save points properly * add and check tag * write param to disk at end of route * remove args * rebase op, cereal * save on exit * restore default handler * cpu usage check * add to process replay * handle reset better, reduce unnecessary computation * always publish raw values - useful for debug * regen routes * update refs * checks on cache restore * check tuning vals too * clean that up * reduce cpu usage * reduce cpu usage by 75% * cleanup * optimize further * handle reset condition better, don't put points in init, use only in corolla * bump cereal after rebasing * update refs * Update common/params.cc Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * remove unnecessary checks * Update RELEASES.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 4fa62f146426f76c9c1c2867d9729b33ec612b59
2022-09-20 06:19:26 +08:00
# Update Torque Params
if self.CP.lateralTuning.which() == 'torque':
torque_params = self.sm['liveTorqueParameters']
if self.sm.all_checks(['liveTorqueParameters']) and torque_params.useParams:
self.LaC.update_live_torque_params(torque_params.latAccelFactorFiltered, torque_params.latAccelOffsetFiltered,
torque_params.frictionCoefficientFiltered)
Live torque (#25456) * wip torqued * add basic logic * setup in manager * check sanity and publish msg * add first order filter to outputs * wire up controlsd, and update gains * rename intercept to offset * add cloudlog, live values are not updated * fix bugs, do not reset points for now * fix crashes * rename to main * fix bugs, works offline * fix float in cereal bug * add latacc filter * randomly choose points, approx for iid * add variable decay * local param to capnp instead of dict * verify works in replay * use torqued output in controlsd * use in controlsd; use points from past routes * controlsd bugfix * filter before updating gains, needs to be replaced * save all points to ensure smooth transition across routes, revert friction factor to 1.5 * add filters to prevent noisy low-speed data points; improve fit sanity * add engaged buffer * revert lat_acc thresh * use paramsd realtime process config * make latacc-to-torque generic, and overrideable * move freq to 4Hz, avoid storing in np.array, don't publish points in the message * float instead of np * remove constant while storing pts * rename slope, offset to lat_accet_factor, offset * resolve issues * use camelcase in all capnp params * use camelcase everywhere * reduce latacc threshold or sanity, add car_sane todo, save points properly * add and check tag * write param to disk at end of route * remove args * rebase op, cereal * save on exit * restore default handler * cpu usage check * add to process replay * handle reset better, reduce unnecessary computation * always publish raw values - useful for debug * regen routes * update refs * checks on cache restore * check tuning vals too * clean that up * reduce cpu usage * reduce cpu usage by 75% * cleanup * optimize further * handle reset condition better, don't put points in init, use only in corolla * bump cereal after rebasing * update refs * Update common/params.cc Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * remove unnecessary checks * Update RELEASES.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 4fa62f146426f76c9c1c2867d9729b33ec612b59
2022-09-20 06:19:26 +08:00
long_plan = self.sm['longitudinalPlan']
model_v2 = self.sm['modelV2']
CC = car.CarControl.new_message()
CC.enabled = self.enabled
# Check which actuators can be enabled
standstill = CS.vEgo <= max(self.CP.minSteerSpeed, MIN_LATERAL_CONTROL_SPEED) or CS.standstill
CC.latActive = self.active and not CS.steerFaultTemporary and not CS.steerFaultPermanent and \
(not standstill or self.joystick_mode)
CC.longActive = self.enabled and not self.events.contains(ET.OVERRIDE_LONGITUDINAL) and self.CP.openpilotLongitudinalControl
actuators = CC.actuators
actuators.longControlState = self.LoC.long_control_state
# Enable blinkers while lane changing
if model_v2.meta.laneChangeState != LaneChangeState.off:
CC.leftBlinker = model_v2.meta.laneChangeDirection == LaneChangeDirection.left
CC.rightBlinker = model_v2.meta.laneChangeDirection == LaneChangeDirection.right
if CS.leftBlinker or CS.rightBlinker:
self.last_blinker_frame = self.sm.frame
# State specific actions
if not CC.latActive:
self.LaC.reset()
if not CC.longActive:
self.LoC.reset(v_pid=CS.vEgo)
Fixup joystick (#21129) * some common changes * rename to joystick * add alert and update controlsd to work with joystick * update joystickd * Update Joystick readme * assume we have inputs * only send gb or steer when engaged_toggle is true * Update instructions * fix --ip * Easier to understand at a glance * much better * -a * receive events and send msg in same loop * always import * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * combine logic and clean up * use argparse * outdated, and use normal class * rm * bit of a refactor * refactor part 2 / 3 * much better (3 / 3) * Simplify * bump cereal and update readme * capitalize * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * make joystick abstraction class clearer * use interp, clearer without comments * no need to use apply_deadzone * more explicit * define btns and axes once * split function by use_keyboard again, but simpler * we can use handle_button as a reset function * need to flip sign * remove * invert axes map for kb, easier to read the button mapping * apply changes from review * new lateral log for debug mode * bump * add saturated * static alert * joystick_mode * conditionally subscribe * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * move params instantiation * Spoof active and enabled * Only allow car to engage * no startup alert if joystick * Update controlsd.py * Should be orange not enabled, green enabled * no more button states * should work * blue * submaster conflates, so only send when we have an update * final change * remove msg * clean up a bit sort of clean up clean up a bit remove msg * this was right * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * lowercase * suggestions from code review * forgot laptop * bump to latest * fixes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> old-commit-hash: ae77f693a26527ffbee044f852cc4185718c2433
2021-06-12 05:33:17 +08:00
if not self.joystick_mode:
# accel PID loop
pid_accel_limits = self.CI.get_pid_accel_limits(self.CP, CS.vEgo, self.v_cruise_helper.v_cruise_kph * CV.KPH_TO_MS)
t_since_plan = (self.sm.frame - self.sm.recv_frame['longitudinalPlan']) * DT_CTRL
actuators.accel = self.LoC.update(CC.longActive, CS, long_plan, pid_accel_limits, t_since_plan)
Fixup joystick (#21129) * some common changes * rename to joystick * add alert and update controlsd to work with joystick * update joystickd * Update Joystick readme * assume we have inputs * only send gb or steer when engaged_toggle is true * Update instructions * fix --ip * Easier to understand at a glance * much better * -a * receive events and send msg in same loop * always import * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * combine logic and clean up * use argparse * outdated, and use normal class * rm * bit of a refactor * refactor part 2 / 3 * much better (3 / 3) * Simplify * bump cereal and update readme * capitalize * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * make joystick abstraction class clearer * use interp, clearer without comments * no need to use apply_deadzone * more explicit * define btns and axes once * split function by use_keyboard again, but simpler * we can use handle_button as a reset function * need to flip sign * remove * invert axes map for kb, easier to read the button mapping * apply changes from review * new lateral log for debug mode * bump * add saturated * static alert * joystick_mode * conditionally subscribe * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * move params instantiation * Spoof active and enabled * Only allow car to engage * no startup alert if joystick * Update controlsd.py * Should be orange not enabled, green enabled * no more button states * should work * blue * submaster conflates, so only send when we have an update * final change * remove msg * clean up a bit sort of clean up clean up a bit remove msg * this was right * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * lowercase * suggestions from code review * forgot laptop * bump to latest * fixes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> old-commit-hash: ae77f693a26527ffbee044f852cc4185718c2433
2021-06-12 05:33:17 +08:00
# Steering PID loop and lateral MPC
self.desired_curvature = clip_curvature(CS.vEgo, self.desired_curvature, model_v2.action.desiredCurvature)
actuators.curvature = self.desired_curvature
actuators.steer, actuators.steeringAngleDeg, lac_log = self.LaC.update(CC.latActive, CS, self.VM, lp,
self.steer_limited, self.desired_curvature,
self.sm['liveLocationKalman'])
Fixup joystick (#21129) * some common changes * rename to joystick * add alert and update controlsd to work with joystick * update joystickd * Update Joystick readme * assume we have inputs * only send gb or steer when engaged_toggle is true * Update instructions * fix --ip * Easier to understand at a glance * much better * -a * receive events and send msg in same loop * always import * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * combine logic and clean up * use argparse * outdated, and use normal class * rm * bit of a refactor * refactor part 2 / 3 * much better (3 / 3) * Simplify * bump cereal and update readme * capitalize * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * make joystick abstraction class clearer * use interp, clearer without comments * no need to use apply_deadzone * more explicit * define btns and axes once * split function by use_keyboard again, but simpler * we can use handle_button as a reset function * need to flip sign * remove * invert axes map for kb, easier to read the button mapping * apply changes from review * new lateral log for debug mode * bump * add saturated * static alert * joystick_mode * conditionally subscribe * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * move params instantiation * Spoof active and enabled * Only allow car to engage * no startup alert if joystick * Update controlsd.py * Should be orange not enabled, green enabled * no more button states * should work * blue * submaster conflates, so only send when we have an update * final change * remove msg * clean up a bit sort of clean up clean up a bit remove msg * this was right * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * lowercase * suggestions from code review * forgot laptop * bump to latest * fixes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> old-commit-hash: ae77f693a26527ffbee044f852cc4185718c2433
2021-06-12 05:33:17 +08:00
else:
lac_log = log.ControlsState.LateralDebugState.new_message()
if self.sm.recv_frame['testJoystick'] > 0:
# reset joystick if it hasn't been received in a while
should_reset_joystick = (self.sm.frame - self.sm.recv_frame['testJoystick'])*DT_CTRL > 0.2
if not should_reset_joystick:
joystick_axes = self.sm['testJoystick'].axes
else:
joystick_axes = [0.0, 0.0]
if CC.longActive:
actuators.accel = 4.0*clip(joystick_axes[0], -1, 1)
Fixup joystick (#21129) * some common changes * rename to joystick * add alert and update controlsd to work with joystick * update joystickd * Update Joystick readme * assume we have inputs * only send gb or steer when engaged_toggle is true * Update instructions * fix --ip * Easier to understand at a glance * much better * -a * receive events and send msg in same loop * always import * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * combine logic and clean up * use argparse * outdated, and use normal class * rm * bit of a refactor * refactor part 2 / 3 * much better (3 / 3) * Simplify * bump cereal and update readme * capitalize * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * make joystick abstraction class clearer * use interp, clearer without comments * no need to use apply_deadzone * more explicit * define btns and axes once * split function by use_keyboard again, but simpler * we can use handle_button as a reset function * need to flip sign * remove * invert axes map for kb, easier to read the button mapping * apply changes from review * new lateral log for debug mode * bump * add saturated * static alert * joystick_mode * conditionally subscribe * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * move params instantiation * Spoof active and enabled * Only allow car to engage * no startup alert if joystick * Update controlsd.py * Should be orange not enabled, green enabled * no more button states * should work * blue * submaster conflates, so only send when we have an update * final change * remove msg * clean up a bit sort of clean up clean up a bit remove msg * this was right * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * lowercase * suggestions from code review * forgot laptop * bump to latest * fixes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> old-commit-hash: ae77f693a26527ffbee044f852cc4185718c2433
2021-06-12 05:33:17 +08:00
if CC.latActive:
steer = clip(joystick_axes[1], -1, 1)
# max angle is 45 for angle-based cars, max curvature is 0.02
actuators.steer, actuators.steeringAngleDeg, actuators.curvature = steer, steer * 90., steer * -0.02
Fixup joystick (#21129) * some common changes * rename to joystick * add alert and update controlsd to work with joystick * update joystickd * Update Joystick readme * assume we have inputs * only send gb or steer when engaged_toggle is true * Update instructions * fix --ip * Easier to understand at a glance * much better * -a * receive events and send msg in same loop * always import * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * combine logic and clean up * use argparse * outdated, and use normal class * rm * bit of a refactor * refactor part 2 / 3 * much better (3 / 3) * Simplify * bump cereal and update readme * capitalize * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * make joystick abstraction class clearer * use interp, clearer without comments * no need to use apply_deadzone * more explicit * define btns and axes once * split function by use_keyboard again, but simpler * we can use handle_button as a reset function * need to flip sign * remove * invert axes map for kb, easier to read the button mapping * apply changes from review * new lateral log for debug mode * bump * add saturated * static alert * joystick_mode * conditionally subscribe * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * move params instantiation * Spoof active and enabled * Only allow car to engage * no startup alert if joystick * Update controlsd.py * Should be orange not enabled, green enabled * no more button states * should work * blue * submaster conflates, so only send when we have an update * final change * remove msg * clean up a bit sort of clean up clean up a bit remove msg * this was right * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * lowercase * suggestions from code review * forgot laptop * bump to latest * fixes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> old-commit-hash: ae77f693a26527ffbee044f852cc4185718c2433
2021-06-12 05:33:17 +08:00
lac_log.active = self.active
Fixup joystick (#21129) * some common changes * rename to joystick * add alert and update controlsd to work with joystick * update joystickd * Update Joystick readme * assume we have inputs * only send gb or steer when engaged_toggle is true * Update instructions * fix --ip * Easier to understand at a glance * much better * -a * receive events and send msg in same loop * always import * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * combine logic and clean up * use argparse * outdated, and use normal class * rm * bit of a refactor * refactor part 2 / 3 * much better (3 / 3) * Simplify * bump cereal and update readme * capitalize * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * make joystick abstraction class clearer * use interp, clearer without comments * no need to use apply_deadzone * more explicit * define btns and axes once * split function by use_keyboard again, but simpler * we can use handle_button as a reset function * need to flip sign * remove * invert axes map for kb, easier to read the button mapping * apply changes from review * new lateral log for debug mode * bump * add saturated * static alert * joystick_mode * conditionally subscribe * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * move params instantiation * Spoof active and enabled * Only allow car to engage * no startup alert if joystick * Update controlsd.py * Should be orange not enabled, green enabled * no more button states * should work * blue * submaster conflates, so only send when we have an update * final change * remove msg * clean up a bit sort of clean up clean up a bit remove msg * this was right * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * lowercase * suggestions from code review * forgot laptop * bump to latest * fixes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> old-commit-hash: ae77f693a26527ffbee044f852cc4185718c2433
2021-06-12 05:33:17 +08:00
lac_log.steeringAngleDeg = CS.steeringAngleDeg
lac_log.output = actuators.steer
lac_log.saturated = abs(actuators.steer) >= 0.9
if CS.steeringPressed:
self.last_steering_pressed_frame = self.sm.frame
recent_steer_pressed = (self.sm.frame - self.last_steering_pressed_frame)*DT_CTRL < 2.0
# Send a "steering required alert" if saturation count has reached the limit
if lac_log.active and not recent_steer_pressed and not self.CP.notCar:
if self.CP.lateralTuning.which() == 'torque' and not self.joystick_mode:
undershooting = abs(lac_log.desiredLateralAccel) / abs(1e-3 + lac_log.actualLateralAccel) > 1.2
turning = abs(lac_log.desiredLateralAccel) > 1.0
good_speed = CS.vEgo > 5
max_torque = abs(self.last_actuators.steer) > 0.99
if undershooting and turning and good_speed and max_torque:
lac_log.active and self.events.add(EventName.steerSaturated)
elif lac_log.saturated:
# TODO probably should not use dpath_points but curvature
dpath_points = model_v2.position.y
if len(dpath_points):
# Check if we deviated from the path
# TODO use desired vs actual curvature
if self.CP.steerControlType == car.CarParams.SteerControlType.angle:
steering_value = actuators.steeringAngleDeg
else:
steering_value = actuators.steer
left_deviation = steering_value > 0 and dpath_points[0] < -0.20
right_deviation = steering_value < 0 and dpath_points[0] > 0.20
if left_deviation or right_deviation:
self.events.add(EventName.steerSaturated)
# Ensure no NaNs/Infs
for p in ACTUATOR_FIELDS:
attr = getattr(actuators, p)
if not isinstance(attr, SupportsFloat):
continue
if not math.isfinite(attr):
cloudlog.error(f"actuators.{p} not finite {actuators.to_dict()}")
setattr(actuators, p, 0.0)
longitudinal personality: change via steering wheel distance button (#31792) * start at param * start by sending personality * change to personality * POC: button changes personality * what's wrong with this? * fix * not really possible but fuzzy test catches this * there's always a typo * dang, we're dropping messages * clean up * no comment * bump * rename * not all cars yet * works but at what cost * clean up * inside settings * write param so we save the distance button changes * setChecked activates buttonToggled and already writes param! * don't need this, we update from longitudinalPlan on changes * some clean up * more * ui * allow some time for ui to receive and write param * plannerd: only track changes in case no ui * Revert "plannerd: only track changes in case no ui" This reverts commit 2b081aa6ceb92c67a621b74592b2292756d29871. * write in plannerd as well, I assume this is atomic? * don't write when setting checked (only user clicks) * better nane * more * Update selfdrive/controls/lib/longitudinal_planner.py Co-authored-by: Cameron Clough <cameronjclough@gmail.com> * doesn't write param now * ParamWatcher is nice * no debug * Update translations * fix * odd drain sock proc replay behavior * vanish * Revert "odd drain sock proc replay behavior" This reverts commit 29b70b39413e1852bb512155af6b6a94a5bd9454. * add GM * only if OP long * move personality to controlsState, since eventually it won't be exclusive to long planner more bump * diff without translations * fix * put nonblocking * CS should start at up to date personality always (no ui flicker) * update toggle on cereal message change * fix * fix that * ubmp * mypy doesn't know this is an int :( * update translations * fix the tests --------- Co-authored-by: Cameron Clough <cameronjclough@gmail.com> old-commit-hash: 3d63c7093afec7ba24f447a44f02f7bea1f7282b
2024-03-13 16:05:02 +08:00
# decrement personality on distance button press
if self.CP.openpilotLongitudinalControl:
if any(not be.pressed and be.type == ButtonType.gapAdjustCruise for be in CS.buttonEvents):
self.personality = (self.personality - 1) % 3
self.params.put_nonblocking('LongitudinalPersonality', str(self.personality))
return CC, lac_log
def publish_logs(self, CS, start_time, CC, lac_log):
"""Send actuators and hud commands to the car, send controlsstate and MPC logging"""
CO = self.sm['carOutput']
# Orientation and angle rates can be useful for carcontroller
# Only calibrated (car) frame is relevant for the carcontroller
orientation_value = list(self.sm['liveLocationKalman'].calibratedOrientationNED.value)
if len(orientation_value) > 2:
CC.orientationNED = orientation_value
angular_rate_value = list(self.sm['liveLocationKalman'].angularVelocityCalibrated.value)
if len(angular_rate_value) > 2:
CC.angularVelocity = angular_rate_value
CC.cruiseControl.override = self.enabled and not CC.longActive and self.CP.openpilotLongitudinalControl
CC.cruiseControl.cancel = CS.cruiseState.enabled and (not self.enabled or not self.CP.pcmCruise)
if self.joystick_mode and self.sm.recv_frame['testJoystick'] > 0 and self.sm['testJoystick'].buttons[0]:
Fixup joystick (#21129) * some common changes * rename to joystick * add alert and update controlsd to work with joystick * update joystickd * Update Joystick readme * assume we have inputs * only send gb or steer when engaged_toggle is true * Update instructions * fix --ip * Easier to understand at a glance * much better * -a * receive events and send msg in same loop * always import * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * combine logic and clean up * use argparse * outdated, and use normal class * rm * bit of a refactor * refactor part 2 / 3 * much better (3 / 3) * Simplify * bump cereal and update readme * capitalize * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * make joystick abstraction class clearer * use interp, clearer without comments * no need to use apply_deadzone * more explicit * define btns and axes once * split function by use_keyboard again, but simpler * we can use handle_button as a reset function * need to flip sign * remove * invert axes map for kb, easier to read the button mapping * apply changes from review * new lateral log for debug mode * bump * add saturated * static alert * joystick_mode * conditionally subscribe * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * move params instantiation * Spoof active and enabled * Only allow car to engage * no startup alert if joystick * Update controlsd.py * Should be orange not enabled, green enabled * no more button states * should work * blue * submaster conflates, so only send when we have an update * final change * remove msg * clean up a bit sort of clean up clean up a bit remove msg * this was right * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * lowercase * suggestions from code review * forgot laptop * bump to latest * fixes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> old-commit-hash: ae77f693a26527ffbee044f852cc4185718c2433
2021-06-12 05:33:17 +08:00
CC.cruiseControl.cancel = True
speeds = self.sm['longitudinalPlan'].speeds
if len(speeds):
CC.cruiseControl.resume = self.enabled and CS.cruiseState.standstill and speeds[-1] > 0.1
hudControl = CC.hudControl
hudControl.setSpeed = float(self.v_cruise_helper.v_cruise_cluster_kph * CV.KPH_TO_MS)
hudControl.speedVisible = self.enabled
hudControl.lanesVisible = self.enabled
hudControl.leadVisible = self.sm['longitudinalPlan'].hasLead
Move personality to controlsState (#31855) * start at param * start by sending personality * change to personality * POC: button changes personality * what's wrong with this? * fix * not really possible but fuzzy test catches this * there's always a typo * dang, we're dropping messages * clean up * no comment * bump * rename * not all cars yet * works but at what cost * clean up * inside settings * write param so we save the distance button changes * setChecked activates buttonToggled and already writes param! * don't need this, we update from longitudinalPlan on changes * some clean up * more * ui * allow some time for ui to receive and write param * plannerd: only track changes in case no ui * Revert "plannerd: only track changes in case no ui" This reverts commit 2b081aa6ceb92c67a621b74592b2292756d29871. * write in plannerd as well, I assume this is atomic? * don't write when setting checked (only user clicks) * better nane * more * Update selfdrive/controls/lib/longitudinal_planner.py Co-authored-by: Cameron Clough <cameronjclough@gmail.com> * doesn't write param now * ParamWatcher is nice * no debug * Update translations * fix * odd drain sock proc replay behavior * vanish * Revert "odd drain sock proc replay behavior" This reverts commit 29b70b39413e1852bb512155af6b6a94a5bd9454. * add GM * only if OP long * move personality to controlsState, since eventually it won't be exclusive to long planner more bump * diff without translations * fix * put nonblocking * CS should start at up to date personality always (no ui flicker) * update toggle on cereal message change * fix * fix that * ubmp * mypy doesn't know this is an int :( * update translations * fix the tests * revert ui * not here * migrate controlsState * Revert "migrate controlsState" - i see no reason we need to test with any specific personality This reverts commit 6063508f2df1a5623f113cda34dcd59a1f4b2ac9. * Update ref_commit --------- Co-authored-by: Cameron Clough <cameronjclough@gmail.com> old-commit-hash: 29e55f99a54d95215aa79ecf94a22363f82913a6
2024-03-13 15:57:57 +08:00
hudControl.leadDistanceBars = self.personality + 1
hudControl.rightLaneVisible = True
hudControl.leftLaneVisible = True
recent_blinker = (self.sm.frame - self.last_blinker_frame) * DT_CTRL < 5.0 # 5s blinker cooldown
ldw_allowed = self.is_ldw_enabled and CS.vEgo > LDW_MIN_SPEED and not recent_blinker \
and not CC.latActive and self.sm['liveCalibration'].calStatus == log.LiveCalibrationData.Status.calibrated
model_v2 = self.sm['modelV2']
desire_prediction = model_v2.meta.desirePrediction
if len(desire_prediction) and ldw_allowed:
right_lane_visible = model_v2.laneLineProbs[2] > 0.5
left_lane_visible = model_v2.laneLineProbs[1] > 0.5
l_lane_change_prob = desire_prediction[Desire.laneChangeLeft]
r_lane_change_prob = desire_prediction[Desire.laneChangeRight]
lane_lines = model_v2.laneLines
l_lane_close = left_lane_visible and (lane_lines[1].y[0] > -(1.08 + CAMERA_OFFSET))
r_lane_close = right_lane_visible and (lane_lines[2].y[0] < (1.08 - CAMERA_OFFSET))
hudControl.leftLaneDepart = bool(l_lane_change_prob > LANE_DEPARTURE_THRESHOLD and l_lane_close)
hudControl.rightLaneDepart = bool(r_lane_change_prob > LANE_DEPARTURE_THRESHOLD and r_lane_close)
if hudControl.rightLaneDepart or hudControl.leftLaneDepart:
self.events.add(EventName.ldw)
clear_event_types = set()
if ET.WARNING not in self.current_alert_types:
clear_event_types.add(ET.WARNING)
if self.enabled:
clear_event_types.add(ET.NO_ENTRY)
alerts = self.events.create_alerts(self.current_alert_types, [self.CP, CS, self.sm, self.is_metric, self.soft_disable_timer])
self.AM.add_many(self.sm.frame, alerts)
current_alert = self.AM.process_alerts(self.sm.frame, clear_event_types)
if current_alert:
hudControl.visualAlert = current_alert.visual_alert
if not self.CP.passive and self.initialized:
self.card.controls_update(CC)
self.last_actuators = CO.actuatorsOutput
if self.CP.steerControlType == car.CarParams.SteerControlType.angle:
self.steer_limited = abs(CC.actuators.steeringAngleDeg - CO.actuatorsOutput.steeringAngleDeg) > \
STEER_ANGLE_SATURATION_THRESHOLD
else:
self.steer_limited = abs(CC.actuators.steer - CO.actuatorsOutput.steer) > 1e-2
force_decel = (self.sm['driverMonitoringState'].awarenessStatus < 0.) or \
(self.state == State.softDisabling)
# Curvature & Steering angle
lp = self.sm['liveParameters']
steer_angle_without_offset = math.radians(CS.steeringAngleDeg - lp.angleOffsetDeg)
curvature = -self.VM.calc_curvature(steer_angle_without_offset, CS.vEgo, lp.roll)
# controlsState
dat = messaging.new_message('controlsState')
dat.valid = CS.canValid
controlsState = dat.controlsState
if current_alert:
controlsState.alertText1 = current_alert.alert_text_1
controlsState.alertText2 = current_alert.alert_text_2
controlsState.alertSize = current_alert.alert_size
controlsState.alertStatus = current_alert.alert_status
controlsState.alertBlinkingRate = current_alert.alert_rate
controlsState.alertType = current_alert.alert_type
controlsState.alertSound = current_alert.audible_alert
controlsState.longitudinalPlanMonoTime = self.sm.logMonoTime['longitudinalPlan']
controlsState.lateralPlanMonoTime = self.sm.logMonoTime['modelV2']
controlsState.enabled = self.enabled
controlsState.active = self.active
controlsState.curvature = curvature
controlsState.desiredCurvature = self.desired_curvature
controlsState.state = self.state
controlsState.engageable = not self.events.contains(ET.NO_ENTRY)
controlsState.longControlState = self.LoC.long_control_state
controlsState.vPid = float(self.LoC.v_pid)
controlsState.vCruise = float(self.v_cruise_helper.v_cruise_kph)
controlsState.vCruiseCluster = float(self.v_cruise_helper.v_cruise_cluster_kph)
controlsState.upAccelCmd = float(self.LoC.pid.p)
controlsState.uiAccelCmd = float(self.LoC.pid.i)
controlsState.ufAccelCmd = float(self.LoC.pid.f)
controlsState.cumLagMs = -self.rk.remaining * 1000.
controlsState.startMonoTime = int(start_time * 1e9)
controlsState.forceDecel = bool(force_decel)
controlsState.canErrorCounter = self.card.can_rcv_cum_timeout_counter
controlsState.experimentalMode = self.experimental_mode
Move personality to controlsState (#31855) * start at param * start by sending personality * change to personality * POC: button changes personality * what's wrong with this? * fix * not really possible but fuzzy test catches this * there's always a typo * dang, we're dropping messages * clean up * no comment * bump * rename * not all cars yet * works but at what cost * clean up * inside settings * write param so we save the distance button changes * setChecked activates buttonToggled and already writes param! * don't need this, we update from longitudinalPlan on changes * some clean up * more * ui * allow some time for ui to receive and write param * plannerd: only track changes in case no ui * Revert "plannerd: only track changes in case no ui" This reverts commit 2b081aa6ceb92c67a621b74592b2292756d29871. * write in plannerd as well, I assume this is atomic? * don't write when setting checked (only user clicks) * better nane * more * Update selfdrive/controls/lib/longitudinal_planner.py Co-authored-by: Cameron Clough <cameronjclough@gmail.com> * doesn't write param now * ParamWatcher is nice * no debug * Update translations * fix * odd drain sock proc replay behavior * vanish * Revert "odd drain sock proc replay behavior" This reverts commit 29b70b39413e1852bb512155af6b6a94a5bd9454. * add GM * only if OP long * move personality to controlsState, since eventually it won't be exclusive to long planner more bump * diff without translations * fix * put nonblocking * CS should start at up to date personality always (no ui flicker) * update toggle on cereal message change * fix * fix that * ubmp * mypy doesn't know this is an int :( * update translations * fix the tests * revert ui * not here * migrate controlsState * Revert "migrate controlsState" - i see no reason we need to test with any specific personality This reverts commit 6063508f2df1a5623f113cda34dcd59a1f4b2ac9. * Update ref_commit --------- Co-authored-by: Cameron Clough <cameronjclough@gmail.com> old-commit-hash: 29e55f99a54d95215aa79ecf94a22363f82913a6
2024-03-13 15:57:57 +08:00
controlsState.personality = self.personality
lat_tuning = self.CP.lateralTuning.which()
Fixup joystick (#21129) * some common changes * rename to joystick * add alert and update controlsd to work with joystick * update joystickd * Update Joystick readme * assume we have inputs * only send gb or steer when engaged_toggle is true * Update instructions * fix --ip * Easier to understand at a glance * much better * -a * receive events and send msg in same loop * always import * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/controls/lib/events.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * combine logic and clean up * use argparse * outdated, and use normal class * rm * bit of a refactor * refactor part 2 / 3 * much better (3 / 3) * Simplify * bump cereal and update readme * capitalize * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/joystick/joystickd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * make joystick abstraction class clearer * use interp, clearer without comments * no need to use apply_deadzone * more explicit * define btns and axes once * split function by use_keyboard again, but simpler * we can use handle_button as a reset function * need to flip sign * remove * invert axes map for kb, easier to read the button mapping * apply changes from review * new lateral log for debug mode * bump * add saturated * static alert * joystick_mode * conditionally subscribe * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * move params instantiation * Spoof active and enabled * Only allow car to engage * no startup alert if joystick * Update controlsd.py * Should be orange not enabled, green enabled * no more button states * should work * blue * submaster conflates, so only send when we have an update * final change * remove msg * clean up a bit sort of clean up clean up a bit remove msg * this was right * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * lowercase * suggestions from code review * forgot laptop * bump to latest * fixes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> old-commit-hash: ae77f693a26527ffbee044f852cc4185718c2433
2021-06-12 05:33:17 +08:00
if self.joystick_mode:
controlsState.lateralControlState.debugState = lac_log
elif self.CP.steerControlType == car.CarParams.SteerControlType.angle:
controlsState.lateralControlState.angleState = lac_log
elif lat_tuning == 'pid':
controlsState.lateralControlState.pidState = lac_log
elif lat_tuning == 'torque':
controlsState.lateralControlState.torqueState = lac_log
self.pm.send('controlsState', dat)
# onroadEvents - logged every second or on change
if (self.sm.frame % int(1. / DT_CTRL) == 0) or (self.events.names != self.events_prev):
ce_send = messaging.new_message('onroadEvents', len(self.events))
ce_send.valid = True
ce_send.onroadEvents = self.events.to_msg()
self.pm.send('onroadEvents', ce_send)
self.events_prev = self.events.names.copy()
# carControl
cc_send = messaging.new_message('carControl')
cc_send.valid = CS.canValid
cc_send.carControl = CC
self.pm.send('carControl', cc_send)
# copy CarControl to pass to CarInterface on the next iteration
self.CC = CC
def step(self):
start_time = time.monotonic()
# Sample data from sockets and get a carState
CS = self.data_sample()
Latency logging 2 (#24058) * msg_order and gantt * frameId in long/lat planner * track frame id * controls frame id * graph tracked events * graph json * cloudlog timestamp * c++ cloudlog * add frame id * bug fixes * bug fixes * frame id visionicp * bug fixes and debug level * timestamp log placement * print timestamps in table * translate events * more logging * bug fixes * daemon boardd * print logs with boardd * more timestamp logs * cleanup * remove publish logs * bug fix * timestamp received * timestamp received * bug fixes * use json lib * ignore driver camera * prep for new timestamp pipeline * bug fix * read new pipeline unfinnished * read new pipeline * bug fix * add frame to controlsstate * remove controlsstate * print * cleanup * more cleanup + bug fix * clock build issue * remove unused imports * format durations * increase speed * pr comments fixes * conflicts * set MANAGER_DAEMON for boardd * clean script code * bug fix + argparse * remove rcv time * bug fixes * print without tabulate * fix pre-commits * plot gnatt * color bug fix * read without timestampextra * bump panda * mono time instead of frame id * finnish script * clean unused * clean unused logging * monotonic + json fixes * del test * remove whilelines * bump laika * cleanup * remove deps * logs nicer strings * remove plotting from scirpt * reset pipfile * reset pipfile * nicer strings * bug fix * bug fix * pr comments cleaning * remove plotting * bug fix * new demo route * bump opendbc and panda * cereal master * cereal master * script less komplex * assertions * matplotlib * readme * Update README.md * graph html * design fixes * more code design * Update common/logging_extra.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * whitespace Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/latency_logger/latency_logger.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * pr comments * bug fix * readme + env once * clean swaglog * bug fix * Update tools/latencylogger/README.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * revert * revert * clean swaglog with error * remove typo file * revert graph * cereal * submodules * whitespaces * update refs Co-authored-by: Bruce Wayne <batman@workstation-openpilot2.internal> Co-authored-by: Comma Device <device@comma.ai> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 65fca83abed98f32993286dc5a66e3e583f06172
2022-04-06 12:05:45 +08:00
cloudlog.timestamp("Data sampled")
self.update_events(CS)
Latency logging 2 (#24058) * msg_order and gantt * frameId in long/lat planner * track frame id * controls frame id * graph tracked events * graph json * cloudlog timestamp * c++ cloudlog * add frame id * bug fixes * bug fixes * frame id visionicp * bug fixes and debug level * timestamp log placement * print timestamps in table * translate events * more logging * bug fixes * daemon boardd * print logs with boardd * more timestamp logs * cleanup * remove publish logs * bug fix * timestamp received * timestamp received * bug fixes * use json lib * ignore driver camera * prep for new timestamp pipeline * bug fix * read new pipeline unfinnished * read new pipeline * bug fix * add frame to controlsstate * remove controlsstate * print * cleanup * more cleanup + bug fix * clock build issue * remove unused imports * format durations * increase speed * pr comments fixes * conflicts * set MANAGER_DAEMON for boardd * clean script code * bug fix + argparse * remove rcv time * bug fixes * print without tabulate * fix pre-commits * plot gnatt * color bug fix * read without timestampextra * bump panda * mono time instead of frame id * finnish script * clean unused * clean unused logging * monotonic + json fixes * del test * remove whilelines * bump laika * cleanup * remove deps * logs nicer strings * remove plotting from scirpt * reset pipfile * reset pipfile * nicer strings * bug fix * bug fix * pr comments cleaning * remove plotting * bug fix * new demo route * bump opendbc and panda * cereal master * cereal master * script less komplex * assertions * matplotlib * readme * Update README.md * graph html * design fixes * more code design * Update common/logging_extra.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * whitespace Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update tools/latency_logger/latency_logger.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * pr comments * bug fix * readme + env once * clean swaglog * bug fix * Update tools/latencylogger/README.md Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * revert * revert * clean swaglog with error * remove typo file * revert graph * cereal * submodules * whitespaces * update refs Co-authored-by: Bruce Wayne <batman@workstation-openpilot2.internal> Co-authored-by: Comma Device <device@comma.ai> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 65fca83abed98f32993286dc5a66e3e583f06172
2022-04-06 12:05:45 +08:00
cloudlog.timestamp("Events updated")
if not self.CP.passive and self.initialized:
# Update control state
self.state_transition(CS)
# Compute actuators (runs PID loops and lateral MPC)
CC, lac_log = self.state_control(CS)
# Publish data
self.publish_logs(CS, start_time, CC, lac_log)
self.CS_prev = CS
Move personality to controlsState (#31855) * start at param * start by sending personality * change to personality * POC: button changes personality * what's wrong with this? * fix * not really possible but fuzzy test catches this * there's always a typo * dang, we're dropping messages * clean up * no comment * bump * rename * not all cars yet * works but at what cost * clean up * inside settings * write param so we save the distance button changes * setChecked activates buttonToggled and already writes param! * don't need this, we update from longitudinalPlan on changes * some clean up * more * ui * allow some time for ui to receive and write param * plannerd: only track changes in case no ui * Revert "plannerd: only track changes in case no ui" This reverts commit 2b081aa6ceb92c67a621b74592b2292756d29871. * write in plannerd as well, I assume this is atomic? * don't write when setting checked (only user clicks) * better nane * more * Update selfdrive/controls/lib/longitudinal_planner.py Co-authored-by: Cameron Clough <cameronjclough@gmail.com> * doesn't write param now * ParamWatcher is nice * no debug * Update translations * fix * odd drain sock proc replay behavior * vanish * Revert "odd drain sock proc replay behavior" This reverts commit 29b70b39413e1852bb512155af6b6a94a5bd9454. * add GM * only if OP long * move personality to controlsState, since eventually it won't be exclusive to long planner more bump * diff without translations * fix * put nonblocking * CS should start at up to date personality always (no ui flicker) * update toggle on cereal message change * fix * fix that * ubmp * mypy doesn't know this is an int :( * update translations * fix the tests * revert ui * not here * migrate controlsState * Revert "migrate controlsState" - i see no reason we need to test with any specific personality This reverts commit 6063508f2df1a5623f113cda34dcd59a1f4b2ac9. * Update ref_commit --------- Co-authored-by: Cameron Clough <cameronjclough@gmail.com> old-commit-hash: 29e55f99a54d95215aa79ecf94a22363f82913a6
2024-03-13 15:57:57 +08:00
def read_personality_param(self):
try:
return int(self.params.get('LongitudinalPersonality'))
except (ValueError, TypeError):
return log.LongitudinalPersonality.standard
def params_thread(self, evt):
while not evt.is_set():
self.is_metric = self.params.get_bool("IsMetric")
self.experimental_mode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl
Move personality to controlsState (#31855) * start at param * start by sending personality * change to personality * POC: button changes personality * what's wrong with this? * fix * not really possible but fuzzy test catches this * there's always a typo * dang, we're dropping messages * clean up * no comment * bump * rename * not all cars yet * works but at what cost * clean up * inside settings * write param so we save the distance button changes * setChecked activates buttonToggled and already writes param! * don't need this, we update from longitudinalPlan on changes * some clean up * more * ui * allow some time for ui to receive and write param * plannerd: only track changes in case no ui * Revert "plannerd: only track changes in case no ui" This reverts commit 2b081aa6ceb92c67a621b74592b2292756d29871. * write in plannerd as well, I assume this is atomic? * don't write when setting checked (only user clicks) * better nane * more * Update selfdrive/controls/lib/longitudinal_planner.py Co-authored-by: Cameron Clough <cameronjclough@gmail.com> * doesn't write param now * ParamWatcher is nice * no debug * Update translations * fix * odd drain sock proc replay behavior * vanish * Revert "odd drain sock proc replay behavior" This reverts commit 29b70b39413e1852bb512155af6b6a94a5bd9454. * add GM * only if OP long * move personality to controlsState, since eventually it won't be exclusive to long planner more bump * diff without translations * fix * put nonblocking * CS should start at up to date personality always (no ui flicker) * update toggle on cereal message change * fix * fix that * ubmp * mypy doesn't know this is an int :( * update translations * fix the tests * revert ui * not here * migrate controlsState * Revert "migrate controlsState" - i see no reason we need to test with any specific personality This reverts commit 6063508f2df1a5623f113cda34dcd59a1f4b2ac9. * Update ref_commit --------- Co-authored-by: Cameron Clough <cameronjclough@gmail.com> old-commit-hash: 29e55f99a54d95215aa79ecf94a22363f82913a6
2024-03-13 15:57:57 +08:00
self.personality = self.read_personality_param()
if self.CP.notCar:
self.joystick_mode = self.params.get_bool("JoystickDebugMode")
time.sleep(0.1)
def controlsd_thread(self):
e = threading.Event()
t = threading.Thread(target=self.params_thread, args=(e, ))
try:
t.start()
while True:
self.step()
self.rk.monitor_time()
except SystemExit:
e.set()
t.join()
def main():
config_realtime_process(4, Priority.CTRL_HIGH)
controls = Controls()
controls.controlsd_thread()
if __name__ == "__main__":
main()