PID Controller Gain adjust

1 visualizzazione (ultimi 30 giorni)
labtst
labtst il 16 Gen 2024
Modificato: Sam Chak il 13 Giu 2024
Hallo Jungs bitte jemand mir helfen?: habe einen pid-Regler für ein Selfdriving car entwickeln. das Problem ist das Fahrzeug fährt nicht in Centerline wie geplann und nach änderung der Strecke, wird der Fehler noch schlimer. kann jemand mir helfen?
function LateralLongitudinal_Controller(obj, cte)
kp_lat = 0.08; % Parameter für laterale Regelung
kd_lat = 0.8;
ki_lat = 0.000002;
kp_lon = 0.1; % Parameter für longitudinale Regelung
kd_lon = 0.01;
ki_lon = 0.000001;
dcte = cte - obj.old_cte;
obj.cte_intergral = obj.cte_intergral + cte;
% Anti-Windup für den integralen Anteil
obj.cte_intergral = max(-obj.steering_angle_limit / ki_lat, min(obj.steering_angle_limit / ki_lat, obj.cte_intergral));
obj.old_cte = cte;
% Lateral Control (quer)
steering = kp_lat * cte + kd_lat * dcte + ki_lat * obj.cte_intergral;
% Begrenzen Sie den Lenkwinkel
steering = max(-obj.steering_angle_limit, min(obj.steering_angle_limit, steering));
% Longitudinal Control (längs)
desired_velocity = obj.max_velocity; % Setzen Sie die gewünschte Geschwindigkeit
velocity_error = desired_velocity - obj.states(4);
% Fügen Sie die max_acceleration-Eigenschaft hinzu
max_acceleration = 10.0; % Setzen Sie hier den gewünschten maximalen Beschleunigungswert ein
% Reduziere die Geschwindigkeit in der Nähe von Kurven
curvature_threshold = 0.4; % Setzen Sie den Krümmungsschwellenwert ein
if abs(cte) > curvature_threshold
desired_velocity = 10 * obj.max_velocity; % Reduziere die Geschwindigkeit in der Nähe von Kurven
end
acceleration = kp_lon * velocity_error + kd_lon * obj.states(4) + ki_lon * sum(obj.states(1:4));
% Begrenzen Sie die Beschleunigung
acceleration = max(-max_acceleration, min(max_acceleration, acceleration));
control_signal = [steering, acceleration];
obj.update_input(control_signal);
end

Risposte (2)

Abhinaya Kennedy
Abhinaya Kennedy il 25 Gen 2024
Hi Ivan,
It appears that you are encountering issues with your PID controller for a self-driving car in MATLAB. The car does not drive in the centreline as expected, and when changing the route, the error increases. I'll help you by providing a checklist to debug and improve the PID controller:
1. Retune PID Gains: Adjust “kp_lat”, “kd_lat”, “ki_lat”, “kp_lon”, “kd_lon”, “ki_lon” to improve response.
2. Check Integral Windup: Ensure anti-windup is effectively preventing integral term accumulation.
3. Verify Steering Limits: Confirm “steering_angle_limit” matches vehicle dynamics and path requirements.
4. Adjust Velocity for Curvature: Ensure reduced velocity during high curvature is appropriate.
5. Validate Trajectory: Make sure the trajectory is accurately interpolated and represents the desired path.
6. Examine State Update: Ensure the “update_state” method accurately reflects vehicle dynamics.
7. Control Input Smoothing: Confirm the low-pass filter factor is balanced for response and smoothness.
8. Error Calculation: Verify CTE calculation in “compute_error” is correct and represents lateral error accurately.
9. Simulation Parameters: Check time step (“ts”), number of steps (“N”), and initial conditions for realism.
10. Use Visualization: Plot trajectory, vehicle path, and control inputs to identify issues.
11. Search for Bugs: Review code for errors, especially in units and coordinate transformations.
12. Test Varied Conditions: Evaluate controller performance under different speeds, trajectories, and road conditions.
13. Consider External Factors: Account for road grade, friction, and environmental effects on vehicle control.
Hope this helps.
  1 Commento
Sam Chak
Sam Chak il 13 Giu 2024
Modificato: Sam Chak il 13 Giu 2024
Your checklist didn't check if 'dcte' is the time derivative of the error signal 'cte'.
Wouldn't it be far better to apply "formulas" for determining the PID gains to achieve specified performance requirements if the linear mathematical model is known in the simulation?
[Kp, Ki, Kd] = f(model, performance values).

Accedi per commentare.


labtst
labtst il 12 Giu 2024
thank your

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by