mirror of https://github.com/commaai/openpilot.git
cleanup old sm pm args (#30241)
* cleanup sm pm
* fix controlsd
* fix
old-commit-hash: b68cfbb332
This commit is contained in:
parent
db2344cdd2
commit
4b78e52e34
|
@ -56,39 +56,33 @@ ENABLED_STATES = (State.preEnabled, *ACTIVE_STATES)
|
|||
|
||||
|
||||
class Controls:
|
||||
def __init__(self, sm=None, pm=None, can_sock=None, CI=None):
|
||||
def __init__(self, CI=None):
|
||||
config_realtime_process(4, Priority.CTRL_HIGH)
|
||||
|
||||
# Ensure the current branch is cached, otherwise the first iteration of controlsd lags
|
||||
self.branch = get_short_branch("")
|
||||
|
||||
# Setup sockets
|
||||
self.pm = pm
|
||||
if self.pm is None:
|
||||
self.pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState',
|
||||
'carControl', 'carEvents', 'carParams'])
|
||||
self.pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState',
|
||||
'carControl', 'carEvents', 'carParams'])
|
||||
|
||||
self.sensor_packets = ["accelerometer", "gyroscope"]
|
||||
self.camera_packets = ["roadCameraState", "driverCameraState", "wideRoadCameraState"]
|
||||
|
||||
self.can_sock = can_sock
|
||||
if can_sock is None:
|
||||
can_timeout = None if os.environ.get('NO_CAN_TIMEOUT', False) else 20
|
||||
self.can_sock = messaging.sub_sock('can', timeout=can_timeout)
|
||||
can_timeout = None if os.environ.get('NO_CAN_TIMEOUT', False) else 20
|
||||
self.can_sock = messaging.sub_sock('can', timeout=can_timeout)
|
||||
|
||||
self.log_sock = messaging.sub_sock('androidLog')
|
||||
|
||||
self.params = Params()
|
||||
self.sm = sm
|
||||
if self.sm is None:
|
||||
ignore = self.sensor_packets + ['testJoystick']
|
||||
if SIMULATION:
|
||||
ignore += ['driverCameraState', 'managerState']
|
||||
self.sm = messaging.SubMaster(['deviceState', 'pandaStates', 'peripheralState', 'modelV2', 'liveCalibration',
|
||||
'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman',
|
||||
'managerState', 'liveParameters', 'radarState', 'liveTorqueParameters',
|
||||
'testJoystick'] + self.camera_packets + self.sensor_packets,
|
||||
ignore_alive=ignore, ignore_avg_freq=['radarState', 'testJoystick'])
|
||||
ignore = self.sensor_packets + ['testJoystick']
|
||||
if SIMULATION:
|
||||
ignore += ['driverCameraState', 'managerState']
|
||||
self.sm = messaging.SubMaster(['deviceState', 'pandaStates', 'peripheralState', 'modelV2', 'liveCalibration',
|
||||
'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman',
|
||||
'managerState', 'liveParameters', 'radarState', 'liveTorqueParameters',
|
||||
'testJoystick'] + self.camera_packets + self.sensor_packets,
|
||||
ignore_alive=ignore, ignore_avg_freq=['radarState', 'testJoystick'])
|
||||
|
||||
if CI is None:
|
||||
# wait for one pandaState and one CAN packet
|
||||
|
@ -879,8 +873,8 @@ class Controls:
|
|||
self.prof.display()
|
||||
|
||||
|
||||
def main(sm=None, pm=None, logcan=None):
|
||||
controls = Controls(sm, pm, logcan)
|
||||
def main():
|
||||
controls = Controls()
|
||||
controls.controlsd_thread()
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ def publish_ui_plan(sm, pm, lateral_planner, longitudinal_planner):
|
|||
uiPlan.accel = longitudinal_planner.a_desired_trajectory_full.tolist()
|
||||
pm.send('uiPlan', ui_send)
|
||||
|
||||
def plannerd_thread(sm=None, pm=None):
|
||||
def plannerd_thread():
|
||||
config_realtime_process(5, Priority.CTRL_LOW)
|
||||
|
||||
cloudlog.info("plannerd is waiting for CarParams")
|
||||
|
@ -41,12 +41,9 @@ def plannerd_thread(sm=None, pm=None):
|
|||
longitudinal_planner = LongitudinalPlanner(CP)
|
||||
lateral_planner = LateralPlanner(CP, debug=debug_mode)
|
||||
|
||||
if sm is None:
|
||||
sm = messaging.SubMaster(['carControl', 'carState', 'controlsState', 'radarState', 'modelV2'],
|
||||
poll=['radarState', 'modelV2'], ignore_avg_freq=['radarState'])
|
||||
|
||||
if pm is None:
|
||||
pm = messaging.PubMaster(['longitudinalPlan', 'lateralPlan', 'uiPlan'])
|
||||
pm = messaging.PubMaster(['longitudinalPlan', 'lateralPlan', 'uiPlan'])
|
||||
sm = messaging.SubMaster(['carControl', 'carState', 'controlsState', 'radarState', 'modelV2'],
|
||||
poll=['radarState', 'modelV2'], ignore_avg_freq=['radarState'])
|
||||
|
||||
while True:
|
||||
sm.update()
|
||||
|
@ -58,8 +55,8 @@ def plannerd_thread(sm=None, pm=None):
|
|||
longitudinal_planner.publish(sm, pm)
|
||||
publish_ui_plan(sm, pm, lateral_planner, longitudinal_planner)
|
||||
|
||||
def main(sm=None, pm=None):
|
||||
plannerd_thread(sm, pm)
|
||||
def main():
|
||||
plannerd_thread()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -440,7 +440,7 @@ def clear_tmp_cache():
|
|||
os.mkdir(Paths.download_cache_root())
|
||||
|
||||
|
||||
def main(sm=None, pm=None):
|
||||
def main():
|
||||
#clear_tmp_cache()
|
||||
|
||||
use_qcom = not Params().get_bool("UbloxAvailable")
|
||||
|
@ -449,8 +449,7 @@ def main(sm=None, pm=None):
|
|||
else:
|
||||
raw_name = "ubloxGnss"
|
||||
raw_gnss_sock = messaging.sub_sock(raw_name, conflate=False)
|
||||
if pm is None:
|
||||
pm = messaging.PubMaster(['gnssMeasurements'])
|
||||
pm = messaging.PubMaster(['gnssMeasurements'])
|
||||
|
||||
# disable until set as main gps source, to better analyze startup time
|
||||
# TODO ensure low CPU usage before enabling
|
||||
|
|
|
@ -117,16 +117,14 @@ def check_valid_with_hysteresis(current_valid: bool, val: float, threshold: floa
|
|||
return current_valid
|
||||
|
||||
|
||||
def main(sm=None, pm=None):
|
||||
def main():
|
||||
config_realtime_process([0, 1, 2, 3], 5)
|
||||
|
||||
DEBUG = bool(int(os.getenv("DEBUG", "0")))
|
||||
REPLAY = bool(int(os.getenv("REPLAY", "0")))
|
||||
|
||||
if sm is None:
|
||||
sm = messaging.SubMaster(['liveLocationKalman', 'carState'], poll=['liveLocationKalman'])
|
||||
if pm is None:
|
||||
pm = messaging.PubMaster(['liveParameters'])
|
||||
pm = messaging.PubMaster(['liveParameters'])
|
||||
sm = messaging.SubMaster(['liveLocationKalman', 'carState'], poll=['liveLocationKalman'])
|
||||
|
||||
params_reader = Params()
|
||||
# wait for stats about the car to come in from controls
|
||||
|
|
|
@ -218,14 +218,11 @@ class TorqueEstimator:
|
|||
return msg
|
||||
|
||||
|
||||
def main(sm=None, pm=None):
|
||||
def main():
|
||||
config_realtime_process([0, 1, 2, 3], 5)
|
||||
|
||||
if sm is None:
|
||||
sm = messaging.SubMaster(['carControl', 'carState', 'liveLocationKalman'], poll=['liveLocationKalman'])
|
||||
|
||||
if pm is None:
|
||||
pm = messaging.PubMaster(['liveTorqueParameters'])
|
||||
pm = messaging.PubMaster(['liveTorqueParameters'])
|
||||
sm = messaging.SubMaster(['carControl', 'carState', 'liveLocationKalman'], poll=['liveLocationKalman'])
|
||||
|
||||
params = Params()
|
||||
with car.CarParams.from_bytes(params.get("CarParams", block=True)) as CP:
|
||||
|
|
|
@ -10,15 +10,12 @@ from openpilot.selfdrive.controls.lib.events import Events
|
|||
from openpilot.selfdrive.monitoring.driver_monitor import DriverStatus
|
||||
|
||||
|
||||
def dmonitoringd_thread(sm=None, pm=None):
|
||||
def dmonitoringd_thread():
|
||||
gc.disable()
|
||||
set_realtime_priority(2)
|
||||
|
||||
if pm is None:
|
||||
pm = messaging.PubMaster(['driverMonitoringState'])
|
||||
|
||||
if sm is None:
|
||||
sm = messaging.SubMaster(['driverStateV2', 'liveCalibration', 'carState', 'controlsState', 'modelV2'], poll=['driverStateV2'])
|
||||
pm = messaging.PubMaster(['driverMonitoringState'])
|
||||
sm = messaging.SubMaster(['driverStateV2', 'liveCalibration', 'carState', 'controlsState', 'modelV2'], poll=['driverStateV2'])
|
||||
|
||||
driver_status = DriverStatus(rhd_saved=Params().get_bool("IsRhdDetected"))
|
||||
|
||||
|
@ -89,8 +86,8 @@ def dmonitoringd_thread(sm=None, pm=None):
|
|||
driver_status.wheel_on_right == (driver_status.wheelpos_learner.filtered_stat.M > driver_status.settings._WHEELPOS_THRESHOLD)):
|
||||
put_bool_nonblocking("IsRhdDetected", driver_status.wheel_on_right)
|
||||
|
||||
def main(sm=None, pm=None):
|
||||
dmonitoringd_thread(sm, pm)
|
||||
def main():
|
||||
dmonitoringd_thread()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -344,11 +344,9 @@ class RouteEngine:
|
|||
# TODO: Check for going wrong way in segment
|
||||
|
||||
|
||||
def main(sm=None, pm=None):
|
||||
if sm is None:
|
||||
sm = messaging.SubMaster(['liveLocationKalman', 'managerState'])
|
||||
if pm is None:
|
||||
pm = messaging.PubMaster(['navInstruction', 'navRoute'])
|
||||
def main():
|
||||
pm = messaging.PubMaster(['navInstruction', 'navRoute'])
|
||||
sm = messaging.SubMaster(['liveLocationKalman', 'managerState'])
|
||||
|
||||
rk = Ratekeeper(1.0)
|
||||
route_engine = RouteEngine(sm, pm)
|
||||
|
|
|
@ -40,9 +40,9 @@ def apply_a_weighting(measurements: np.ndarray) -> np.ndarray:
|
|||
|
||||
|
||||
class Mic:
|
||||
def __init__(self, pm):
|
||||
self.pm = pm
|
||||
def __init__(self):
|
||||
self.rk = Ratekeeper(RATE)
|
||||
self.pm = messaging.PubMaster(['microphone'])
|
||||
|
||||
self.measurements = np.empty(0)
|
||||
|
||||
|
@ -93,11 +93,8 @@ class Mic:
|
|||
self.update()
|
||||
|
||||
|
||||
def main(pm=None):
|
||||
if pm is None:
|
||||
pm = messaging.PubMaster(['microphone'])
|
||||
|
||||
mic = Mic(pm)
|
||||
def main():
|
||||
mic = Mic()
|
||||
mic.micd_thread()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue