|
LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
|
#include <iterativeVelPidController.hpp>
Classes | |
| struct | Gains |
Public Member Functions | |
| IterativeVelPIDController (double ikP, double ikD, double ikF, double ikSF, std::unique_ptr< VelMath > ivelMath, const TimeUtil &itimeUtil, std::unique_ptr< Filter > iderivativeFilter=std::make_unique< PassthroughFilter >(), std::shared_ptr< Logger > ilogger=Logger::getDefaultLogger()) | |
| Velocity PD controller. | |
| IterativeVelPIDController (const Gains &igains, std::unique_ptr< VelMath > ivelMath, const TimeUtil &itimeUtil, std::unique_ptr< Filter > iderivativeFilter=std::make_unique< PassthroughFilter >(), std::shared_ptr< Logger > ilogger=Logger::getDefaultLogger()) | |
| Velocity PD controller. | |
| double | step (double inewReading) override |
| Do one iteration of the controller. | |
| void | setTarget (double itarget) override |
| Sets the target for the controller. | |
| void | controllerSet (double ivalue) override |
| Writes the value of the controller output. | |
| double | getTarget () override |
| Gets the last set target, or the default target if none was set. | |
| double | getTarget () const |
| Gets the last set target, or the default target if none was set. | |
| double | getProcessValue () const override |
| double | getOutput () const override |
| Returns the last calculated output of the controller. | |
| double | getMaxOutput () override |
| Get the upper output bound. | |
| double | getMinOutput () override |
| Get the lower output bound. | |
| double | getError () const override |
| Returns the last error of the controller. | |
| bool | isSettled () override |
| Returns whether the controller has settled at the target. | |
| void | setSampleTime (QTime isampleTime) override |
| Set time between loops in ms. | |
| void | setOutputLimits (double imax, double imin) override |
| Set controller output bounds. | |
| void | setControllerSetTargetLimits (double itargetMax, double itargetMin) override |
| Sets the (soft) limits for the target range that controllerSet() scales into. | |
| void | reset () override |
| Resets the controller's internal state so it is similar to when it was first initialized, while keeping any user-configured information. | |
| void | flipDisable () override |
| Changes whether the controller is off or on. | |
| void | flipDisable (bool iisDisabled) override |
| Sets whether the controller is off or on. | |
| bool | isDisabled () const override |
| Returns whether the controller is currently disabled. | |
| QTime | getSampleTime () const override |
| Get the last set sample time. | |
| virtual QAngularSpeed | stepVel (double inewReading) |
| Do one iteration of velocity calculation. | |
| virtual void | setGains (const Gains &igains) |
| Set controller gains. | |
| Gains | getGains () const |
| Gets the current gains. | |
| virtual void | setTicksPerRev (double tpr) |
| Sets the number of encoder ticks per revolution. | |
| virtual QAngularSpeed | getVel () const |
| Returns the current velocity. | |
Public Member Functions inherited from okapi::IterativeController< Input, Output > | |
| virtual Output | step (Input ireading)=0 |
| Do one iteration of the controller. | |
| virtual void | setOutputLimits (Output imax, Output imin)=0 |
| Set controller output bounds. | |
| virtual void | setControllerSetTargetLimits (Output itargetMax, Output itargetMin)=0 |
| Sets the (soft) limits for the target range that controllerSet() scales into. | |
Public Member Functions inherited from okapi::ClosedLoopController< Input, Output > | |
| virtual | ~ClosedLoopController ()=default |
| virtual void | setTarget (Input itarget)=0 |
| Sets the target for the controller. | |
Public Member Functions inherited from okapi::ControllerOutput< Input > | |
| virtual void | controllerSet (Input ivalue)=0 |
| Writes the value of the controller output. | |
Protected Attributes | |
| std::shared_ptr< Logger > | logger |
| double | kP |
| double | kD |
| double | kF |
| double | kSF |
| QTime | sampleTime {10_ms} |
| double | error {0} |
| double | derivative {0} |
| double | target {0} |
| double | outputSum {0} |
| double | output {0} |
| double | outputMax {1} |
| double | outputMin {-1} |
| double | controllerSetTargetMax {1} |
| double | controllerSetTargetMin {-1} |
| bool | controllerIsDisabled {false} |
| std::unique_ptr< VelMath > | velMath |
| std::unique_ptr< Filter > | derivativeFilter |
| std::unique_ptr< AbstractTimer > | loopDtTimer |
| std::unique_ptr< SettledUtil > | settledUtil |
Definition at line 16 of file iterativeVelPidController.hpp.
| okapi::IterativeVelPIDController::IterativeVelPIDController | ( | double | ikP, |
| double | ikD, | ||
| double | ikF, | ||
| double | ikSF, | ||
| std::unique_ptr< VelMath > | ivelMath, | ||
| const TimeUtil & | itimeUtil, | ||
| std::unique_ptr< Filter > | iderivativeFilter = std::make_unique< PassthroughFilter >(), |
||
| std::shared_ptr< Logger > | ilogger = Logger::getDefaultLogger() |
||
| ) |
Velocity PD controller.
| ikP | the proportional gain |
| ikD | the derivative gain |
| ikF | the feed-forward gain |
| ikSF | a feed-forward gain to counteract static friction |
| ivelMath | The VelMath used for calculating velocity. |
| itimeUtil | see TimeUtil docs |
| iderivativeFilter | a filter for filtering the derivative term |
| ilogger | The logger this instance will log to. |
| okapi::IterativeVelPIDController::IterativeVelPIDController | ( | const Gains & | igains, |
| std::unique_ptr< VelMath > | ivelMath, | ||
| const TimeUtil & | itimeUtil, | ||
| std::unique_ptr< Filter > | iderivativeFilter = std::make_unique< PassthroughFilter >(), |
||
| std::shared_ptr< Logger > | ilogger = Logger::getDefaultLogger() |
||
| ) |
|
override |
Writes the value of the controller output.
This method might be automatically called in another thread by the controller. The range of input values is expected to be [-1, 1].
| ivalue | the controller's output in the range [-1, 1] |
|
overridevirtual |
Changes whether the controller is off or on.
Turning the controller on after it was off will cause the controller to move to its last set target, unless it was reset in that time.
Implements okapi::ClosedLoopController< Input, Output >.
|
overridevirtual |
Sets whether the controller is off or on.
Turning the controller on after it was off will cause the controller to move to its last set target, unless it was reset in that time.
| iisDisabled | whether the controller is disabled |
Implements okapi::ClosedLoopController< Input, Output >.
|
overridevirtual |
Returns the last error of the controller.
Does not update when disabled.
Implements okapi::ClosedLoopController< Input, Output >.
| Gains okapi::IterativeVelPIDController::getGains | ( | ) | const |
Gets the current gains.
|
overridevirtual |
Get the upper output bound.
Implements okapi::IterativeController< Input, Output >.
|
overridevirtual |
Get the lower output bound.
Implements okapi::IterativeController< Input, Output >.
|
overridevirtual |
Returns the last calculated output of the controller.
Implements okapi::IterativeController< Input, Output >.
|
overridevirtual |
Implements okapi::ClosedLoopController< Input, Output >.
|
overridevirtual |
Get the last set sample time.
Implements okapi::IterativeController< Input, Output >.
| double okapi::IterativeVelPIDController::getTarget | ( | ) | const |
Gets the last set target, or the default target if none was set.
|
overridevirtual |
Gets the last set target, or the default target if none was set.
Implements okapi::ClosedLoopController< Input, Output >.
|
virtual |
Returns the current velocity.
|
overridevirtual |
Returns whether the controller is currently disabled.
Implements okapi::ClosedLoopController< Input, Output >.
|
overridevirtual |
Returns whether the controller has settled at the target.
Determining what settling means is implementation-dependent.
If the controller is disabled, this method must return true.
Implements okapi::ClosedLoopController< Input, Output >.
|
overridevirtual |
Resets the controller's internal state so it is similar to when it was first initialized, while keeping any user-configured information.
Implements okapi::ClosedLoopController< Input, Output >.
|
override |
Sets the (soft) limits for the target range that controllerSet() scales into.
The target computed by controllerSet() is scaled into the range [-itargetMin, itargetMax].
| itargetMax | The new max target for controllerSet(). |
| itargetMin | The new min target for controllerSet(). |
|
virtual |
Set controller gains.
| igains | The new gains. |
|
override |
Set controller output bounds.
Default bounds are [-1, 1].
| imax | max output |
| imin | min output |
|
overridevirtual |
Set time between loops in ms.
| isampleTime | time between loops |
Implements okapi::IterativeController< Input, Output >.
|
override |
Sets the target for the controller.
| itarget | new target velocity |
|
virtual |
Sets the number of encoder ticks per revolution.
Default is 1800.
| tpr | number of measured units per revolution |
|
override |
Do one iteration of the controller.
Returns the reading in the range [-1, 1] unless the bounds have been changed with setOutputLimits().
| inewReading | new measurement |
|
virtual |
Do one iteration of velocity calculation.
| inewReading | new measurement |
|
protected |
Definition at line 248 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 246 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 247 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 240 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 251 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 239 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 237 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 237 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 237 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 237 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 236 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 252 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 243 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 244 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 245 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 242 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 238 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 253 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 241 of file iterativeVelPidController.hpp.
|
protected |
Definition at line 250 of file iterativeVelPidController.hpp.