|
|
|
@ -2,10 +2,8 @@ |
|
|
|
|
import numpy as np |
|
|
|
|
from cereal import car |
|
|
|
|
from common.numpy_fast import clip, interp |
|
|
|
|
from common.realtime import DT_CTRL |
|
|
|
|
from selfdrive.swaglog import cloudlog |
|
|
|
|
from selfdrive.config import Conversions as CV |
|
|
|
|
from selfdrive.controls.lib.events import ET |
|
|
|
|
from selfdrive.car.honda.values import CruiseButtons, CAR, HONDA_BOSCH, HONDA_BOSCH_ALT_BRAKE_SIGNAL |
|
|
|
|
from selfdrive.car import STD_CARGO_KG, CivicParams, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint |
|
|
|
|
from selfdrive.controls.lib.longitudinal_planner import _A_CRUISE_MAX_V_FOLLOWING |
|
|
|
@ -75,9 +73,6 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
def __init__(self, CP, CarController, CarState): |
|
|
|
|
super().__init__(CP, CarController, CarState) |
|
|
|
|
|
|
|
|
|
self.last_enable_pressed = 0 |
|
|
|
|
self.last_enable_sent = 0 |
|
|
|
|
|
|
|
|
|
if self.CS.CP.carFingerprint == CAR.ACURA_ILX: |
|
|
|
|
self.compute_gb = get_compute_gb_acura() |
|
|
|
|
else: |
|
|
|
@ -488,7 +483,7 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
ret.buttonEvents = buttonEvents |
|
|
|
|
|
|
|
|
|
# events |
|
|
|
|
events = self.create_common_events(ret, pcm_enable=False) |
|
|
|
|
events = self.create_common_events(ret, pcm_enable=self.CP.enableCruise) |
|
|
|
|
if self.CS.brake_error: |
|
|
|
|
events.add(EventName.brakeUnavailable) |
|
|
|
|
if self.CS.brake_hold and self.CS.CP.openpilotLongitudinalControl: |
|
|
|
@ -511,34 +506,18 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
if self.CS.CP.minEnableSpeed > 0 and ret.vEgo < 0.001: |
|
|
|
|
events.add(EventName.manualRestart) |
|
|
|
|
|
|
|
|
|
cur_time = self.frame * DT_CTRL |
|
|
|
|
enable_pressed = False |
|
|
|
|
# handle button presses |
|
|
|
|
for b in ret.buttonEvents: |
|
|
|
|
|
|
|
|
|
# do enable on both accel and decel buttons |
|
|
|
|
if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: |
|
|
|
|
self.last_enable_pressed = cur_time |
|
|
|
|
enable_pressed = True |
|
|
|
|
if not self.CP.enableCruise: |
|
|
|
|
events.add(EventName.buttonEnable) |
|
|
|
|
|
|
|
|
|
# do disable on button down |
|
|
|
|
if b.type == "cancel" and b.pressed: |
|
|
|
|
if b.type == ButtonType.cancel and b.pressed: |
|
|
|
|
events.add(EventName.buttonCancel) |
|
|
|
|
|
|
|
|
|
if self.CP.enableCruise: |
|
|
|
|
# KEEP THIS EVENT LAST! send enable event if button is pressed and there are |
|
|
|
|
# NO_ENTRY events, so controlsd will display alerts. Also not send enable events |
|
|
|
|
# too close in time, so a no_entry will not be followed by another one. |
|
|
|
|
# TODO: button press should be the only thing that triggers enable |
|
|
|
|
if ((cur_time - self.last_enable_pressed) < 0.2 and |
|
|
|
|
(cur_time - self.last_enable_sent) > 0.2 and |
|
|
|
|
ret.cruiseState.enabled) or \ |
|
|
|
|
(enable_pressed and events.any(ET.NO_ENTRY)): |
|
|
|
|
events.add(EventName.buttonEnable) |
|
|
|
|
self.last_enable_sent = cur_time |
|
|
|
|
elif enable_pressed: |
|
|
|
|
events.add(EventName.buttonEnable) |
|
|
|
|
|
|
|
|
|
ret.events = events.to_msg() |
|
|
|
|
|
|
|
|
|
self.CS.out = ret.as_reader() |
|
|
|
|