Closed Frankybeen29 closed 7 months ago
The current acceleration is calculated in MyTurn.esdl as described above. We can access this in myDrive_4.bd to log the acceleration and later check if in the curves we adhere to the desired.
Also another car message is introduced for the acceleration in case of possible use in experiments:
Since a lot of new calculations need to be done in the Control.esdl, a lot of them are transferred into newly created specifications.
The CalcAngle specification calculates $\frac{\alpha}{2}$:
The CalcRadius specification calculates the radius of the circle:
The CheckCurve specification checks whether we are back on track after leaving the curve:
The NextFocuspoint specification handles not only when to approach the next focuspoint but also when to calculate the angle between the next two segments which is after leaving the current curve. It also makes sure that the old focuspoint is updated at the right moment so that the right angle is calculated.
The TargetVelo specification determines the target velocity for control that is determined by the current calculated radius with the exception of the last segment where we just drive with 60 kmph until we break and then come to a stop at the end.
The Main Specification still calculates the targeted steering angle, calls the above listed specifications and as a last step sends the acquired target velocity to the velocity controller to get the power and the break signals which are then send to the car.
When plotting the logged velocity, one can see that we break before the curves and also drive slowly through the curves.
When plotting the driven curve and the actual, we can see that we drive through the curves way smoother and we also don't exceed the maximum lateral acceleration. There are some points which violate the condition but all in all this algorithm does it's job very well.
When trying this algorithm on the Nurburg Ring, the mentioned limitations apply. The car breaks in the curves however also accelerates in certain intervals since multiple points make a curve.
One can also see the violations on the acceleration plot:
However improving that further would be a little too extensive for the project.
Done
Changes are in docs
Feasibility
We can calculate the lateral acceleration by given formula:
$a = \frac{v^2}{R}$
source: https://www.mrwaynesclass.com/circular/notes/corner/home.htm
We can get the current radius as in D3 from the steering angle and with the current velocity calculate the current acceleration. We get all these variables in the MyTurn.esdl, so we can just calculate the current acceleration here:
A typical car has a maximum acceleration of 0.6 to 0.9g, therefore we choose 0.8g (source: https://www.mrwaynesclass.com/circular/index08.html).
With the formula provided, we can then calculate the maximum velocity that can be driven when steering with a certain angle aka driving on a curve with a certain radius:
$v_{targeted} = \sqrt{R \cdot a}$
However, this is of no use for us. Since the car has a breaking distance, we cannot reach a targeted velocity in an instance, so we need to kind of predict what velocity we need when driving through the next curve. Then we can break in time to reach an appropriate velocity.
But how can we predict? An approximation method that we came up with is explained in the following:
We can calculate the radius of the circle that is defined by the current position of the car and the two line segments defined by the focuspoint that is currently approached the former focuspoint and the focuspoint to come:
$R = distance2focuspoint \cdot tan(\frac{\alpha}{2})$
We start calculating that radius after coming out of the last curve when we are pretty much on track again meaning the angle difference between bearing and vector to next focuspoint is smaller than 0.01 rad. Then after that during the approach and during the curve we constantly calculate the radius which gets smaller and smaller which causes the target velocity to also decrease and we should break on time and reach an appropriate speed when being in the curve.
Limitations
This approach may not work that good when the curves are defined by many focuspoints as we accelerate again after a certain error is undershot. We would then accelerate in a curve which is not desired. However for routes with small resolution meaning defined by few points in good distance to each other this should work very well.