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

Allow a custom throttle in deep learning template #1115

Open
Ezward opened this issue Mar 23, 2023 · 2 comments
Open

Allow a custom throttle in deep learning template #1115

Ezward opened this issue Mar 23, 2023 · 2 comments
Assignees

Comments

@Ezward
Copy link
Contributor

Ezward commented Mar 23, 2023

Throttle can be difficult to learn from data unless there is a lot of data. This is because throttle is much harder to duplicate from run to run than steering for the human driver, so it is harder to learn from the resulting data. It would be useful to have an algorithmic approach to throttle that could be configured.

Both the path follow and the computer vision templates allow a algorithmic throttle control to be used when in autopilot mode, but they do it differently. The path follow template allows a constant throttle by setting USE_CONSTANT_THROTTLE = True and using PID_THROTTLE as the throttle value.

PID_THROTTLE = 0.50                 # constant throttle value during path following
USE_CONSTANT_THROTTLE = False       # whether or not to use the constant throttle or variable throttle captured during path recording

The computer vision template implements a more sophisticated approach that allows throttle to be varied between a minimum and maximum based on the steering value (slow down when turning; speed up when going straight). There are initial, minimum, and maximum values that can be specified; so this is a constant step controller, which is easy to tune. Also, by making min, max and initial the same and step = 0, it can create a constant throttle.

THROTTLE_MAX = 0.3    # maximum throttle value the controller will produce
THROTTLE_MIN = 0.15   # minimum throttle value the controller will produce
THROTTLE_INITIAL = THROTTLE_MIN  # initial throttle value
THROTTLE_STEP = 0.05  # how much to change throttle when on/off line (adding/subtracting respectively)

Perhaps the computer vision throttle control is a capability we should add to all templates. It is implemented using the pixel offset of the line, but we should change this to be based on the steering value and implement a standalone part to separate throttle control from steering control in the computer vision template, then use that same part in the other templates.

Or for the deep learning template we may want something even more sophisticated; use a lambda to convert the steering value to a throttle and allow the user to provide the implementation in the configuration. That would allow the user maximum flexibility over how the throttle value is calculated.

@Ezward Ezward self-assigned this Mar 23, 2023
@Ezward Ezward changed the title Allow a constant throttle in deep learning template Allow a custom throttle in deep learning template Oct 21, 2023
@Yann377
Copy link

Yann377 commented Oct 23, 2023

Hi, I'm an IT student, I'm going to work on it as part of my computer science studies :-)

@Ezward
Copy link
Contributor Author

Ezward commented Jan 13, 2024

@Yann377 Great, this is a good project. The documentation has a discussion of the donkeycar software architecture, that is a good place to start. The deep learning template is here https://github.com/autorope/donkeycar/blob/main/donkeycar/templates/complete.py.

This is the line where the deep learning model is added to the vehicle pipeline. So when running in autpilot mode, that is the first place that a throttle value will be created. So you want your part that creates its own throttle value to run after that. We have a couple of other parts in the vehicle pipeline that modify throttle; the Stop Sign Detector runs runs a separate model that detects a stop sign and sets the throttle to zero if it finds one. The AI Launcher sets a constant throttle for a short time the first time the car is put into auto-pilot mode, so it can 'launch' the car really fast down the first straight in a race. Notice that both of them run just after the deep learning model. I think you want your part to run before both of those, but after the deep learning model.

So your part will take as input the steering and throttle values that the deep learning model output. It will then apply some function to the steering value to calculate a new throttle value and output that, thus overwriting the value the model created, so your value gets used instead.

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

No branches or pull requests

2 participants