Files
sunnypilot/openpilot/selfdrive/controls/plannerd.py
T
ferb-comma d0800d005e radard, plannerd: move off the ui's core (#39432)
On a comma 3X the ui renders on the CPU since AGNOS 20.4 and runs above
radard and plannerd on core 5. With a full-screen alert it takes the whole
frame, radarState drops below 16 Hz and openpilot soft-disables
(commIssueAvgFreq). Core 6 only has camerad.

Asked by: shane

Co-authored-by: ferb-comma <358214594+ferb-comma@users.noreply.github.com>
2026-11-20 09:33:03 -08:00

41 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
from opendbc.car.structs import car
from openpilot.common.params import Params
from openpilot.common.realtime import Priority, config_realtime_process
from openpilot.common.swaglog import cloudlog
from openpilot.selfdrive.controls.lib.ldw import LaneDepartureWarning
from openpilot.selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner
import openpilot.cereal.messaging as messaging
def main():
config_realtime_process(6, Priority.CTRL_LOW)
cloudlog.info("plannerd is waiting for CarParams")
params = Params()
CP = messaging.log_from_bytes(params.get("CarParams", block=True), car.CarParams)
cloudlog.info("plannerd got CarParams: %s", CP.brand)
ldw = LaneDepartureWarning()
longitudinal_planner = LongitudinalPlanner(CP)
pm = messaging.PubMaster(['longitudinalPlan', 'driverAssistance'])
sm = messaging.SubMaster(['carControl', 'carState', 'controlsState', 'radarState', 'modelV2', 'selfdriveState', 'vehicleParameters'],
poll='modelV2')
while True:
sm.update()
if sm.updated['modelV2']:
longitudinal_planner.update(sm)
longitudinal_planner.publish(sm, pm)
ldw.update(sm.frame, sm['modelV2'], sm['carState'], sm['carControl'])
msg = messaging.new_message('driverAssistance')
msg.valid = sm.all_checks()
msg.driverAssistance.leftLaneDeparture = ldw.left
msg.driverAssistance.rightLaneDeparture = ldw.right
pm.send('driverAssistance', msg)
if __name__ == "__main__":
main()