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

Made convenience functions for tuning a CustomPIDController on SmartDashboard #197

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

c0d3rman
Copy link
Member

@c0d3rman c0d3rman commented Mar 19, 2017

Include our PID tuning code as an optional module in CustomPIDController.

SmartDashboard.putNumber(prefix + "_F", getD());
return;
}
setPIDF(SmartDashboard.getNumber(prefix + "_P", getP()),
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to use the two-argument version with a default value? We've done this in the past while testing (with default 0).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a good way of doing it, it will default to the previous P/I/D/F value.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is what I'm doing...?

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes -- I have... room to improve.

* @param prefix
* The prefix to use when putting things on SmartDashboard.
*/
public void putToSmartDashboard(String prefix) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be added as an abstract function to MotionController (same for the other functions).

Copy link
Contributor

@carturn carturn left a comment

Choose a reason for hiding this comment

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

I agree with the general changes, but they should be abstracted to MotionController.

@ajnadel
Copy link
Member

ajnadel commented Mar 19, 2017

@carterturn Yes, perhaps, except that the values themselves are implementation-specific.

@carturn
Copy link
Contributor

carturn commented Mar 19, 2017

@ajnadel Yes. I think we should only add abstract functions to MotionController. Otherwise we will have to declare all MotionControllers to actually be a certain non-abstract type.

SmartDashboard.putNumber(prefix + "_Error", getError() + noise);
SmartDashboard.putNumber(prefix + "_Setpoint", getSetpoint() + noise);
SmartDashboard.putNumber(prefix + "_Sensor", getSensorValue() + noise);
SmartDashboard.putNumber(prefix + "_Output", get() + noise);
Copy link
Member

Choose a reason for hiding this comment

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

Also, did we decide that the mutating effects of calling get() (of the I and D) calculations are not big enough to matter?

Copy link
Contributor

@carturn carturn Mar 19, 2017

Choose a reason for hiding this comment

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

I think we have decided to fix that in the future. It should not make too much of a difference, as it does calculate time deltas every time.

Copy link
Member

Choose a reason for hiding this comment

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

Cool -- and the sensor updates fast enough that each few ticks will probably have a different value.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is on the list to be fixed. (In fact I have a list of PID changes we need to make that various programmers will be doing before SVR)

SmartDashboard.putNumber(prefix + "_P", getP());
SmartDashboard.putNumber(prefix + "_I", getI());
SmartDashboard.putNumber(prefix + "_D", getD());
SmartDashboard.putNumber(prefix + "_F", getD());
Copy link
Member

Choose a reason for hiding this comment

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

D != F

@ajnadel
Copy link
Member

ajnadel commented Mar 19, 2017

@carterturn better?

@@ -18,6 +19,7 @@
protected double A;
protected double F;
protected double threshold;
protected static final String DEFAULT_SMARTDASHBOARD_PREFIX = "!!";
Copy link
Contributor

Choose a reason for hiding this comment

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

If this actually works, I think it is great. I would watch out for improper nonalphanumeric character parsing in NetworkTables though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why did we change it to this? It's pretty jenk

Copy link
Contributor

Choose a reason for hiding this comment

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

This did not exist before. It is for the bang (!) bang (!) controller. We should make a shebang controller at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

As funny as that is it should probably be BangBang or BANGBANG

Copy link
Contributor

@carturn carturn left a comment

Choose a reason for hiding this comment

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

I now approve this.

@c0d3rman
Copy link
Member Author

I'm still not convinced we want to REQUIRE every controller to implement this. I think we should either have a default implementation or make this an interface.

@carturn
Copy link
Contributor

carturn commented Mar 21, 2017

I think it is trivial enough to implement in most cases that a default implementation is not really going to make much of a difference. This is a convenient interface for tuning that should probably be preferred over the reupload with new constants method.

Copy link
Contributor

@oshlern oshlern left a comment

Choose a reason for hiding this comment

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

I wish we had merged this years ago, because we've been doing this manually a lot. Awesome quality of life changes that will make PID tuning easier and faster. Can also be used by Shuffleboard if its widgets use the SmartDashboard network table.

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

Successfully merging this pull request may close these issues.

5 participants