mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-21 00:33:44 +08:00
9fb9b73620
# Conflicts: # README.md # SConstruct # conftest.py # docs/CARS.md # msgq_repo # opendbc_repo # openpilot/common/params_keys.h # openpilot/common/params_pyx.pyx # openpilot/common/tests/test_swaglog.cc # openpilot/selfdrive/car/card.py # openpilot/selfdrive/car/tests/test_car_interfaces.py # openpilot/selfdrive/car/tests/test_cruise_speed.py # openpilot/selfdrive/car/tests/test_models.py # openpilot/selfdrive/controls/controlsd.py # openpilot/selfdrive/controls/lib/latcontrol_torque.py # openpilot/selfdrive/controls/lib/longitudinal_planner.py # openpilot/selfdrive/controls/plannerd.py # openpilot/selfdrive/controls/radard.py # openpilot/selfdrive/controls/tests/test_longcontrol.py # openpilot/selfdrive/locationd/torqued.py # openpilot/selfdrive/modeld/modeld.py # openpilot/selfdrive/monitoring/dmonitoringd.py # openpilot/selfdrive/monitoring/test_monitoring.py # openpilot/selfdrive/selfdrived/selfdrived.py # openpilot/selfdrive/selfdrived/tests/test_alertmanager.py # openpilot/selfdrive/test/longitudinal_maneuvers/plant.py # openpilot/selfdrive/test/process_replay/migration.py # openpilot/selfdrive/test/process_replay/process_replay.py # openpilot/selfdrive/ui/feedback/feedbackd.py # openpilot/selfdrive/ui/layouts/settings/device.py # openpilot/selfdrive/ui/layouts/settings/toggles.py # openpilot/selfdrive/ui/mici/layouts/onboarding.py # openpilot/selfdrive/ui/onroad/augmented_road_view.py # openpilot/selfdrive/ui/tests/test_soundd.py # openpilot/selfdrive/ui/translations/app.pot # openpilot/selfdrive/ui/translations/app_de.po # openpilot/selfdrive/ui/translations/app_en.po # openpilot/selfdrive/ui/translations/app_es.po # openpilot/selfdrive/ui/translations/app_fr.po # openpilot/selfdrive/ui/translations/app_ja.po # openpilot/selfdrive/ui/translations/app_ko.po # openpilot/selfdrive/ui/translations/app_pt-BR.po # openpilot/selfdrive/ui/translations/app_th.po # openpilot/selfdrive/ui/translations/app_tr.po # openpilot/selfdrive/ui/translations/app_uk.po # openpilot/selfdrive/ui/translations/app_zh-CHS.po # openpilot/selfdrive/ui/translations/app_zh-CHT.po # openpilot/system/athena/athenad.py # openpilot/system/hardware/hardwared.py # openpilot/system/loggerd/deleter.py # openpilot/system/manager/process_config.py # openpilot/system/ui/lib/application.py # panda # pyproject.toml # tinygrad_repo # uv.lock
52 lines
2.2 KiB
Python
Executable File
52 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
from openpilot.cereal import custom
|
|
from opendbc.car.structs import car
|
|
from openpilot.common.gps import get_gps_location_service
|
|
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(5, 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)
|
|
|
|
cloudlog.info("plannerd is waiting for CarParamsSP")
|
|
CP_SP = messaging.log_from_bytes(params.get("CarParamsSP", block=True), custom.CarParamsSP)
|
|
cloudlog.info("plannerd got CarParamsSP")
|
|
|
|
gps_location_service = get_gps_location_service(params)
|
|
ignore_services = ["liveMapDataSP", "carStateSP", "selfdriveStateSP", gps_location_service]
|
|
|
|
ldw = LaneDepartureWarning()
|
|
longitudinal_planner = LongitudinalPlanner(CP, CP_SP)
|
|
pm = messaging.PubMaster(['longitudinalPlan', 'driverAssistance', 'longitudinalPlanSP'])
|
|
sm = messaging.SubMaster(['carControl', 'carState', 'controlsState', 'vehicleParameters', 'radarState', 'modelV2', 'selfdriveState',
|
|
'liveMapDataSP', 'carStateSP', 'selfdriveStateSP', gps_location_service],
|
|
poll='modelV2', ignore_alive=ignore_services, ignore_avg_freq=ignore_services, ignore_valid=ignore_services)
|
|
|
|
while True:
|
|
sm.update()
|
|
longitudinal_planner.sla.update_buttons(sm['selfdriveStateSP'].buttonsReleaseToggle)
|
|
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()
|