Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

490 remodel acc concept #516

Merged
merged 13 commits into from
Dec 5, 2024
Binary file added doc/assets/research_assets/ACC_FLC_Example_1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions doc/research/paf24/planning/ACC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# ACC

This file gives a general overview on possible ACC implementations and reflects the current state of the ACC.

## General

The main goal of an ACC (Adaptive Cruise Control) is to follow a car driving in front while keeping a safe distance to it. This can be achieved by adjusting the speed to the speed of the car in front.
In general, classic ACC systems are designed for higher velocity (e.g. > 40 km/h). Apart from that, there are Stop & Go systems that support lower velocites (e.g. < 40 km/h). In our case, both systems might be needed and it might be reasonable to develop two different systems for ACC and Stop & Go.
Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
There are basically three different techniques that can be used to implement an ACC: PID Control, Model Predictive Control and Fuzzy Logic Control. Another option is CACC (Cooperative Adaptive Cruise Control) but this is not relevant for our project since it requires communication between the vehicles.

### PID Control

The PID Controller consists of three terms: the proportional term, the integral term and the derivative term. One possible simple controller model looks as follows:

$$ v_f(t) = v_f(t - t_s) + k_p e (t-t_s) + k_d \dot{e}(t - t_s) $$
$$ e(t-t_s) = \Delta x(t - t_s) - t_{hw,d} v_f (t - t_s) $$

- $t_s$: sampling time
- $k_p$ and $k_d$: coefficients for proportional and derivative terms
- $e$: distance error (difference between actual distance $\Delta x$ and desired distance $\Delta x_d$)

Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
### Model Predictive Control (MPC)

It calculates the current control action by solving an online, iterative and finite-horizon optimization of the model.
Procedure:

1. Prediction of future system states based on current states
2. Computation of the cost function for a finite time horizon in the future
3. Implementation of the first step of the solved control sequence
4. Application of the feedback control loop to compensate for the predictive error and model inaccuracy
5. Sampling of new current states and repitition of the process

Comment on lines +27 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance MPC section with implementation specifics

The MPC section needs more detailed information to be implementable:

  1. Define the prediction model
  2. Specify the cost function components
  3. Document the optimization constraints
  4. Provide the control horizon parameters

Would you like me to help draft the detailed MPC implementation specifications?

### Fuzzy Logic Control (FLC)

Provides a unified control framework to offer both functions: ACC and Stop & Go.

![Example of a FLC control algorithm](../../../assets/research_assets/ACC_FLC_Example_1.png)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me this link does not work. This might be the github preview however.
Maybe this image should also be directly included.
Especially because here some formula symbols are explained.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I embed an image directly?

Vroni27 marked this conversation as resolved.
Show resolved Hide resolved

## Discussion

- When should the ACC be used? Only when driving straight forward?
- How to test adaptations of the ACC? Create test scenarios?
- Which output should be transfered to the Acting component? Only the desired speed?
- Which input do we get from the Perception component? The distance and velocity of the car in front?

Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
## ACC in our project

### Current implementation

- General behaviour:
checks for obstacle distance < safety distance

calculates new speed based on obstacle distance

else keep current speed

- publishes speed to acc_velocity
- safe distance calculation is currently not correct, uses speed + (speed * 0.36)² which results in wrong distances
- if car in front of us ignores speed limits we ignore them as well
Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
- some parts of unstuck routine are in ACC and need to be refactored
- same goes for publishing of current waypoint, this should not be in ACC

Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +54 to +58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Address safety distance calculation and architectural issues

Several critical issues require immediate attention:

  1. Safety distance calculation is incorrect and unsafe
  2. Component responsibilities are mixed:
    • Unstuck routine in ACC
    • Waypoint publishing in ACC

Proposed actions:

  1. Create a dedicated SafetyDistance class with physics-based calculations
  2. Move unstuck routine to a behavior module
  3. Implement waypoint management in planning component
  4. Add comprehensive unit tests

Would you like me to help draft the SafetyDistance class implementation?

In summary, the current implementation is not sufficient and needs major refactoring.

### Concept for new implementation

The new concept for the ACC is to take the trajectory, look at all or a limited subset of the next points and add a target velocity and the current behaviour to each point.
This way the Acting has more knowledge about what the car is doing and can adjust accordingly in a local manner.
For this a new trajectory message type was implemented in #511.

![trajectoryMsg](https://github.com/user-attachments/assets/0b452f1a-4c60-45b2-882f-3a50118c9cb9)
Vroni27 marked this conversation as resolved.
Show resolved Hide resolved

Since behaviour is passed as an ID a new enum for behaviours was implemented in utils.py as well.
Vroni27 marked this conversation as resolved.
Show resolved Hide resolved

The general idea for speeds above the 40 km/h mark is to calculate a proper safety distance, a general target velocity and velocity targets based on PID. For speeds lower than that a stop and go system can be discussed if it is really needed.

For safety distance we will use the concept from the FLC graphic.

For a general speed target we either take the speed of the car in front or the speed limit, whichever is lower. In cases where the car in front is substantially slower than the speed limit ACC could inititate overtaking.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Document safety distance calculation details

The reference to "the concept from the FLC graphic" needs explicit documentation:

  1. Provide the actual formula to be used
  2. Define all variables and their units
  3. Include validation criteria for the safety distance calculation

This is critical for safety and should be thoroughly documented before implementation.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~77-~77: Possible missing comma found.
Context: ...sed if it is really needed. For safety distance we will use the concept from the FLC gr...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~78-~78: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... use the concept from the FLC graphic. For a general speed target we either take t...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[uncategorized] ~79-~79: Possible missing comma found.
Context: ...m the FLC graphic. For a general speed target we either take the speed of the car in ...

(AI_HYDRA_LEO_MISSING_COMMA)


Since we want to calculate the desired speed at each point of the trajectory, the way PID calculates velocity seems reasonable since we can treat the trajectory points as different points in time for the sampling time.
For example let's say we sample every fifth point and calculate the velocity for that, then we can just interpolate every other point inbetween.

$v_f(t - t_s)$ would then simply be the velocity of the fifth point before the current one. Theoretically this allows us to dynamically adjust the sampling time as well if needed.

Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
For the distance error we can use the safety distance as the desired distance. The distance at time t needs to be predicted based on the (predicted) distance at the prior sample point and the calculated speed at the prior sample point.

We calculate velocities like that up to the point where the velocity reaches the desired general speed target. For points further than that we simply use the desired general speed.

Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
### Possible next steps

A seperate file for the new ACC should be created to not disturb the system.

The parts that might get cut from ACC like current waypoint and unstuck routine need to be evaluated for necessity and if need be moved to somewhere more fitting.

Implement publisher for new message type.

Start implementing safety distance and general target speed logic. Subscriber logic could be taken from old implementation.

Implement PID logic

Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
### Requirements

- obstacle speed
- obstacle distance
Comment on lines +103 to +104
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Expand system requirements with specific metrics

The requirements section needs quantitative metrics:

  1. Obstacle Detection:
    • Detection range
    • Speed measurement accuracy
    • Position accuracy
    • Update rate
  2. System Performance:
    • Control loop frequency
    • Response time
    • Speed control accuracy
  3. Safety Requirements:
    • Minimum time gap
    • Maximum deceleration
    • Fail-safe behavior

Would you like me to help draft detailed requirements specifications?


Vroni27 marked this conversation as resolved.
Show resolved Hide resolved
## Sources

He, Yinglong et al. (2019). Adaptive Cruise Control Strategies Implemented on Experimental Vehicles: A Review. IFAC-PapersOnLine. 52. 21-27. 10.1016/j.ifacol.2019.09.004.
[Link](https://www.researchgate.net/publication/335934496_Adaptive_Cruise_Control_Strategies_Implemented_on_Experimental_Vehicles_A_Review)
Loading