フィルターのクリア

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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by