From d18a0868c667ba17d838b22eefcfa77cef5e869f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 11 Aug 2024 22:25:08 -0500 Subject: [PATCH] move the body events to card (#33262) * move the body events to card * rm import old-commit-hash: 093c09a7373868a77d8f9e56f7f26304601855dc --- selfdrive/car/body/interface.py | 10 +--------- selfdrive/car/card.py | 6 ++++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/selfdrive/car/body/interface.py b/selfdrive/car/body/interface.py index 50564d3ed..29d55c934 100644 --- a/selfdrive/car/body/interface.py +++ b/selfdrive/car/body/interface.py @@ -1,6 +1,6 @@ import math from cereal import car -from openpilot.selfdrive.car import DT_CTRL, get_safety_config +from openpilot.selfdrive.car import get_safety_config from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.car.body.values import SPEED_FROM_RPM @@ -27,12 +27,4 @@ class CarInterface(CarInterfaceBase): def _update(self, c): ret = self.CS.update(self.cp) - # wait for everything to init first - if self.frame > int(5. / DT_CTRL): - # body always wants to enable - ret.init('events', 1) - ret.events[0].name = car.CarEvent.EventName.pcmEnable - ret.events[0].enable = True - self.frame += 1 - return ret diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index d091f3104..0f26681a0 100755 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -159,6 +159,12 @@ class Car: self.events.add_from_msg(CS.events) + if self.CP.notCar: + # wait for everything to init first + if self.sm.frame > int(5. / DT_CTRL) and self.initialized_prev: + # body always wants to enable + self.events.add(EventName.pcmEnable) + # Disable on rising edge of accelerator or brake. Also disable on brake when speed > 0 if (CS.gasPressed and not self.CS_prev.gasPressed and self.disengage_on_accelerator) or \ (CS.brakePressed and (not self.CS_prev.brakePressed or not CS.standstill)) or \