openpilot icon indicating copy to clipboard operation
openpilot copied to clipboard

Subaru: POC for longitudinal control

Open martinl opened this issue 2 years ago • 11 comments

Description POC for Subaru Global longitudinal control. For acceleration, there are 2 signals - cruise_throttle and cruise_rpm that are basically throttle and rpm target requests. Scaling values used in carcontroller are roughly modeled by plotting and observing stock acc signals and testing. Brake request is single linear signal with 0-400 scale.

Stock AEB/PCB is passed through.

The general idea for logitudinal control is that eyesight is not engaged by rewriting the feedback signals from car. openpilot generates the required signals for lateral and longitudinal control and dash display.

POC is usable and I have used it for testing the openpilot vision only performance from time to time

Verification Tested on 2018 Crosstrek

martinl avatar Aug 03 '22 05:08 martinl

I did some testing on subaru long branch and Eyesight also faults when rebased to latest master. I tracked down the commit using preserved subaru-long-c2 branch and fault starts after opendbc commit 859fea7ded706516f4b963218a3c9cf543f39c2a (CAN FD support in packer + parser).

Last currently working opendbc commit is 0ccc718b1a35316cf6f553bf220f25b156e67c63

I will post relevant routes once they are uploaded

martinl avatar Aug 17 '22 19:08 martinl

Working subaru-long-c2 route: 05bca04dfbdca165|2022-08-17--22-23-55 Eyesight fault on startup: 05bca04dfbdca165|2022-08-17--22-29-26

martinl avatar Aug 17 '22 21:08 martinl

I did some testing on subaru long branch and Eyesight also faults when rebased to latest master. I tracked down the commit using preserved subaru-long-c2 branch and fault starts after opendbc commit 859fea7ded706516f4b963218a3c9cf543f39c2a (CAN FD support in packer + parser).

I would check if any signals are overlapping.

adeebshihadeh avatar Aug 17 '22 22:08 adeebshihadeh

I tested the subaru dbc files

I did some testing on subaru long branch and Eyesight also faults when rebased to latest master. I tracked down the commit using preserved subaru-long-c2 branch and fault starts after opendbc commit 859fea7ded706516f4b963218a3c9cf543f39c2a (CAN FD support in packer + parser).

I would check if any signals are overlapping.

I tested loading subaru dbc files using cantools and there are no overlapping signals. I created one signals overlap for testing and cantools reported it correctly.

I also enabled DEBUG in opendbc/can/common.h but did not find any clues related to can signals or checksums being wrong

martinl avatar Aug 18 '22 04:08 martinl

with latest version / feature-subaru-long branch I get during startup

opendbc/can/parser.cc: 0x3AC MISSING
opendbc/can/parser.cc: 0x119 MISSING
opendbc/can/parser.cc: 0x3AC MISSING
opendbc/can/parser.cc: 0x3AC MISSING
opendbc/can/parser.cc: 0x3AC MISSING
opendbc/can/parser.cc: 0x3AC MISSING
opendbc/can/parser.cc: 0x3AC MISSING
opendbc/can/parser.cc: 0x322 MISSING
opendbc/can/parser.cc: 0x321 MISSING
opendbc/can/parser.cc: 0x322 MISSING
opendbc/can/parser.cc: 0x321 MISSING
opendbc/can/parser.cc: 0x322 MISSING
opendbc/can/parser.cc: 0x321 MISSING
opendbc/can/parser.cc: 0x322 MISSING
opendbc/can/parser.cc: 0x321 MISSING
opendbc/can/parser.cc: 0x322 MISSING
opendbc/can/parser.cc: 0x321 MISSING
opendbc/can/parser.cc: 0x3AC MISSING
opendbc/can/parser.cc: 0x3AC MISSING
opendbc/can/parser.cc: 0x3AC MISSING

I tried to comment out can_valid checks in opendbc/can/parser.cc (can_valid is always true) and set all frequency checks in carstate to 1 but eyesight still faulted.

Are there any other debug options to enable that might be useful to finding the cause?

martinl avatar Aug 18 '22 16:08 martinl

I made some progress narrowing down the issue - Eyesight does not fault if I allow forwarding of Brake_Status and CruiseControl messages in panda safety. I added debug output to subarucan to print the sent Brake_Status and CruiseControl messages

working, subaru-long-c2 branch:

send cruisecontrol
[576, 0, b'\xd4\x05\x00\xa46\x00\x08\xab', 2]
send brake_status
[316, 0, b'\x0f/\x00\x00\x00\x00@c', 2]
send brake_status
[316, 0, b'\x00 \x00\x00\x00\x00@c', 2]
send brake_status
[316, 0, b'\x01!\x00\x00\x00\x00@c', 2]
send cruisecontrol
[576, 0, b'\xd6\x06\x00\xa46\x00\x08\xac', 2]
send brake_status
[316, 0, b'\x02"\x00\x00\x00\x00@c', 2]
selfdrive/boardd/boardd.cc: got 736 bytes CarParams
selfdrive/boardd/boardd.cc: panda 0: setting safety model: 11, param: 0, alternative experience: 1
send brake_status
[316, 0, b'\x03#\x00\x00\x00\x00@c', 2]
send brake_status
[316, 0, b'\x04$\x00\x00\x00\x00@c', 2]
send cruisecontrol
[576, 0, b'\xd7\x07\x00\xa46\x00\x08\xac', 2]
send brake_status
[316, 0, b'\x05%\x00\x00\x00\x00@c', 2]
send brake_status
[316, 0, b'\x06&\x00\x00\x00\x00@c', 2]

not working, subaru-feature-long:

send cruisecontrol
[576, 0, b'\xa8\n\x00\xa0\x06\x00\x08\xae', 2]
send brake_status
[316, 0, b'\x03#@\x03\x00\x00\x00`', 2]
send brake_status
[316, 0, b'\x04$@\x03\x00\x00\x00`', 2]
send brake_status
[316, 0, b'\x05%@\x03\x00\x00\x00`', 2]
selfdrive/boardd/boardd.cc: got 1408 bytes CarParams
selfdrive/boardd/boardd.cc: panda 0: setting safety model: 11, param: 2, alternative experience: 1
send brake_status
[316, 0, b'\x06&@\x03\x00\x00\x00`', 2]
send brake_status
[316, 0, b"\x07'@\x03\x00\x00\x00`", 2]
send brake_status
[316, 0, b'\x08(@\x03\x00\x00\x00`', 2]
send cruisecontrol
[576, 0, b'\xab\x0c\x00\xa0\x06\x00\x08\xaf', 2]
send brake_status
[316, 0, b'\t)@\x03\x00\x00\x00`', 2]
send brake_status
[316, 0, b'\n*@\x03\x00\x00\x00`', 2]
send cruisecontrol
[576, 0, b'\xad\r\x00\xa0\x06\x00\x08\xb0', 2]

Eyesight faults when the panda safety mode is set

martinl avatar Sep 04 '22 11:09 martinl

I split the 46bit Brake_Status Signal1 signal to two 23bit signals in test branch and that fixed eyesight fault. I'll see if I can fix opendbc large values issue but I may need help with that.

martinl avatar Sep 07 '22 18:09 martinl

CAN Parser bug fixed and opendbc has been bumped on master with the fix.

adeebshihadeh avatar Sep 08 '22 03:09 adeebshihadeh

Thanks. I merged the latest master and it's working with Crosstrek. I'll look into why gen2 car interface tests are failing, process replay failure is expected

martinl avatar Sep 08 '22 08:09 martinl

not directly relevant but I had to add the if sys.platform.startswith("linux"): conditions back in common/realtime.py because on macos pre-commit checks fail with mypy errors

common/realtime.py:35: error: Module has no attribute "sched_setscheduler" common/realtime.py:40: error: Module has no attribute "sched_setaffinity"

martinl avatar Oct 02 '22 10:10 martinl

I moved the dev environment to ubuntu and reverted linux platform checks. Also moved ES_Status and ES_Brake to can1 for GEN2, so all route tests are passing now.

martinl avatar Oct 16 '22 10:10 martinl

Stock AEB PR https://github.com/commaai/openpilot/pull/28052

martinl avatar Apr 27 '23 21:04 martinl

the required changes are already implemented in feature-subaru-long-2023-07-02 branch, I will merge soon after testing

martinl avatar Jul 05 '23 06:07 martinl

Superseded by https://github.com/commaai/openpilot/pull/28872 - closing this

martinl avatar Aug 13 '23 01:08 martinl