| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -4,7 +4,7 @@ from selfdrive.config import Conversions as CV | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from selfdrive.boardd.boardd import can_list_to_can_capnp | 
					 | 
					 | 
					 | 
					from selfdrive.boardd.boardd import can_list_to_can_capnp | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from selfdrive.car import apply_std_steer_torque_limits | 
					 | 
					 | 
					 | 
					from selfdrive.car import apply_std_steer_torque_limits | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from selfdrive.car.gm import gmcan | 
					 | 
					 | 
					 | 
					from selfdrive.car.gm import gmcan | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from selfdrive.car.gm.values import CAR, DBC, AccState | 
					 | 
					 | 
					 | 
					from selfdrive.car.gm.values import CAR, DBC | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from selfdrive.can.packer import CANPacker | 
					 | 
					 | 
					 | 
					from selfdrive.can.packer import CANPacker | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -29,11 +29,11 @@ class CarControllerParams(): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.ADAS_KEEPALIVE_STEP = 10 | 
					 | 
					 | 
					 | 
					    self.ADAS_KEEPALIVE_STEP = 10 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # pedal lookups, only for Volt | 
					 | 
					 | 
					 | 
					    # pedal lookups, only for Volt | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    MAX_GAS = 3072              # Only a safety limit | 
					 | 
					 | 
					 | 
					    MAX_GAS = 3072              # Only a safety limit | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.ZERO_GAS = 2048 | 
					 | 
					 | 
					 | 
					    ZERO_GAS = 2048 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    MAX_BRAKE = 350             # Should be around 3.5m/s^2, including regen | 
					 | 
					 | 
					 | 
					    MAX_BRAKE = 350             # Should be around 3.5m/s^2, including regen | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.MAX_ACC_REGEN = 1404  # ACC Regen braking is slightly less powerful than max regen paddle | 
					 | 
					 | 
					 | 
					    self.MAX_ACC_REGEN = 1404  # ACC Regen braking is slightly less powerful than max regen paddle | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.GAS_LOOKUP_BP = [-0.25, 0., 0.5] | 
					 | 
					 | 
					 | 
					    self.GAS_LOOKUP_BP = [-0.25, 0., 0.5] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, self.ZERO_GAS, MAX_GAS] | 
					 | 
					 | 
					 | 
					    self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, ZERO_GAS, MAX_GAS] | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.BRAKE_LOOKUP_BP = [-1., -0.25] | 
					 | 
					 | 
					 | 
					    self.BRAKE_LOOKUP_BP = [-1., -0.25] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.BRAKE_LOOKUP_V = [MAX_BRAKE, 0] | 
					 | 
					 | 
					 | 
					    self.BRAKE_LOOKUP_V = [MAX_BRAKE, 0] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -83,6 +83,7 @@ class CarController(object): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      return | 
					 | 
					 | 
					 | 
					      return | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    P = self.params | 
					 | 
					 | 
					 | 
					    P = self.params | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # Send CAN commands. | 
					 | 
					 | 
					 | 
					    # Send CAN commands. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    can_sends = [] | 
					 | 
					 | 
					 | 
					    can_sends = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    canbus = self.canbus | 
					 | 
					 | 
					 | 
					    canbus = self.canbus | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -130,18 +131,12 @@ class CarController(object): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if (frame % 4) == 0: | 
					 | 
					 | 
					 | 
					      if (frame % 4) == 0: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        idx = (frame / 4) % 4 | 
					 | 
					 | 
					 | 
					        idx = (frame / 4) % 4 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        car_stopping = apply_gas < P.ZERO_GAS | 
					 | 
					 | 
					 | 
					        at_full_stop = enabled and CS.standstill | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        standstill = CS.pcm_acc_status == AccState.STANDSTILL | 
					 | 
					 | 
					 | 
					        near_stop = enabled and (CS.v_ego < P.NEAR_STOP_BRAKE_PHASE) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        at_full_stop = enabled and standstill and car_stopping | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        near_stop = enabled and (CS.v_ego < P.NEAR_STOP_BRAKE_PHASE) and car_stopping | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, canbus.chassis, apply_brake, idx, near_stop, at_full_stop)) | 
					 | 
					 | 
					 | 
					        can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, canbus.chassis, apply_brake, idx, near_stop, at_full_stop)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        # Auto-resume from full stop by resetting ACC control | 
					 | 
					 | 
					 | 
					        at_full_stop = enabled and CS.standstill | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        acc_enabled = enabled | 
					 | 
					 | 
					 | 
					        can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, canbus.powertrain, apply_gas, idx, enabled, at_full_stop)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if standstill and not car_stopping: | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          acc_enabled = False | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, canbus.powertrain, apply_gas, idx, acc_enabled, at_full_stop)) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # Send dashboard UI commands (ACC status), 25hz | 
					 | 
					 | 
					 | 
					      # Send dashboard UI commands (ACC status), 25hz | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if (frame % 4) == 0: | 
					 | 
					 | 
					 | 
					      if (frame % 4) == 0: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |