Program to control acceleration of a car

조회 수: 6 (최근 30일)
Ryan
Ryan 2014년 10월 22일
댓글: Jon Boerner 2014년 10월 23일
Hello, I am trying to create a program to control the acceleration of a car. The car has accelerate up to the speed limit or the car in front of it, which ever is slower and decelerate to avoid a collision if necessary. There are comfortable limits for deceleration and acceleration.
The first test case is the simplest and involves accelerating up to meet a car and then following it. I can get up behind it, but my acceleration and deceleration oscillate extremely. The graph of acceleration bounces back forth between the max and min acceleration..
How can I fix this?
if true
% code
% D(n) is the distance to the car in front at time n
% VL is the velocity of the lead car
% V(n) is the velocity of the car at time n
if D(n)>(8*V(n)) % accel comfortably until within 8sec of car in front
a=AccelLimit;
elseif(VL-V(n))<0
a= min((100/((D(n))))*((VL-V(n))/dt),AccelLimit);% if the car in front is going slower, we want our deceleration to be proportional to diff in VL-V(n) and inverse to D(n)
elseif D(n)<1
a=DecelLimit;
else
a=min((0.01*(D(n))*((VL-V(n))/dt)),DecelLimit); % if the car in front is going faser, we want our acceleration to be proportional to D(n) and VL-V(n)
end
end
Thanks!
  댓글 수: 1
Jon Boerner
Jon Boerner 2014년 10월 23일
Hi Ryan,
Could you post enough code so we can see the behavior you are talking about? For example, I would imagine you have a loop and some variable definitions. It would be a lot easier to take a look if you did that.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by