@ -57,29 +57,33 @@ TorqueFromLateralAccelCallbackType = Callable[[LatControlInputs, car.CarParams.L 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					@cache @cache  
			
		
	
		
		
			
				
					
					def  get_torque_params ( candidate ) : def  get_torque_params ( ) :  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					  with  open ( TORQUE_SUBSTITUTE_PATH ,  ' rb ' )  as  f :    with  open ( TORQUE_SUBSTITUTE_PATH ,  ' rb ' )  as  f :   
			
		
	
		
		
			
				
					
					    sub  =  tomllib . load ( f )      sub  =  tomllib . load ( f )   
			
		
	
		
		
			
				
					
					  if  candidate  in  sub :   
			
		
	
		
		
			
				
					
					    candidate  =  sub [ candidate ]   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  with  open ( TORQUE_PARAMS_PATH ,  ' rb ' )  as  f :    with  open ( TORQUE_PARAMS_PATH ,  ' rb ' )  as  f :   
			
		
	
		
		
			
				
					
					    params  =  tomllib . load ( f )      params  =  tomllib . load ( f )   
			
		
	
		
		
			
				
					
					  with  open ( TORQUE_OVERRIDE_PATH ,  ' rb ' )  as  f :    with  open ( TORQUE_OVERRIDE_PATH ,  ' rb ' )  as  f :   
			
		
	
		
		
			
				
					
					    override  =  tomllib . load ( f )      override  =  tomllib . load ( f )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  # Ensure no overlap    torque_params  =  { }   
			
				
				
			
		
	
		
		
			
				
					
					  if  sum ( [ candidate  in  x  for  x  in  [ sub ,  params ,  override ] ] )  >  1 :    for  candidate  in  ( sub . keys ( )  |  params . keys ( )  |  override . keys ( ) )  -  { ' legend ' } :   
			
				
				
			
		
	
		
		
			
				
					
					    raise  RuntimeError ( f ' { candidate }  is defined twice in torque config ' )      if  sum ( [ candidate  in  x  for  x  in  [ sub ,  params ,  override ] ] )  >  1 :   
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					      raise  RuntimeError ( f ' { candidate }  is defined twice in torque config ' )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    sub_candidate  =  sub . get ( candidate ,  candidate )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    if  sub_candidate  in  override :   
			
		
	
		
		
			
				
					
					      out  =  override [ sub_candidate ]   
			
		
	
		
		
			
				
					
					    elif  sub_candidate  in  params :   
			
		
	
		
		
			
				
					
					      out  =  params [ sub_candidate ]   
			
		
	
		
		
			
				
					
					    else :   
			
		
	
		
		
			
				
					
					      raise  NotImplementedError ( f " Did not find torque params for  { sub_candidate } " )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  if  candidate  in  override :      torque_params [ sub_candidate ]  =  { key :  out [ i ]  for  i ,  key  in  enumerate ( params [ ' legend ' ] ) }   
			
				
				
			
		
	
		
		
			
				
					
					    out  =  override [ candidate ]      if  candidate  in  sub :   
			
				
				
			
		
	
		
		
			
				
					
					  elif  candidate  in  params :        torque_params [ candidate ]  =  torque_params [ sub_candidate ]   
			
				
				
			
		
	
		
		
			
				
					
					    out  =  params [ candidate ]   
			
		
	
		
		
			
				
					
					  else :   
			
		
	
		
		
			
				
					
					    raise  NotImplementedError ( f " Did not find torque params for  { candidate } " )   
			
		
	
		
		
			
				
					
					  return  { key :  out [ i ]  for  i ,  key  in  enumerate ( params [ ' legend ' ] ) }   
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  return  torque_params   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					# generic car and radar interfaces # generic car and radar interfaces  
			
		
	
		
		
			
				
					
					
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -180,7 +184,7 @@ class CarInterfaceBase(ABC): 
			
		
	
		
		
			
				
					
					    ret . carFingerprint  =  candidate      ret . carFingerprint  =  candidate   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    # Car docs fields      # Car docs fields   
			
		
	
		
		
			
				
					
					    ret . maxLateralAccel  =  get_torque_params ( candidate ) [ ' MAX_LAT_ACCEL_MEASURED ' ]      ret . maxLateralAccel  =  get_torque_params ( ) [ candidate ] [ ' MAX_LAT_ACCEL_MEASURED ' ]   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					    ret . autoResumeSng  =  True   # describes whether car can resume from a stop automatically      ret . autoResumeSng  =  True   # describes whether car can resume from a stop automatically   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    # standard ALC params      # standard ALC params   
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -213,7 +217,7 @@ class CarInterfaceBase(ABC): 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  @staticmethod    @staticmethod   
			
		
	
		
		
			
				
					
					  def  configure_torque_tune ( candidate ,  tune ,  steering_angle_deadzone_deg = 0.0 ,  use_steering_angle = True ) :    def  configure_torque_tune ( candidate ,  tune ,  steering_angle_deadzone_deg = 0.0 ,  use_steering_angle = True ) :   
			
		
	
		
		
			
				
					
					    params  =  get_torque_params ( candidate )      params  =  get_torque_params ( ) [ candidate ]   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    tune . init ( ' torque ' )      tune . init ( ' torque ' )   
			
		
	
		
		
			
				
					
					    tune . torque . useSteeringAngle  =  use_steering_angle      tune . torque . useSteeringAngle  =  use_steering_angle