| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -48,6 +48,7 @@ Desire = log.LateralPlan.Desire | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					LaneChangeState = log.LateralPlan.LaneChangeState | 
					 | 
					 | 
					 | 
					LaneChangeState = log.LateralPlan.LaneChangeState | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					LaneChangeDirection = log.LateralPlan.LaneChangeDirection | 
					 | 
					 | 
					 | 
					LaneChangeDirection = log.LateralPlan.LaneChangeDirection | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					EventName = car.CarEvent.EventName | 
					 | 
					 | 
					 | 
					EventName = car.CarEvent.EventName | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					ButtonEvent = car.CarState.ButtonEvent | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					class Controls: | 
					 | 
					 | 
					 | 
					class Controls: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -149,6 +150,7 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.events_prev = [] | 
					 | 
					 | 
					 | 
					    self.events_prev = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.current_alert_types = [ET.PERMANENT] | 
					 | 
					 | 
					 | 
					    self.current_alert_types = [ET.PERMANENT] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.logged_comm_issue = False | 
					 | 
					 | 
					 | 
					    self.logged_comm_issue = False | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    self.button_timers = {ButtonEvent.Type.decelCruise: 0, ButtonEvent.Type.accelCruise: 0} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # TODO: no longer necessary, aside from process replay | 
					 | 
					 | 
					 | 
					    # TODO: no longer necessary, aside from process replay | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.sm['liveParameters'].valid = True | 
					 | 
					 | 
					 | 
					    self.sm['liveParameters'].valid = True | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -367,7 +369,7 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # if stock cruise is completely disabled, then we can use our own set speed logic | 
					 | 
					 | 
					 | 
					    # if stock cruise is completely disabled, then we can use our own set speed logic | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if not self.CP.pcmCruise: | 
					 | 
					 | 
					 | 
					    if not self.CP.pcmCruise: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      self.v_cruise_kph = update_v_cruise(self.v_cruise_kph, CS.buttonEvents, self.enabled) | 
					 | 
					 | 
					 | 
					      self.v_cruise_kph = update_v_cruise(self.v_cruise_kph, CS.buttonEvents, self.button_timers, self.enabled) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    elif self.CP.pcmCruise and CS.cruiseState.enabled: | 
					 | 
					 | 
					 | 
					    elif self.CP.pcmCruise and CS.cruiseState.enabled: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH | 
					 | 
					 | 
					 | 
					      self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -520,6 +522,16 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return actuators, lac_log | 
					 | 
					 | 
					 | 
					    return actuators, lac_log | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  def update_button_timers(self, buttonEvents): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    # increment timer for buttons still pressed | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    for k in self.button_timers.keys(): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      if self.button_timers[k] > 0: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        self.button_timers[k] += 1 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    for b in buttonEvents: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      if b.type.raw in self.button_timers: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        self.button_timers[b.type.raw] = 1 if b.pressed else 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  def publish_logs(self, CS, start_time, actuators, lac_log): | 
					 | 
					 | 
					 | 
					  def publish_logs(self, CS, start_time, actuators, lac_log): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    """Send actuators and hud commands to the car, send controlsstate and MPC logging""" | 
					 | 
					 | 
					 | 
					    """Send actuators and hud commands to the car, send controlsstate and MPC logging""" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -673,6 +685,8 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.publish_logs(CS, start_time, actuators, lac_log) | 
					 | 
					 | 
					 | 
					    self.publish_logs(CS, start_time, actuators, lac_log) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.prof.checkpoint("Sent") | 
					 | 
					 | 
					 | 
					    self.prof.checkpoint("Sent") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    self.update_button_timers(CS.buttonEvents) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  def controlsd_thread(self): | 
					 | 
					 | 
					 | 
					  def controlsd_thread(self): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    while True: | 
					 | 
					 | 
					 | 
					    while True: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      self.step() | 
					 | 
					 | 
					 | 
					      self.step() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |