|  |  |  | @ -19,8 +19,7 @@ from selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY | 
			
		
	
		
			
				
					|  |  |  |  | # move it at all, this is compensated for too. | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | LOW_SPEED_FACTOR = 200 | 
			
		
	
		
			
				
					|  |  |  |  | JERK_THRESHOLD = 0.2 | 
			
		
	
		
			
				
					|  |  |  |  | FRICTION_THRESHOLD = 0.2 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | def set_torque_tune(tune, MAX_LAT_ACCEL=2.5, FRICTION=0.01, steering_angle_deadzone_deg=0.0): | 
			
		
	
	
		
			
				
					|  |  |  | @ -66,14 +65,16 @@ class LatControlTorque(LatControl): | 
			
		
	
		
			
				
					|  |  |  |  |       actual_lateral_accel = actual_curvature * CS.vEgo ** 2 | 
			
		
	
		
			
				
					|  |  |  |  |       lateral_accel_deadzone = curvature_deadzone * CS.vEgo ** 2 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |       setpoint = desired_lateral_accel + LOW_SPEED_FACTOR * desired_curvature | 
			
		
	
		
			
				
					|  |  |  |  |       measurement = actual_lateral_accel + LOW_SPEED_FACTOR * actual_curvature | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |       low_speed_factor = interp(CS.vEgo, [0, 15], [500, 0]) | 
			
		
	
		
			
				
					|  |  |  |  |       setpoint = desired_lateral_accel + low_speed_factor * desired_curvature | 
			
		
	
		
			
				
					|  |  |  |  |       measurement = actual_lateral_accel + low_speed_factor * actual_curvature | 
			
		
	
		
			
				
					|  |  |  |  |       error = apply_deadzone(setpoint - measurement, lateral_accel_deadzone) | 
			
		
	
		
			
				
					|  |  |  |  |       pid_log.error = error | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |       ff = desired_lateral_accel - params.roll * ACCELERATION_DUE_TO_GRAVITY | 
			
		
	
		
			
				
					|  |  |  |  |       # convert friction into lateral accel units for feedforward | 
			
		
	
		
			
				
					|  |  |  |  |       friction_compensation = interp(error, [-JERK_THRESHOLD, JERK_THRESHOLD], [-self.friction, self.friction]) | 
			
		
	
		
			
				
					|  |  |  |  |       friction_compensation = interp(error, [-FRICTION_THRESHOLD, FRICTION_THRESHOLD], [-self.friction, self.friction]) | 
			
		
	
		
			
				
					|  |  |  |  |       ff += friction_compensation / self.kf | 
			
		
	
		
			
				
					|  |  |  |  |       freeze_integrator = CS.steeringRateLimited or CS.steeringPressed or CS.vEgo < 5 | 
			
		
	
		
			
				
					|  |  |  |  |       output_torque = self.pid.update(error, | 
			
		
	
	
		
			
				
					|  |  |  | 
 |