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

Mod tuning #31

Merged
merged 9 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions TUNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,46 @@ To use this mod you need to do 2 things:

You will need to specify which variables you want the Tuning mod to manage by adding them to that file. See the file called **selfdrive/ui/params.example.txt** for an example.

2. Modify OpenPilot code that uses the variable so that it is read from this file instead of hard coded. This is left for the user to figure out and implement.
2. Modify OpenPilot code that uses the variable so that it is read from this file instead of hard coded. This is left for the user to figure out and implement. To help you get started with this step you can use the following python code to read in the variables stored by this mod:

```
import imp
f = open("/sdcard/tuning/params.txt")
tuning = imp.load_source('tuning', '', f)
f.close()
````

This will read all of the parameters that you've defined in your **params.txt** file and store them into a python variable called `tuning`. Then you need to assign the real variables that openpilot uses with the corresponding parameter value. For example, if openpilot has a hard coded value for `ret.steerKp=[0.2]` Assuming your **params.txt** file contains this parameter:

`
MySteerKp=[0.25]
`

You would then replace that line in the openpilot python file with `ret.steerKp=tuning.MySteerKp`.

This mod can manage up to 10 different variables with each variable having a maximum of 3 element values in it.

For questions or info about this mod, visit the comma slack channel #mod-tuning

To change the "scale" of the steps tap the "Steps" box. It will cycle through different scales. The step scales are: \[0.001, 0.01, 0.1, 1, 5\]
To change the "scale" of the steps tap the "Steps" box. It will cycle through different scales. The step scales are: \[0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 5\]

![screenshot](https://i.imgur.com/G7j2vQY.jpg)

CHANGE LOG:

v0.0.1 - Initial version
v0.0.3
========================
* Increase precision to 6 decimal places

v0.0.2
========================
* Added 'press and hold' on the +/- buttons
* Swapped positions of +/- buttons

v0.0.1
========================
* Initial version

To Do:
- [ ] Ability to handle hex values
- [ ] Suppress baseui from toggling zoom view when tapping
2 changes: 1 addition & 1 deletion selfdrive/ui/tuning.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ char properties[50][MAX_NUM_PARAMS]; // List of property names
int current_property = -1; // Which property value to adjust when clicking the increase/decrease buttons
ui_element *property_buttons[MAX_NUM_PARAMS]; // Store the buttons that can be selected
double step = 0.000001; // Steps to adjust on each click
float delta_step = 0.001; // Change step by this amount
float delta_step = 0.000001; // Change step by this amount
int step_toggle = 0; // Change to preset toggle step

int param_index = 0; // Index to track which param label we're working with
Expand Down