![]() |
WPILib PIDController Question
Hi, our team has been having a lot of trouble using the PIDController class to move an arm on our robot based on an angle sensor. We're not really sure how to use the PIDController, for example, what methods are necessary to initialize the PIDController for it for set motor values correctly? We are using Java and the Command-based Architecture.
Here is what our code is doing (within a Subsystem class): Code:
public static Double setpoint;Has anyone else had success with the PIDController? |
Re: WPILib PIDController Question
It's a bit difficult to tell what issues you are having without seeing all of the code (in particular I could not tell how you were reading the sensor and determining the current angle), but here are some suggestions/comments.
If you haven't taken a look at the WPIlib docs on PIDController yet, check out: http://wpilib.screenstepslive.com/s/...rs-pid-control If your class extends PIDSubsystem instead of Subsystem, then you should probably remove your current PIDController object and refer to the WPIlib docs mentioned above. If your class extends Subsystem, then having your own PIDController object (controller) makes sense. Your P value of 10 looks way big for an initial starting point. The P value is multiplied by the error to come up with a motor power value in your PID. Hence a 3 degree error would result in a motor power of 30.0 given your 10.0 P multiplier. I would suggest you start with a much smaller value (like 0.01) and work your way up. Using the SmartDashboard PID control can be very useful for this (enabling this is described later). Once you get close on your P value, try adding some D to reduce oscillation. Make sure you look for inversion of source or power (if your shooter heads in the wrong direction, it typically means that the motor power or sensor reading needs to be inverted). Your pidGet() method looks something like the following: Code:
@OverrideCode:
@OverrideCode:
// Temporarily add widget to dashboard to play with PID settingsCode:
void updateDashboard() {
|
| All times are GMT -5. The time now is 07:55 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi