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

modified clip_actions() to consider update frequency when dealing with acceleration #548

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhum86
Copy link

@zhum86 zhum86 commented Dec 29, 2023

I assume the expected behavior of clip_actions() would be modifying the action whenever the current action would make the next vehicle state (e.g., self.speed += action["acceleration"]*dt) outside its operation limit (e.g., max/min speed). The modified action should bring the vehicle state (e.g., speed) to its corresponding limit (e.g., max/min speed) in this step. The current implementation does not consider the dt (update frequency).

For example:

# Given
# self.MIN_SPEED = 0.0
# dt = 0.5 # s
# self.action["acceleration"] = -5.0
# self.speed = 0.5

def step(self, dt):
  self.clip_actions() # self.action["acceleration"] = -0.5 (current) vs -1.0 (new)
  ...
  self.speed += self.action["acceleration"] * dt # self.speed = 0.25 (current) vs 0.0 (new)

@zhum86
Copy link
Author

zhum86 commented Jan 31, 2024

@eleurent Hi, would you please review this PR?

@eleurent
Copy link
Collaborator

Hi, sorry for the late reply.

TLDR: this is intended behaviour to prevent abrupt deccelerations

I understand what you mean: this change makes sense if the goal is to ensure that the vehicle speed statisfies the hard constraints v_min <= v <= v_max by applying a correction in a single timestep dt.
However, the problem is that this can lead to very large accelerations (dv/dt) if dt is small.

The controller that is currently implemented instead follows a smoother trajectory, where any overflow from the maximum speed is corrected with a 1st-order controller with a response time of 1.0s, i.e it takes roughly 2 seconds to correct it.
I think this is slightly more physical, e.g. if a vehicle is initialised with a speed > v_max, it will slow down more gracefully that doing an instantaneous stop.

The drawback of that approach is that the constraint are not hard, since the correction is only applied after the speed is out of bounds, but I think that is fine as long as the overshoot stays small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants