-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
Conversation
SmartDashboard.putNumber(prefix + "_F", getD()); | ||
return; | ||
} | ||
setPIDF(SmartDashboard.getNumber(prefix + "_P", getP()), |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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).
There was a problem hiding this 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.
@carterturn Yes, perhaps, except that the values themselves are implementation-specific. |
@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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D != F
@carterturn better? |
@@ -18,6 +19,7 @@ | |||
protected double A; | |||
protected double F; | |||
protected double threshold; | |||
protected static final String DEFAULT_SMARTDASHBOARD_PREFIX = "!!"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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.
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. |
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. |
There was a problem hiding this 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.
Include our PID tuning code as an optional module in
CustomPIDController
.