Files
StarPilot/openpilot/starpilot/longitudinal/tests/test_gm_suburban.py
T
firestar5683 80fbb4f6db Feature registration
Register vehicle controls, planner modes, UI actions and Galaxy services after their providers exist. Wire the shared runtime entrypoints and cover their combined behavior.

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Daniel Koepping <elkoled@gmail.com>
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com>
Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com>
Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com>
Co-authored-by: Kacper Rączy <gfw.kra@gmail.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>
Co-authored-by: stef <19478336+stefpi@users.noreply.github.com>
Co-authored-by: whoisdomi <dcantu83@gmail.com>

Co-authored-by: Intelli <contact@intelli.software>
Co-authored-by: haraschax <6804392+haraschax@users.noreply.github.com>
Co-authored-by: prabhaavp <prabhaav@msu.edu>
2026-10-14 20:02:39 -05:00

37 lines
1.6 KiB
Python

"""Suburban stopping ramp through the production longitudinal controller."""
import unittest
from opendbc.car import gen_empty_fingerprint, structs
from opendbc.car.gm.interface import CarInterface
from opendbc.car.gm.values import CAR
from openpilot.selfdrive.controls.lib.longcontrol import LongControl
def params(candidate=CAR.CHEVROLET_SUBURBAN):
fingerprint = gen_empty_fingerprint()
fingerprint[1][0x460] = 8
return CarInterface.get_params(candidate, fingerprint, [], False, False, False)
class TestSuburbanStop(unittest.TestCase):
def test_actual_stopping_ramp_and_profile_isolation(self):
cp = params()
state = structs.CarState(vEgo=0.1)
owner = LongControl(cp)
self.assertAlmostEqual(owner.stopping_decel_rate, 0.8)
for tick in range(1, 51):
accel = owner.update(True, state, 0.0, True, (-4.0, 2.0))
self.assertAlmostEqual(accel, -0.008 * tick)
self.assertEqual(owner.long_control_state, structs.CarControl.Actuators.LongControlState.stopping)
self.assertEqual(owner.update(False, state, 0.0, True, (-4.0, 2.0)), 0.0)
self.assertEqual(LongControl(params(CAR.CHEVROLET_SUBURBAN_ASCM)).stopping_decel_rate, 1.0)
for field, value in (("openpilotLongitudinalControl", False), ("pcmCruise", True),
("networkLocation", structs.CarParams.NetworkLocation.fwdCamera)):
rejected = params()
setattr(rejected, field, value)
self.assertEqual(LongControl(rejected).stopping_decel_rate, 1.0)
rejected = params()
rejected.safetyConfigs[0].safetyParam = 1
self.assertEqual(LongControl(rejected).stopping_decel_rate, 1.0)