|  |  |  | @ -10,11 +10,12 @@ from common.conversions import Conversions as CV | 
			
		
	
		
			
				
					|  |  |  |  | from common.kalman.simple_kalman import KF1D | 
			
		
	
		
			
				
					|  |  |  |  | from common.numpy_fast import interp | 
			
		
	
		
			
				
					|  |  |  |  | from common.realtime import DT_CTRL | 
			
		
	
		
			
				
					|  |  |  |  | from selfdrive.car import apply_hysteresis, create_button_enable_events, gen_empty_fingerprint | 
			
		
	
		
			
				
					|  |  |  |  | from selfdrive.car import apply_hysteresis, gen_empty_fingerprint | 
			
		
	
		
			
				
					|  |  |  |  | from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, apply_deadzone | 
			
		
	
		
			
				
					|  |  |  |  | from selfdrive.controls.lib.events import Events | 
			
		
	
		
			
				
					|  |  |  |  | from selfdrive.controls.lib.vehicle_model import VehicleModel | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | ButtonType = car.CarState.ButtonEvent.Type | 
			
		
	
		
			
				
					|  |  |  |  | GearShifter = car.CarState.GearShifter | 
			
		
	
		
			
				
					|  |  |  |  | EventName = car.CarEvent.EventName | 
			
		
	
		
			
				
					|  |  |  |  | TorqueFromLateralAccelCallbackType = Callable[[float, car.CarParams.LateralTorqueTuning, float, float, bool], float] | 
			
		
	
	
		
			
				
					|  |  |  | @ -210,7 +211,8 @@ class CarInterfaceBase(ABC): | 
			
		
	
		
			
				
					|  |  |  |  |   def apply(self, c: car.CarControl) -> Tuple[car.CarControl.Actuators, List[bytes]]: | 
			
		
	
		
			
				
					|  |  |  |  |     pass | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True, allow_enable=True): | 
			
		
	
		
			
				
					|  |  |  |  |   def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True, allow_enable=True, | 
			
		
	
		
			
				
					|  |  |  |  |                            enable_buttons=(ButtonType.accelCruise, ButtonType.decelCruise)): | 
			
		
	
		
			
				
					|  |  |  |  |     events = Events() | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     if cs_out.doorOpen: | 
			
		
	
	
		
			
				
					|  |  |  | @ -244,7 +246,13 @@ class CarInterfaceBase(ABC): | 
			
		
	
		
			
				
					|  |  |  |  |       events.add(EventName.steerOverride) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     # Handle button presses | 
			
		
	
		
			
				
					|  |  |  |  |     events.events.extend(create_button_enable_events(cs_out.buttonEvents, pcm_cruise=self.CP.pcmCruise)) | 
			
		
	
		
			
				
					|  |  |  |  |     for b in cs_out.buttonEvents: | 
			
		
	
		
			
				
					|  |  |  |  |       # Enable OP long on falling edge of enable buttons (defaults to accelCruise and decelCruise, overridable per-port) | 
			
		
	
		
			
				
					|  |  |  |  |       if not self.CP.pcmCruise and (b.type in enable_buttons and not b.pressed): | 
			
		
	
		
			
				
					|  |  |  |  |         events.add(EventName.buttonEnable) | 
			
		
	
		
			
				
					|  |  |  |  |       # Disable on rising edge of cancel for both stock and OP long | 
			
		
	
		
			
				
					|  |  |  |  |       if b.type == ButtonType.cancel and b.pressed: | 
			
		
	
		
			
				
					|  |  |  |  |         events.add(EventName.buttonCancel) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     # Handle permanent and temporary steering faults | 
			
		
	
		
			
				
					|  |  |  |  |     self.steering_unpressed = 0 if cs_out.steeringPressed else self.steering_unpressed + 1 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |