# PID for fixed distance

조회 수: 7(최근 30일)
Andrea Tonelli 2022년 11월 8일
댓글: Andrea Tonelli 2022년 11월 9일
Hello everyone, I attach here my model of a car moving towards that must maintain a fixed distance of 100m from the car in front of it. I have drawn all the schemes which seem to be correct. I have a signal reference that must be followed with a constant error, but I'm not able to understand why I have divergence between the reference signal and the actual position of my vehicle, whichever value of the gains I use, from the smallest to the largest.
I really hope someone could help me. Thank you very much!

댓글을 달려면 로그인하십시오.

### 답변(1개)

Sam Chak 2022년 11월 9일
I think your control design part is okay. But the divergence issue is probably related to the way you setup the simulation (Error – 100). Thus, I have made a super simple model (ignoring the aerodynamics and frictions) in this example.
The Auto-Cruise Control Car should follow the Reference, which is the trajectory of the "Car-in-front – 100".
% Super Simple Car motion model
J = 1000;
s = tf('s');
Gp = minreal(1/(J*s^2))
Gp = 0.001 ----- s^2 Continuous-time transfer function.
% Super Simple PID Controller
Gc = pid(0, 0, 500, 0.5)
Gc = s Kp + Kd * -------- Tf*s+1 with Kp = 0, Kd = 500, Tf = 0.5 Continuous-time PDF controller in parallel form.
Gcl = minreal(feedback(Gc*Gp, 1))
Gcl = 1 ------------- s^2 + 2 s + 1 Continuous-time transfer function.
Amp = 50;
Tp = 300; % 1 cycle period
Tf = 300; % final time simulation (5 minutes)
Ts = 0.1; % sampling time interval
[u, t] = gensig('sine', Tp, Tf, Ts); % standard sine wave generation
Car = Amp*u + 150; % Car in front of your vehicle
Ref = Car - 100; % Reference for Auto-Cruise Control Car
y = lsim(Gcl, Ref, t);
plot(t, Car, t, y, 'linewidth', 1.5), grid on, xlabel('t'), ylabel('Position of Vehicles')
legend('Car-in-front', 'Auto-Cruiser', 'location', 'best', 'FontSize', 14)
error = Car - y; % relative distance of Car-in-front ahead of your vehicle
plot(t, error, 'linewidth', 1.5), grid on, xlabel('t, sec'), ylabel('Relative Distance, m')
title('ACC Car attempts to maintain a relative distance of 100 m')
By the way, in your 1st question, have you identified the cause of the problem (fuzzy controller) based on the given advice?
You can update the progress, or close it if your problem solved. Thanks.
##### 댓글 수: 3표시숨기기 이전 댓글 수: 2
Andrea Tonelli 2022년 11월 9일
Still nothing changes. I will try to work on the gains.

댓글을 달려면 로그인하십시오.

### 범주

Find more on PID Controller Tuning in Help Center and File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by