mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 06:33:57 +08:00
* Add support for TinyGrad model runner processing Introduced a new function `is_tinygrad_model` to detect TinyGrad as an active model runner. Updated the `is_stock_model` logic to account for TinyGrad models and added a new process entry for TinyGrad in the model manager. This enables handling TinyGrad models alongside existing configurations. adding modeld back Add support for `modeld_v2` and update paths for consistency Updated `SConscript` files to integrate `modeld_v2` alongside `modeld` and adjusted script paths for correct metadata handling. Adjusted various configurations and scripts, such as `labeler.yaml` and `build_release.sh`, to include `modeld_v2` and ensure cohesive project structure. Refactor imports to use updated `modeld_v2` paths. Replaced outdated `modeld` references with their `modeld_v2` counterparts for consistency and clarity across the codebase. Also updated `.gitignore` to accommodate new directory structure. This change ensures better maintainability and alignment with the new directory schema. Refactor and reorganize modeld to sunnypilot/modeld_v2 structure. Moved and renamed `modeld` components to the new `sunnypilot/modeld_v2` directory for better organization and modularity. Updated imports and file references to align with the new structure, ensuring compatibility and functionality. Streamlined project structure to improve maintainability and future development. * typo * Use `stock` model runner and refactor model checks. Replaces outdated model detection logic with unified `stock` runner integration, simplifying the decision flow for model selection. Includes `stock` as a new enum in the `Runner` type and updates affected references accordingly. * Handle missing 'sim_pose' in model outputs gracefully. Added conditional checks to ensure the code handles cases where 'sim_pose' is absent in the model outputs. Fallback behaviors use 'plan' data when 'sim_pose' is unavailable, preventing potential errors and enhancing robustness.
47 lines
1.8 KiB
Python
Executable File
47 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import time
|
|
|
|
from cereal import car, log, messaging
|
|
from openpilot.common.params import Params
|
|
from openpilot.system.manager.process_config import managed_processes, is_snpe_model, is_tinygrad_model, is_stock_model
|
|
from openpilot.system.hardware import HARDWARE
|
|
|
|
if __name__ == "__main__":
|
|
CP = car.CarParams(notCar=True, wheelbase=1, steerRatio=10)
|
|
params = Params()
|
|
params.put("CarParams", CP.to_bytes())
|
|
|
|
if use_snpe_modeld := is_snpe_model(False, params, CP):
|
|
print("Using SNPE modeld")
|
|
if use_tinygrad_modeld := is_tinygrad_model(False, params, CP):
|
|
print("Using TinyGrad modeld")
|
|
if use_stock_modeld := is_stock_model(False, params, CP):
|
|
print("Using stock modeld")
|
|
|
|
HARDWARE.set_power_save(False)
|
|
|
|
procs = ['camerad', 'ui', 'calibrationd', 'plannerd', 'dmonitoringmodeld', 'dmonitoringd']
|
|
procs += ["modeld_snpe" if use_snpe_modeld else "modeld_tinygrad" if use_tinygrad_modeld else "modeld"]
|
|
for p in procs:
|
|
managed_processes[p].start()
|
|
|
|
pm = messaging.PubMaster(['controlsState', 'deviceState', 'pandaStates', 'carParams'])
|
|
|
|
msgs = {s: messaging.new_message(s) for s in ['controlsState', 'deviceState', 'carParams']}
|
|
msgs['deviceState'].deviceState.started = True
|
|
msgs['deviceState'].deviceState.deviceType = HARDWARE.get_device_type()
|
|
msgs['carParams'].carParams.openpilotLongitudinalControl = True
|
|
|
|
msgs['pandaStates'] = messaging.new_message('pandaStates', 1)
|
|
msgs['pandaStates'].pandaStates[0].ignitionLine = True
|
|
msgs['pandaStates'].pandaStates[0].pandaType = log.PandaState.PandaType.uno
|
|
|
|
try:
|
|
while True:
|
|
time.sleep(1 / 100) # continually send, rate doesn't matter
|
|
for s in msgs:
|
|
pm.send(s, msgs[s])
|
|
except KeyboardInterrupt:
|
|
for p in procs:
|
|
managed_processes[p].stop()
|