From 20d823d18a70893e2e353cd9b42e6f5ad7b34e8f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 4 Apr 2022 18:02:27 -0700 Subject: [PATCH] controlsState: add override state with grey border (#24030) * Squashed commit of the following: commit f0cf822666fb8f78a486d721fe474e8f37da6970 Author: Shane Smiskol Date: Mon Apr 4 17:24:00 2022 -0700 clean up commit 4364bdb79b1b055daa7542267eb3f37740723fd4 Merge: d448664cf e85f82af3 Author: Shane Smiskol Date: Mon Apr 4 17:21:41 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit d448664cfdacbdfd3c99f8e12d96f2ba7b24abb5 Author: Shane Smiskol Date: Mon Apr 4 17:20:44 2022 -0700 revert tests changes commit 40ab8c2d912ccbeb12286ca272e3737656388ac8 Author: Shane Smiskol Date: Fri Apr 1 19:03:39 2022 -0700 sort commit 5abd4448b420e91eda57e3c4edb6794893dab42f Author: Shane Smiskol Date: Fri Apr 1 19:02:59 2022 -0700 bump cereal commit fcffc42082b1460676554924461c63c881c31501 Author: Shane Smiskol Date: Fri Apr 1 19:02:25 2022 -0700 pass in CI commit f47dd63bc597e18c05d2d9365eb996c13ec70c17 Author: Shane Smiskol Date: Fri Apr 1 12:06:00 2022 -0700 update refs commit f1c54e16ccfa37f770b422ad77e2fc940f8ea7f2 Author: Shane Smiskol Date: Fri Apr 1 11:51:04 2022 -0700 move to tuple commit bebafc6ed223a67e59daa7c2105f8cb28c4f9c5f Merge: b0578dc54 0e983562d Author: Shane Smiskol Date: Fri Apr 1 11:45:19 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit b0578dc54f9d943e0ab2182b0b79d076129468a7 Author: Shane Smiskol 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 Date: Thu Mar 31 23:41:41 2022 -0700 test individual event types fix commit 1fbf66fc8ba7e5a0a25d34a1f30a2cb3ccb86a02 Author: Shane Smiskol Date: Thu Mar 31 23:03:09 2022 -0700 clean up test state machine test state machine commit 33856bef69b1c2e637e58032b1358f275a6cd6bb Author: Shane Smiskol Date: Thu Mar 31 22:59:05 2022 -0700 clean up commit d64cd664980edd6cff0038379a5c3965409ebda0 Author: Shane Smiskol Date: Thu Mar 31 22:40:25 2022 -0700 test few more things commit 72a3e57a9a8813b348a8ae9648e283983f7ba56b Author: Shane Smiskol Date: Thu Mar 31 22:17:22 2022 -0700 default transitions commit ce0051fde8296dab6417d9ef175fdf039d09a8f3 Author: Shane Smiskol Date: Thu Mar 31 22:05:21 2022 -0700 remove commit 56de4f8a87e9b96dd99739772da1dddaa873ceb1 Author: Shane Smiskol Date: Thu Mar 31 22:05:15 2022 -0700 this way we can test any combo of event types commit bdfd47738e5a3c0e22817047cc2d804ca0fe2785 Author: Shane Smiskol Date: Thu Mar 31 21:36:33 2022 -0700 add some state machine tests commit 81a72d1773b204cc984fb0631ac30fb00555962d Author: Shane Smiskol Date: Thu Mar 31 17:43:03 2022 -0700 update refs commit 00018708714b156c29f963011a6193fa9028b308 Merge: fa97ffa67 fa934d846 Author: Shane Smiskol Date: Thu Mar 31 17:31:51 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit fa97ffa67eec1556b2b255ee68bdf46fc101596e Author: Shane Smiskol Date: Thu Mar 31 17:30:23 2022 -0700 revert todo commit b0dcd49b0b0254a4754ddc5ea61618246686327d Author: Shane Smiskol Date: Wed Mar 30 00:07:11 2022 -0700 move back commit ef12853ceed8c8aa37b16af406e510d172269226 Author: Shane Smiskol Date: Tue Mar 29 23:09:05 2022 -0700 bump cereal commit 2658f557e2fac79563b74385b8676a659f31f7dc Author: Shane Smiskol Date: Mon Mar 28 20:54:48 2022 -0700 fix commit ed2db85acd34cd78017c6bae0db5df3356c2c19c Author: Shane Smiskol Date: Mon Mar 28 20:47:18 2022 -0700 add alert to pass unit tests commit dc970f55f5f69ecbca7095099bd50ff21ba02610 Author: Shane Smiskol Date: Mon Mar 28 20:26:18 2022 -0700 bump commit e9a3c73d61590120cc5e5c16a3d1a0bbbd51e19d Author: Shane Smiskol Date: Mon Mar 28 20:25:33 2022 -0700 normal commit 4ecfbf18d5e6436f9be6bd3b1c4ea3bca8c1a572 Merge: 47e0ad3cb 02b968ed9 Author: Shane Smiskol Date: Mon Mar 28 20:14:08 2022 -0700 Merge remote-tracking branch 'upstream/master' into override-alert-type commit 47e0ad3cbe4fee81b7a6e4c284973c25b144ddf7 Author: Shane Smiskol Date: Thu Mar 24 10:50:34 2022 -0700 only rename commit 8c46435630c1bfba5c5b911bc1d3c8d4b24c9fdd Author: Shane Smiskol Date: Thu Mar 24 10:49:26 2022 -0700 bump cereal commit eb48440843d6a4b09e1f34d8eb2ed4c7f7a8274c Author: Shane Smiskol Date: Thu Mar 24 10:29:49 2022 -0700 fix commit 231afe3e6f211e866216a557f2ec2787760d2607 Author: Shane Smiskol Date: Wed Mar 23 23:57:40 2022 -0700 clean up commit 7a3f49db1bdb58c8ef59a9376306ef1157ba2e57 Author: Shane Smiskol Date: Wed Mar 23 23:57:10 2022 -0700 fix logic commit eab4f8b46e6c22033ac4ae433b6ba94e6a4ff322 Author: Shane Smiskol Date: Wed Mar 23 21:05:05 2022 -0700 clean up commit 51e189a27268364e051c6d9231ae6f181ec7f95b Author: Shane Smiskol Date: Wed Mar 23 20:51:23 2022 -0700 override state testing * clean up old-commit-hash: 2624b4cb27f7f2bd184bac5dd7b2c718767da583 --- selfdrive/controls/controlsd.py | 17 +++++++++++++++-- selfdrive/ui/ui.cc | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index b715d1d4f7..3525e70abb 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -421,7 +421,7 @@ class Controls: self.current_alert_types = [ET.PERMANENT] - # ENABLED, SOFT DISABLING, PRE ENABLING + # 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.any(ET.USER_DISABLE): @@ -440,6 +440,10 @@ class Controls: self.soft_disable_timer = int(SOFT_DISABLE_TIME / DT_CTRL) self.current_alert_types.append(ET.SOFT_DISABLE) + elif self.events.any(ET.OVERRIDE): + self.state = State.overriding + self.current_alert_types.append(ET.OVERRIDE) + # SOFT DISABLING elif self.state == State.softDisabling: if not self.events.any(ET.SOFT_DISABLE): @@ -462,6 +466,13 @@ class Controls: else: self.current_alert_types.append(ET.PRE_ENABLE) + # OVERRIDING + elif self.state == State.overriding: + if not self.events.any(ET.OVERRIDE): + self.state = State.enabled + else: + self.current_alert_types.append(ET.OVERRIDE) + # DISABLED elif self.state == State.disabled: if self.events.any(ET.ENABLE): @@ -471,6 +482,8 @@ class Controls: else: if self.events.any(ET.PRE_ENABLE): self.state = State.preEnabled + elif self.events.any(ET.OVERRIDE): + self.state = State.overriding else: self.state = State.enabled self.current_alert_types.append(ET.ENABLE) @@ -500,7 +513,7 @@ class Controls: # Check which actuators can be enabled CC.latActive = self.active and not CS.steerFaultTemporary and not CS.steerFaultPermanent and \ CS.vEgo > self.CP.minSteerSpeed and not CS.standstill - CC.longActive = self.active + CC.longActive = self.active and self.state != State.overriding actuators = CC.actuators actuators.longControlState = self.LoC.long_control_state diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 5eb1f9194c..96cd65af79 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -203,7 +203,7 @@ void UIState::updateStatus() { status = STATUS_WARNING; } else if (alert_status == cereal::ControlsState::AlertStatus::CRITICAL) { status = STATUS_ALERT; - } else if (state == cereal::ControlsState::OpenpilotState::PRE_ENABLED) { + } else if (state == cereal::ControlsState::OpenpilotState::PRE_ENABLED || state == cereal::ControlsState::OpenpilotState::OVERRIDING) { status = STATUS_OVERRIDE; } else { status = controls_state.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED;