dragonpilot - 基於 openpilot 的開源駕駛輔助系統
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
4.4 KiB

5 years ago
#!/usr/bin/env python3
import unittest
import pytest
5 years ago
import sys
from parameterized import parameterized_class
from typing import List, Optional
5 years ago
from openpilot.selfdrive.car.car_helpers import interface_names
from openpilot.selfdrive.test.process_replay.process_replay import check_openpilot_enabled
from openpilot.selfdrive.test.process_replay.helpers import TestProcessReplayDiffBase
5 years ago
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>
3 years ago
source_segments = [
("BODY", "937ccb7243511b65|2022-05-24--16-03-09--1"), # COMMA.BODY
("HYUNDAI", "02c45f73a2e5c6e9|2021-01-01--19-08-22--1"), # HYUNDAI.SONATA
("HYUNDAI2", "d545129f3ca90f28|2022-11-07--20-43-08--3"), # HYUNDAI.KIA_EV6 (+ QCOM GPS)
("TOYOTA", "0982d79ebb0de295|2021-01-04--17-13-21--13"), # TOYOTA.PRIUS
("TOYOTA2", "0982d79ebb0de295|2021-01-03--20-03-36--6"), # TOYOTA.RAV4
("TOYOTA3", "f7d7e3538cda1a2a|2021-08-16--08-55-34--6"), # TOYOTA.COROLLA_TSS2
("HONDA", "eb140f119469d9ab|2021-06-12--10-46-24--27"), # HONDA.CIVIC (NIDEC)
("HONDA2", "7d2244f34d1bbcda|2021-06-25--12-25-37--26"), # HONDA.ACCORD (BOSCH)
("CHRYSLER", "4deb27de11bee626|2021-02-20--11-28-55--8"), # CHRYSLER.PACIFICA_2018_HYBRID
("RAM", "17fc16d840fe9d21|2023-04-26--13-28-44--5"), # CHRYSLER.RAM_1500
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>
3 years ago
("SUBARU", "341dccd5359e3c97|2022-09-12--10-35-33--3"), # SUBARU.OUTBACK
("GM", "0c58b6a25109da2b|2021-02-23--16-35-50--11"), # GM.VOLT
("GM2", "376bf99325883932|2022-10-27--13-41-22--1"), # GM.BOLT_EUV
("NISSAN", "35336926920f3571|2021-02-12--18-38-48--46"), # NISSAN.XTRAIL
4 years ago
("VOLKSWAGEN", "de9592456ad7d144|2021-06-29--11-00-15--6"), # VOLKSWAGEN.GOLF
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>
3 years ago
("MAZDA", "bd6a637565e91581|2021-10-30--15-14-53--4"), # MAZDA.CX9_2021
("FORD", "54827bf84c38b14f|2023-01-26--21-59-07--4"), # FORD.BRONCO_SPORT_MK1
VW PQ: Volkswagen Passat NMS (#24768) * VW PQ: Volkswagen Passat NMS * regen CARS.md * vEgo from Bremse_1 vehicle speed * sync opendbc to master * handle checksums and counters in opendbc * LDW HUD message handling * GRA_Neu_Zaehler -> COUNTER * bump opendbc * stub in till we find platform ACC standstill * bump opendbc * bump opendbc * placeholder lateral accel data * regen CARS.md * counters now directly supported in opendbc * additional door-open signals * add trunk lid state * add doors and trunk lid to signals list * LDW_Status updates and passthrough * bump opendbc for typo fix * update AWV comment * another comment update * regen CARS.md with PQ in dashcam only * don't show NMS footnotes while still in dashcam * polish * add stubbed-out dashcamOnly prep * VW MQB: Cleanup stock ACC button handling * bump opendbc and panda * use controls resume output as trigger * these can wait until taco bell * bump opendbc * pass through of previously fixed value * retry CI * checks already done in carcontroller * don't need these anymore * reduce diff for now * slightly better abstraction * more engine and trans FW * turn signal is instantaneous stalk position * weak sauce :( * better clarity * try torque tune * add test route references * bump opendbc and panda for OP long * don't show steering faults for 3 seconds after start * longitudinal control senders * a little more torque * test hax to torque control * test a little more delay * allow use of manufacturer ramp-up rate * soften wheel-touch threshold * Revert "test hax to torque control" This reverts commit d1af459c29e36264aae406f72b8fcbc9ef22b9e0. * punch it Chewie * better ACC state and mainswitch handling * a little more * tweak max accel gradient * oops * also oops * stuff * srsly * that's not how this works * regen CARS.md * footnotes now properly excluded for dashcam cars * this wasn't a problem * update network location detection * bump submodules for ACC main switch * clean up DBC references and long flag * bump one more time * one more time * follow CANPacker counter refactor * bump opendbc * sync opendbc to master * bump panda to fix Subaru tests * DBC handling cleanup * fix * model-year stretch * cleanup and rate bugfixes * better abstractions * simplify create_lka_hud_control * volkswagencan -> mqbcan * bump panda * fix doc data bug, regen CARS.md * style updates; diff reduction * use common button enable logic * not needed anymore * refactor TSK and HUD enum values * make common button events function * consistency * bump panda * bump panda * dashcam only * don't need process_replay yet * regen CARS.md with Passat NMS in dashcam * can't handle dashcam-orphaned footnotes yet * remove outdated standstill handling * editor tried to be too helpful at some point * don't need to import this anymore * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * follow parkingBrake refactor Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
3 years ago
# Enable when port is tested and dashcamOnly is no longer set
#("TESLA", "bb50caf5f0945ab1|2021-06-19--17-20-18--3"), # TESLA.AP2_MODELS
VW PQ: Volkswagen Passat NMS (#24768) * VW PQ: Volkswagen Passat NMS * regen CARS.md * vEgo from Bremse_1 vehicle speed * sync opendbc to master * handle checksums and counters in opendbc * LDW HUD message handling * GRA_Neu_Zaehler -> COUNTER * bump opendbc * stub in till we find platform ACC standstill * bump opendbc * bump opendbc * placeholder lateral accel data * regen CARS.md * counters now directly supported in opendbc * additional door-open signals * add trunk lid state * add doors and trunk lid to signals list * LDW_Status updates and passthrough * bump opendbc for typo fix * update AWV comment * another comment update * regen CARS.md with PQ in dashcam only * don't show NMS footnotes while still in dashcam * polish * add stubbed-out dashcamOnly prep * VW MQB: Cleanup stock ACC button handling * bump opendbc and panda * use controls resume output as trigger * these can wait until taco bell * bump opendbc * pass through of previously fixed value * retry CI * checks already done in carcontroller * don't need these anymore * reduce diff for now * slightly better abstraction * more engine and trans FW * turn signal is instantaneous stalk position * weak sauce :( * better clarity * try torque tune * add test route references * bump opendbc and panda for OP long * don't show steering faults for 3 seconds after start * longitudinal control senders * a little more torque * test hax to torque control * test a little more delay * allow use of manufacturer ramp-up rate * soften wheel-touch threshold * Revert "test hax to torque control" This reverts commit d1af459c29e36264aae406f72b8fcbc9ef22b9e0. * punch it Chewie * better ACC state and mainswitch handling * a little more * tweak max accel gradient * oops * also oops * stuff * srsly * that's not how this works * regen CARS.md * footnotes now properly excluded for dashcam cars * this wasn't a problem * update network location detection * bump submodules for ACC main switch * clean up DBC references and long flag * bump one more time * one more time * follow CANPacker counter refactor * bump opendbc * sync opendbc to master * bump panda to fix Subaru tests * DBC handling cleanup * fix * model-year stretch * cleanup and rate bugfixes * better abstractions * simplify create_lka_hud_control * volkswagencan -> mqbcan * bump panda * fix doc data bug, regen CARS.md * style updates; diff reduction * use common button enable logic * not needed anymore * refactor TSK and HUD enum values * make common button events function * consistency * bump panda * bump panda * dashcam only * don't need process_replay yet * regen CARS.md with Passat NMS in dashcam * can't handle dashcam-orphaned footnotes yet * remove outdated standstill handling * editor tried to be too helpful at some point * don't need to import this anymore * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * follow parkingBrake refactor Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
3 years ago
#("VOLKSWAGEN2", "3cfdec54aa035f3f|2022-07-19--23-45-10--2"), # VOLKSWAGEN.PASSAT_NMS
5 years ago
]
segments = [
("BODY", "regen997DF2697CB|2023-10-30--23-14-29--0"),
("HYUNDAI", "regen2A9D2A8E0B4|2023-10-30--23-13-34--0"),
("HYUNDAI2", "regen6CA24BC3035|2023-10-30--23-14-28--0"),
("TOYOTA", "regen5C019D76307|2023-10-30--23-13-31--0"),
("TOYOTA2", "regen5DCADA88A96|2023-10-30--23-14-57--0"),
("TOYOTA3", "regen7204CA3A498|2023-10-30--23-15-55--0"),
("HONDA", "regen048F8FA0B24|2023-10-30--23-15-53--0"),
("HONDA2", "regen7D2D3F82D5B|2023-10-30--23-15-55--0"),
("CHRYSLER", "regen7125C42780C|2023-10-30--23-16-21--0"),
("RAM", "regen2731F3213D2|2023-10-30--23-18-11--0"),
("SUBARU", "regen86E4C1B4DDD|2023-10-30--23-18-14--0"),
("GM", "regenF6393D64745|2023-10-30--23-17-18--0"),
("GM2", "regen220F830C05B|2023-10-30--23-18-39--0"),
("NISSAN", "regen4F671F7C435|2023-10-30--23-18-40--0"),
("VOLKSWAGEN", "regen8BDFE7307A0|2023-10-30--23-19-36--0"),
("MAZDA", "regen2E9F1A15FD5|2023-10-30--23-20-36--0"),
("FORD", "regen6D39E54606E|2023-10-30--23-20-54--0"),
]
# dashcamOnly makes don't need to be tested until a full port is done
excluded_interfaces = ["mock", "tesla"]
ALL_CARS = sorted({car for car, _ in segments})
@pytest.mark.slow
@parameterized_class(('case_name', 'segment'), segments)
class TestCarProcessReplay(TestProcessReplayDiffBase):
"""
Runs a replay diff on a segment for each car.
"""
case_name: Optional[str] = None
tested_cars: List[str] = ALL_CARS
@classmethod
def setUpClass(cls):
if cls.case_name not in cls.tested_cars:
raise unittest.SkipTest(f"{cls.case_name} was not requested to be tested")
super().setUpClass()
def test_all_makes_are_tested(self):
if set(self.tested_cars) != set(ALL_CARS):
raise unittest.SkipTest("skipping check because some cars were skipped via command line")
# check to make sure all car brands are tested
untested = (set(interface_names) - set(excluded_interfaces)) - {c.lower() for c in self.tested_cars}
self.assertEqual(len(untested), 0, f"Cars missing routes: {str(untested)}")
def test_controlsd_engaged(self):
if "controlsd" not in self.tested_procs:
raise unittest.SkipTest("controlsd was not requested to be tested")
# check to make sure openpilot is engaged in the route
log_msgs = self.log_msgs["controlsd"]
self.assertTrue(check_openpilot_enabled(log_msgs), f"Route did not enable at all or for long enough: {self.segment}")
if __name__ == '__main__':
pytest.main([*sys.argv[1:], __file__])