Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

safety: add longitudinal pre-enable state for brake at a standstill #1123

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
95a5148
disallow longitudinal at a stop with brake held
sshane Oct 28, 2022
8563b63
comment
sshane Oct 28, 2022
b4b89dc
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Nov 29, 2022
f66a28f
stash what we got so far
sshane Nov 29, 2022
a905664
so far
sshane Nov 29, 2022
c1df489
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Nov 30, 2022
85235a7
stash
sshane Dec 1, 2022
1bc58d6
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Dec 1, 2022
a0d1286
clean up
sshane Dec 1, 2022
5daf884
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Dec 3, 2022
fc5c43f
lateral allowed
sshane Dec 3, 2022
7824cb0
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Dec 15, 2022
7afb897
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Oct 4, 2023
42c0c27
don't change lat
sshane Oct 4, 2023
e689d51
rename
sshane Oct 4, 2023
97f403c
this should work
sshane Oct 4, 2023
813750e
draft
sshane Oct 4, 2023
3c22fdb
need to do this for tesla to know where 0 accel point is
sshane Oct 4, 2023
8065c64
this is cleaner
sshane Oct 4, 2023
65aa62b
oh wait it does
sshane Oct 4, 2023
b5eaf9f
use _generic_limit_safety_check in ford
sshane Oct 4, 2023
a880f46
tests
sshane Oct 4, 2023
2e0e7a9
Revert "use _generic_limit_safety_check in ford"
sshane Oct 4, 2023
4fe2baa
all good
sshane Oct 4, 2023
60d5052
ford
sshane Oct 4, 2023
4c59318
messy
sshane Oct 4, 2023
c48473d
clean up
sshane Oct 4, 2023
40dcb1b
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Nov 11, 2023
1c1c6c1
cando this, but this seems more confusing now
sshane Nov 11, 2023
423fe3e
or...
sshane Nov 11, 2023
55681c1
better
sshane Nov 11, 2023
57122bb
comments
sshane Nov 11, 2023
024663a
winning
sshane Nov 11, 2023
26a45ca
remove get_decel_allowed
sshane Nov 11, 2023
7ce2100
space up here
sshane Nov 11, 2023
2965bca
overkill
sshane Nov 11, 2023
31955d8
tests
sshane Nov 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
tests
  • Loading branch information
sshane committed Nov 11, 2023
commit 31955d84a6b67e73d7f50a9dcdf989edebe2e36e
31 changes: 11 additions & 20 deletions tests/safety/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def test_accel_actuation_limits(self, stock_longitudinal=False):
should_tx = False
else:
should_tx = controls_allowed and min_accel <= accel <= max_accel

should_tx = should_tx or accel == self.INACTIVE_ACCEL
self.assertEqual(should_tx, self._tx(self._accel_msg(accel)))

Expand All @@ -239,15 +238,13 @@ def test_brake_preenable(self):
self._rx(self._user_brake_msg(1))

# Test we allow brake but not positive accel
for valid_accel in np.concatenate((np.arange(self.MIN_ACCEL, self.MAX_ACCEL, 0.1), [self.INACTIVE_ACCEL])):
valid_accel = round(valid_accel, 2) # floats might not hit exact boundary conditions without rounding
should_tx = valid_accel <= 0
self.assertEqual(should_tx, self._tx(self._accel_msg(valid_accel)))
for valid_accel in (self.MIN_ACCEL, 0, self.INACTIVE_ACCEL):
self.assertTrue(self._tx(self._accel_msg(valid_accel)))
self.assertFalse(self._tx(self._accel_msg(self.MAX_ACCEL)))

# Make sure we can re-gain longitudinal actuation
self._rx(self._user_brake_msg(0))
for valid_accel in np.concatenate((np.arange(self.MIN_ACCEL, self.MAX_ACCEL, 0.1), [self.INACTIVE_ACCEL])):
valid_accel = round(valid_accel, 2) # floats might not hit exact boundary conditions without rounding
for valid_accel in (self.MIN_ACCEL, self.MAX_ACCEL, 0, self.INACTIVE_ACCEL):
self.assertTrue(self._tx(self._accel_msg(valid_accel)))


Expand Down Expand Up @@ -293,23 +290,17 @@ def test_brake_preenable(self):
self._rx(self._user_brake_msg(1))

# Test we allow brake but not gas
self.assertFalse(self._tx(self._send_gas_msg(0)))
for brake in (self.MIN_BRAKE, self.MAX_BRAKE, 0):
self.assertTrue(self._tx(self._send_brake_msg(brake)))

self.assertTrue(self._tx(self._send_gas_msg(self.INACTIVE_GAS)))
if self.INACTIVE_GAS != self.MIN_GAS:
self.assertFalse(self._tx(self._send_gas_msg(self.MIN_GAS)))

self.assertTrue(self._tx(self._send_brake_msg(0)))
self.assertTrue(self._tx(self._send_brake_msg(self.MIN_BRAKE)))
self.assertTrue(self._tx(self._send_brake_msg(self.MAX_BRAKE)))

# for valid_accel in (0, self.INACTIVE_ACCEL, self.MIN_ACCEL):
# self.assertTrue(self._tx(self._accel_msg(valid_accel)))
# self.assertFalse(self._tx(self._accel_msg(self.MAX_ACCEL)))
#
# # Make sure we can re-gain longitudinal actuation
# self._rx(self._user_brake_msg(0))
# for valid_accel in (0, self.INACTIVE_ACCEL, self.MIN_ACCEL, self.MAX_ACCEL):
# self.assertTrue(self._tx(self._accel_msg(valid_accel)))
# Make sure we can re-gain longitudinal actuation
self._rx(self._user_brake_msg(0))
for gas in (self.MIN_GAS, self.MAX_GAS, self.INACTIVE_GAS):
self.assertTrue(self._tx(self._send_gas_msg(gas)))

class TorqueSteeringSafetyTestBase(PandaSafetyTestBase, abc.ABC):

Expand Down
1 change: 1 addition & 0 deletions tests/safety/test_toyota.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def test_accel_actuation_limits(self, stock_longitudinal=True):
super().test_accel_actuation_limits(stock_longitudinal=stock_longitudinal)

def test_brake_preenable(self):
# Stock long blocks longitudinal actuation
raise unittest.SkipTest

def test_acc_cancel(self):
Expand Down
Loading