You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							49 lines
						
					
					
						
							1.5 KiB
						
					
					
				
			
		
		
	
	
							49 lines
						
					
					
						
							1.5 KiB
						
					
					
				| #!/usr/bin/env python3
 | |
| from cereal import car
 | |
| from common.params import Params
 | |
| from common.realtime import Priority, config_realtime_process
 | |
| from selfdrive.swaglog import cloudlog
 | |
| from selfdrive.controls.lib.longitudinal_planner import Planner
 | |
| from selfdrive.controls.lib.lateral_planner import LateralPlanner
 | |
| from selfdrive.hardware import TICI
 | |
| import cereal.messaging as messaging
 | |
| 
 | |
| 
 | |
| def plannerd_thread(sm=None, pm=None):
 | |
|   config_realtime_process(5 if TICI else 2, Priority.CTRL_LOW)
 | |
| 
 | |
|   cloudlog.info("plannerd is waiting for CarParams")
 | |
|   params = Params()
 | |
|   CP = car.CarParams.from_bytes(params.get("CarParams", block=True))
 | |
|   cloudlog.info("plannerd got CarParams: %s", CP.carName)
 | |
| 
 | |
|   use_lanelines = not params.get_bool('EndToEndToggle')
 | |
|   wide_camera = params.get_bool('EnableWideCamera') if TICI else False
 | |
| 
 | |
|   longitudinal_planner = Planner(CP)
 | |
|   lateral_planner = LateralPlanner(CP, use_lanelines=use_lanelines, wide_camera=wide_camera)
 | |
| 
 | |
|   if sm is None:
 | |
|     sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'modelV2'],
 | |
|                              poll=['radarState', 'modelV2'])
 | |
| 
 | |
|   if pm is None:
 | |
|     pm = messaging.PubMaster(['longitudinalPlan', 'liveLongitudinalMpc', 'lateralPlan', 'liveMpc'])
 | |
| 
 | |
|   while True:
 | |
|     sm.update()
 | |
| 
 | |
|     if sm.updated['modelV2']:
 | |
|       lateral_planner.update(sm, CP)
 | |
|       lateral_planner.publish(sm, pm)
 | |
|     if sm.updated['radarState']:
 | |
|       longitudinal_planner.update(sm, CP)
 | |
|       longitudinal_planner.publish(sm, pm)
 | |
| 
 | |
| 
 | |
| def main(sm=None, pm=None):
 | |
|   plannerd_thread(sm, pm)
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|   main()
 | |
| 
 |