Commit Graph

2216 Commits

Author SHA1 Message Date
Robbe Derks
2c937656cf Continuous harness detection (#1402)
* read in mV and make threshold board-dependent

* refactor and add SBU voltages to health

* refactor relay driving

* more refactoring and readout lock

* avoid race condition

* fix misra

* continuous detection

* 1Hz is fine

* another race condition

* use harness detection to trigger bootkick

* update orientation detection test

* more in-depth harness tests

* fix ignition

* fix

* raise threshold
2023-05-08 13:30:23 +02:00
Shane Smiskol
35609dfdce safety utils: add ROUND helper (#1397)
* add round macro

* Update board/utils.h

* function

* one line

* misra

* use here too
2023-05-06 21:25:25 -07:00
Adeeb Shihadeh
e7f2e72c3d setup independent watchdog (#1404)
* setup independent watchdog

* builds

* same file

* configurable timeout

* disable for now

* no feed

* rm

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-05-05 16:46:38 -07:00
Robbe Derks
fea1feb598 ADC cleanup (#1401)
* cleanup function names

* cleanup voltage reading

* define constant

* fix misra

* remove comments
2023-05-04 13:22:01 +02:00
Shane Smiskol
cedb5fd1a6 Ford: remove safety mode from debug flag (#1400)
remove from debug
2023-05-04 06:08:10 +00:00
Shane Smiskol
94cd9a0788 Ford: curvature rate limits (#1258)
* ford curvature rate limits draft

* make common angle tests work with curvature

* comment

* no need for this

* extra line

* fix test

* generic curvature test class

* more reasonable limits

* adjust limits

* draft

* works

* works

* clean up

* add vehicle speed

* works

* clean up

* clean up

* more clean up

* more clean up

* lower

* double

* add updated bp

* remove

* can clean that up

* draft

* this works!

* think that's the correct placement

* try this

* closer

* use min

* add/sub one to not falsely trip

* remove old angle error safety

* i'm not sure if clamp is more readable

* fix that

* fix

* stash

* fix these tests

* ternary

* floats are a pain

* draft, works kinda

* even better

* round that

* need tolerance

* this should work (adding tol=1 wouldn't let us have multiple rate limits)

* test works

* clamp breaks if low is higher than high :(((

down from 150 blocked msgs to 7!

* no blocked msgs!!!

* test a whole bunch

* stash

* stash

* clean up test

* clean up test to be more like torque (+ speeds)

* clean up

* cmt

* test up

* up and down are good

* rename and remove

* this is tested

* uncomment

* this is tested by ensuring we move towards error at a minimum rate

* not used any more

* revert common

* clean up test_ford a bit more

* some clean up (combine variables where it makes sense)

* yeah can't use clamp since min isn't always < max, min(max(.. handles this

* clean up

* revert that

* comments

* cmt

* another

* that's old

* misra!

* Update board/safety/safety_ford.h

* Update board/safety/safety_ford.h

* add todo, fix test case

* more clear, matches panda

* add comment

* Update tests/safety/test_ford.py

* more fine speed increments

* rm comment

* better names

* this is expected behavior (tested by common checks)

* CURVATURE_ERROR_LIMIT_SPEED

* better name?

* pretty clean!

* same for up

* only used in one place now

* these are now clear

* common term

* make vehicle_speed a sample_t

* need to use values[0]

* speed is a float

* Revert "speed is a float"

This reverts commit 01af02f1d35026d983cc2ba6d9ba364c87c800ee.

* Revert "need to use values[0]"

This reverts commit 8f6d68345a92f7285d07ca071285e903ed7871bb.

* Revert "make vehicle_speed a sample_t"

This reverts commit ecd8dc86b6b97cc8bff7da697353a8d90c358b12.

* safety fixes for new speed sample

* test fixes for new speed sample

* fix misra and make intermediate variable

* this isn't needed
2023-05-04 04:59:35 +00:00
Shane Smiskol
b44df8151a safety tests: use rx/tx helpers (#1399)
use rx/tx helpers
2023-05-04 04:09:09 +00:00
Shane Smiskol
3a64b6ccb5 safety: make vehicle_speed a sample (#1391)
* convert vehicle_speed into sample_t, change no behavior

* draft

* round

* test

* clean up

* round

* round all

* use min

* remove round macro from this PR

* reset speed measurement

* debug

* bbd

* rm

* revert

* test above and below

* need this now

* misra pt 1

* misra pt 2

* misra pt 3

* i don't understand this one, not different from other cases

* fix test

* test

* revert that

* draft

* test the sample_t works properly for safety modes that use it (angle only)

* can combine these tests

* test decimals

* global

* misra

comment

* suggestions

* fix

* use new helper
2023-05-04 03:37:56 +00:00
Shane Smiskol
5a9603600e safety tests: reset safety helper (#1398)
* reset safety

* use it

* clean it up

* two lines

* fix python linting
2023-05-04 02:51:08 +00:00
Shane Smiskol
776bb69945 Ford: test angle measurement (#1396)
* test angle meas readback (ensures speed and yaw rate are used properly)

* revert

* rm

* tuple

* temp

* clean up

* stash

* Revert "stash"

This reverts commit cab96b3e2b46d7b43ef539b96e0f6d3918d21e55.

* use global

* test negative

* name
2023-05-03 21:37:04 +00:00
Shane Smiskol
4b04275514 Ford: test angle error speed in steering signal test (#1395)
* test above and below limit speed

* need this now
2023-05-03 21:19:52 +00:00
Adeeb Shihadeh
ba5c2948e4 python: default to 60s timeout for recover() (#1394) 2023-05-03 14:15:34 -07:00
Shane Smiskol
810df6b5c1 safety replay: safety tick (#1364)
* make explicit, there was no bug only because the if statement is identical to above

* debug

* Revert "debug"

This reverts commit 2ec83677c3749f805681c4874b746696767f7634.

* Revert "make explicit, there was no bug only because the if statement is identical to above"

This reverts commit fcb2a106b9694727ca4b5a9acf4eda3312fc4271.

* fixes

* remove

* allow 1 second

* remove

* clean up

* call every can msg

* safety_tick_rx_invalid like test_models

* order

* skip end

* try that
2023-05-03 05:01:44 +00:00
Shane Smiskol
3a3e117d01 Ford: remove unused function (#1393)
we can just round this now
2023-05-03 04:35:00 +00:00
Shane Smiskol
aa30b15de5 Ford safety: more clear variable names (#1392)
* that's a better name

* that too
2023-05-03 03:45:33 +00:00
Shane Smiskol
22b2453728 angle safety: consistent rate limit variable names (#1390)
consistent names
2023-05-03 00:34:24 +00:00
Shane Smiskol
69ad3dd8e8 angle safety: add comment about rate limits at 0 (#1389)
* up when 0

* Revert "up when 0"

This reverts commit fc9b459651826e5ca8d597920d4fea49eedb15d5.

* add comment

* whoops
2023-05-03 00:07:23 +00:00
Shane Smiskol
14cfb78ab2 Subaru: add gen 2 Outback route (#1386)
gen2 outback route
2023-05-02 13:45:21 -07:00
Shane Smiskol
1d1284e863 Revert "Subaru: add gen 2 Outback route (#1385)"
This reverts commit c43f33191c.
2023-05-02 13:18:26 -07:00
Shane Smiskol
c43f33191c Subaru: add gen 2 Outback route (#1385)
gen2 outback route
2023-05-02 13:07:50 -07:00
Shane Smiskol
2fb25c4a0b Subaru: fix Impreza replay route (#1384)
* fix

* impreza route
2023-05-02 01:21:33 -07:00
Robbe Derks
641d9c4f3a Tesla: DAS_control is on bus 2 (#1374)
these are on bus 2
2023-05-02 00:55:00 -07:00
Adeeb Shihadeh
8e1ca608b0 H7: remove busy wait on TXC (#1381)
* works

* cleanup

* less irq

* less diff

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-05-01 20:18:23 -07:00
Shane Smiskol
f9485c8d5d Ford: more clear steering safety check (#1383)
one line
2023-05-01 20:01:03 -07:00
Adeeb Shihadeh
a5718ce5dd spi: different ack dummy bytes for debugging (#1382)
different ack vals

Co-authored-by: Comma Device <device@comma.ai>
2023-05-01 19:31:13 -07:00
Shane Smiskol
dbe941004a safety: reset torque_meas on init properly (#1250)
* reset min torque meas too

* add test that fails

* cmt

* cmt

* clean up test

* don't be random

* above test tests this pretty much

* test angle too

* fix

* also test driver torque

* whoops

* whoops
2023-04-28 17:45:02 -07:00
Shane Smiskol
63db708491 driver torque limit: make driver torque message abstract (#1377)
* abs

* uncomment

* fixy
2023-04-28 17:36:35 -07:00
Shane Smiskol
99809f7071 angle safety tests: more clear helper function name
here too
2023-04-28 15:02:57 -07:00
Shane Smiskol
001f9917ef ford: disable counter check for second speed (#1375)
add comment and disable counter for second speed
2023-04-28 14:25:35 -07:00
Shane Smiskol
4160d8d71c safety: common angle safety function (#1369)
* draft clean up

* always check

* add angle to name

* ford sends curvature when not steering and bit is 0.

it's not torque, curvature of 0 will still apply torque

* need this to be generic

* formatting

* rm

* test that we can send curvature=0 if enabled=False while control_allowed=True (let's say EPS faults, OP doesn't want to actuate)

* revert ford tests to master

* this <i>should</i> preserve behavior

* this is fine to remove

* and this should also be covered

* yeet

* change opt name, combine checks, much better!

* one more

* modes

* Add comment

* misra has a bug :(

* ugh

* make this clear

* ?

* order

* fix

* comments
2023-04-27 23:33:54 -07:00
Shane Smiskol
69a0b6ed34 safety: use max_limit_check helper in angle safety (#1373)
* better

* ?

* ?

* Revert "?"

This reverts commit ae70c7ff3b41e49ccc149b7b202fdcde0a120e8d.

* Revert "?"

This reverts commit db7fd644a9cedfc46583651fe7581e4862b0f77e.
2023-04-27 23:19:26 -07:00
Shane Smiskol
aac46a2ef2 angle safety: enforce disabled angle when not steering (#1372)
* enforce disabled angle when bit not set, below we enforce bit to be 0 when not controls allowed

* test

* other test

* combine tests

* comment
2023-04-27 21:41:38 -07:00
Shane Smiskol
240370cdd1 ford: allow 0 curvature when controls are allowed if not steering (#1370)
* test that we can send curvature=0 if enabled=False while control_allowed=True (let's say EPS faults, OP doesn't want to actuate)

* draft

* only check error if apply bit is 1

* subtest

* no subtest

* fix safety and tests

* tests say this works

* clean up

* subtests are sloww

* Revert "subtests are sloww"

This reverts commit 560c6745c8dddfcce87113e36e3661274fbb239b.

* fix test from merge

* add comment

* add comment

* add another comment

* spacing
2023-04-27 17:44:32 -07:00
Shane Smiskol
07680692d9 Ford: add subtests (#1371)
* subtest here

* and here

* bit faster
2023-04-27 17:27:18 -07:00
Shane Smiskol
c9c3cb38f6 Ford safety: curvature error limit (#1353)
* set ford vehicle speed

* parse yaw rate signals

* misra

* misra

* misra

* misra

* draft

* update module

* already checked

* and set it properly

* some stuff

* draft

* clean up (will fail tests because we don't send yaw rate yet)

* could do something like this

* this is better and less prone to bugs

* match simple op limiting, debugging

* set checksum for messages in tests

* clean up

* fix that

* one m/s fudge

* fix sign of yaw rate

* interpolate detects size

* forgot OP flips the curvature sign. it matches yaw on can

* all my debugging crap

* make replay work for ford

* fix panda blocking messages (array is fixed size so size-1 is 0 rate at high speed)

* uncomment safety test limits

* revert

* round for zero blocked msgs

* fix limits

* meas safety checks that down rate is >=, not <

* test pass

* lots of comments and draft what one meas torque check would look like

* fix that

* add curvature meas

* add debugging stuff

* Revert "add debugging stuff"

This reverts commit 449783fc625954868a1cfca48a655cac7b074cc1.

* messy but at least one test passes now

* draft

* add max_steer

* some safety clean up

* and that

* start with a test that works

* another test that works (sort of, we need more strict panda safety without false positives)

* no max curvature check (not safety related), allow any rate limits

* add new function

* also need to consider max val here, since OP will send up to that

* and now use the function

* lower to 10

* compilation fixes

* clean up (no rate limiting)

* remove that too

* curvature diff test

* more clean up

* debug

* ?

* better names

* more official

* use _curvature_meas_msg_array here

* bit faster

* no i don't

* revert that

* why not just use angle_meas?

* bb ll

* bb deb

* clean up debug vals

* more

* revert replay drive debugging changes

* Update board/safety.h

* rm line

* only need to round the final thing

* not needed, under 10 ms

* make a class variable

* fix a misra?

* another misra?

better

* ?

* 12.1

* need to explicitly convert

* add one to not false trigger the violation (float rounding)

* not really needed

* rm line

* cmt

* use clamp

* rename

* in struct

* comment

* use max_limit_check

* draft clean up

* Revert "draft clean up"

This reverts commit d1a0e8acd1d0eb2bd7b75618c7df14e15c16e134.

* make a global

make a global

* this is fine
2023-04-27 00:40:29 -07:00
Shane Smiskol
4269b74a84 safety: use max_limit_check (#1368)
use max_limit_check
2023-04-26 23:55:04 -07:00
Adeeb Shihadeh
1e8c5d59c7 CI: run tests with UBSan (#1363)
* CI: run tests with UBSan

* try this
2023-04-26 23:15:28 -07:00
Adeeb Shihadeh
7aef934d4c Fix undefined behavior in GET_BYTES macro (#1367) 2023-04-26 22:59:58 -07:00
Shane Smiskol
f444f1554f Ford: check second speed for mismatches (#1358)
* Add second speed

* 2.5 m/s is 9 kph, 4 kph is the max in the field

* add quality signal

* qf signal name

* comment

* checksum matches except it goes to zero when turning the car off despite counter still active

* update comments

* now test it

* spacing

* Update board/safety/safety_ford.h

* zzzz

* not needed

* whoops

* test vehicle state mismatch

* add to safety_helpers

* probably misra

* we might want to check it in both speed signals in case one doesn't exist on a car

* Revert "we might want to check it in both speed signals in case one doesn't exist on a car"

This reverts commit 3338931409327f9c0eaa6fbd0daa9a57ef229b46.

* fix formatting

* 2 m/s (7 kph)

* set controls_allowed directly like other safety models

remove vehicle_state_mismatch

* obv
2023-04-26 22:37:36 -07:00
Shane Smiskol
5c21b14049 Ford: check 2nd speed message (#1365)
* Add second speed

* 2.5 m/s is 9 kph, 4 kph is the max in the field

* add quality signal

* qf signal name

* comment

* checksum matches except it goes to zero when turning the car off despite counter still active

* update comments

* now test it

* spacing

* Update board/safety/safety_ford.h

* zzzz

* not needed

* whoops

* test vehicle state mismatch

* add to safety_helpers

* probably misra

* we might want to check it in both speed signals in case one doesn't exist on a car

* Revert "we might want to check it in both speed signals in case one doesn't exist on a car"

This reverts commit 3338931409327f9c0eaa6fbd0daa9a57ef229b46.

* fix formatting

* 2 m/s (7 kph)

* revert mismatch stuff
2023-04-26 21:49:39 -07:00
Shane Smiskol
048ddeea4a safety: make addr index getter more explicit (#1361)
make this explicit
2023-04-26 21:15:55 -07:00
Shane Smiskol
f3d6d613c0 safety: don't check out of bounds array item (#1360)
* safety: don't check out of bounds array item

* better name

* cleanup

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2023-04-26 19:43:30 -07:00
Shane Smiskol
23b5130de9 replay drive: fixes (#1362)
* make explicit, there was no bug only because the if statement is identical to above

* debug

* Revert "debug"

This reverts commit 2ec83677c3749f805681c4874b746696767f7634.

* Revert "make explicit, there was no bug only because the if statement is identical to above"

This reverts commit fcb2a106b9694727ca4b5a9acf4eda3312fc4271.

* fixes

* clean that up

* and this
2023-04-26 17:45:04 -07:00
Adeeb Shihadeh
b342c2d724 fan: add stall threshold backoff (#1357)
* fan: add stall threshold backoff

* Update board/config.h

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-21 15:41:26 -07:00
Adeeb Shihadeh
08ed853bf9 log total stall count in fan tuning script 2023-04-21 13:47:13 -07:00
Adeeb Shihadeh
272b81e97b fan: fix stall detection (#1351)
* cleanup and fix

* dos must stall

* clean those up

* fix misra

* more test

* fix import

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-20 15:44:12 -07:00
Adeeb Shihadeh
6093301bc9 add CLAMP macro (#1356)
* add CLAMP macro

* fix
2023-04-20 14:34:11 -07:00
Adeeb Shihadeh
3c75a8bc00 add fan stall count to health (#1355)
* add fan stall count to health

* fix misra

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-20 13:30:56 -07:00
Adeeb Shihadeh
0e2eb9c0f5 fan debugging script (#1354)
* fan debugging script

* merge those

* disable

* better print

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-20 13:00:40 -07:00
Adeeb Shihadeh
e6cad01955 H7: fix CAN FD IRQ rate (#1332) 2023-04-19 17:34:31 -07:00