mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-10 02:03:42 +08:00
Update disturbance_controller.py
This commit is contained in:
@@ -40,20 +40,21 @@ class DisturbanceController:
|
||||
def highpass_filter(self, current_value, lowpass_value):
|
||||
return current_value - lowpass_value
|
||||
|
||||
def compensate(self, CS, VM, params, calibrated_pose, desired_curvature):
|
||||
def get_correction(self, CS, VM, params, calibrated_pose, desired_curvature):
|
||||
if calibrated_pose is None:
|
||||
return desired_curvature
|
||||
|
||||
actual_curvature_vm = -VM.calc_curvature(math.radians(CS.steeringAngleDeg - params.angleOffsetDeg), CS.vEgo, 0.)
|
||||
actual_curvature_3dof = -VM.calc_curvature_3dof(calibrated_pose.acceleration.y, calibrated_pose.acceleration.x, calibrated_pose.angular_velocity.yaw,
|
||||
CS.vEgo, math.radians(CS.steeringAngleDeg - params.angleOffsetDeg), 0.)
|
||||
|
||||
steering_angle_without_offset = math.radians(CS.steeringAngleDeg - params.angleOffsetDeg)
|
||||
actual_curvature_vm = -VM.calc_curvature(steering_angle_without_offset, CS.vEgo, 0.)
|
||||
actual_curvature_3dof = -VM.calc_curvature_3dof(calibrated_pose.acceleration.y, calibrated_pose.acceleration.x,
|
||||
calibrated_pose.angular_velocity.yaw, CS.vEgo, steering_angle_without_offset, 0.)
|
||||
actual_curvature = np.interp(CS.vEgo, [2.0, 5.0], [actual_curvature_vm, actual_curvature_3dof])
|
||||
|
||||
alpha = self.compute_dynamic_alpha(desired_curvature)
|
||||
reaction = self.lowpass_filter(actual_curvature, alpha)
|
||||
disturbance = self.highpass_filter(actual_curvature, reaction)
|
||||
|
||||
error = desired_curvature - disturbance
|
||||
output_curvature = self.pid.update(error, feedforward=desired_curvature, speed=CS.vEgo)
|
||||
error = -disturbance
|
||||
correction = self.pid.update(error, feedforward=0.0, speed=CS.vEgo)
|
||||
|
||||
return float(output_curvature)
|
||||
return float(correction)
|
||||
|
||||
Reference in New Issue
Block a user