class
IterativeVelTBHController
Constructors, destructors, conversion operators
- IterativeVelTBHController(double iGain, std::unique_ptr<VelMath> iVelMath, const TimeUtil& iTimeUtil, std::shared_ptr<Logger> iLogger = Logger::getDefaultLogger())
Public functions
- auto step(double iNewReading) -> double 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.
- auto getTarget() -> double override
- Gets the last set target, or the default target if none was set.
- auto getTarget() const -> double
- Gets the last set target, or the default target if none was set.
- auto getProcessValue() const -> double override
- auto getOutput() const -> double override
- Returns the last calculated output of the controller.
- auto getMaxOutput() -> double override
- Get the upper output bound.
- auto getMinOutput() -> double override
- Get the lower output bound.
- auto getError() const -> double override
- Returns the last error of the controller.
- auto isSettled() -> bool 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.
- auto isDisabled() const -> bool override
- Returns whether the controller is currently disabled.
- auto getSampleTime() const -> QTime override
- Get the last set sample time.
- auto stepVel(double iNewReading) -> QAngularSpeed virtual
- Do one iteration of velocity calculation.
- void setGains(const double iGain) virtual
- Set controller gain.
- auto getGains() const -> double
- Gets the current gain.
- void setTicksPerRev(double iTPR) virtual
- Sets the number of encoder ticks per revolution.
- auto getVel() const -> QAngularSpeed virtual
- Returns the current velocity.
Protected variables
- double gain
- QTime sampleTime
- double target
- double error
- double prevError
- double tbh
- double output
- double outputMax
- double outputMin
- double controllerSetTargetMax
- double controllerSetTargetMin
- bool controllerIsDisabled
- std::shared_ptr<Logger> logger
- std::unique_ptr<VelMath> velMath
- std::unique_ptr<AbstractTimer> loopDtTimer
- std::unique_ptr<SettledUtil> settledUtil
Function documentation
double rz:: IterativeVelTBHController:: step(double iNewReading) override
Do one iteration of the controller.
Parameters | |
---|---|
iNewReading | new measurement |
Returns | controller output |
Returns the reading in the range [-1, 1] unless the bounds have been changed with setOutputLimits().
void rz:: IterativeVelTBHController:: setTarget(double iTarget) override
Sets the target for the controller.
Parameters | |
---|---|
iTarget | new target velocity |
void rz:: IterativeVelTBHController:: controllerSet(double iValue) override
Writes the value of the controller output.
Parameters | |
---|---|
iValue | the controller's output in the range [-1, 1] |
This method might be automatically called in another thread by the controller. The range of input values is expected to be [-1, 1].
double rz:: IterativeVelTBHController:: getTarget() override
Gets the last set target, or the default target if none was set.
Returns | the last target |
---|
double rz:: IterativeVelTBHController:: getTarget() const
Gets the last set target, or the default target if none was set.
Returns | the last target |
---|
double rz:: IterativeVelTBHController:: getProcessValue() const override
Returns | The most recent value of the process variable. |
---|
double rz:: IterativeVelTBHController:: getMaxOutput() override
Get the upper output bound.
Returns | the upper output bound |
---|
double rz:: IterativeVelTBHController:: getMinOutput() override
Get the lower output bound.
Returns | the lower output bound |
---|
double rz:: IterativeVelTBHController:: getError() const override
Returns the last error of the controller.
Does not update when disabled.
bool rz:: IterativeVelTBHController:: isSettled() override
Returns whether the controller has settled at the target.
Returns | whether the controller is settled |
---|
Determining what settling means is implementation-dependent.
If the controller is disabled, this method must return true.
void rz:: IterativeVelTBHController:: setSampleTime(QTime iSampleTime) override
Set time between loops in ms.
Parameters | |
---|---|
iSampleTime | time between loops |
void rz:: IterativeVelTBHController:: setOutputLimits(double iMax,
double iMin) override
Set controller output bounds.
Parameters | |
---|---|
iMax | max output |
iMin | min output |
Default bounds are [-1, 1].
void rz:: IterativeVelTBHController:: setControllerSetTargetLimits(double iTargetMax,
double iTargetMin) override
Sets the (soft) limits for the target range that controllerSet() scales into.
Parameters | |
---|---|
iTargetMax | The new max target for controllerSet(). |
iTargetMin | The new min target for controllerSet(). |
The target computed by controllerSet() is scaled into the range [-itargetMin, itargetMax].
void rz:: IterativeVelTBHController:: flipDisable() override
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.
void rz:: IterativeVelTBHController:: flipDisable(bool iIsDisabled) override
Sets whether the controller is off or on.
Parameters | |
---|---|
iIsDisabled | whether the controller is disabled |
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.
bool rz:: IterativeVelTBHController:: isDisabled() const override
Returns whether the controller is currently disabled.
Returns | whether the controller is currently disabled |
---|
QTime rz:: IterativeVelTBHController:: getSampleTime() const override
Get the last set sample time.
Returns | sample time |
---|
QAngularSpeed rz:: IterativeVelTBHController:: stepVel(double iNewReading) virtual
Do one iteration of velocity calculation.
Parameters | |
---|---|
iNewReading | new measurement |
Returns | filtered velocity |
void rz:: IterativeVelTBHController:: setGains(const double iGain) virtual
Set controller gain.
Parameters | |
---|---|
iGain | The new gain. |
double rz:: IterativeVelTBHController:: getGains() const
Gets the current gain.
Returns | The current gain. |
---|
void rz:: IterativeVelTBHController:: setTicksPerRev(double iTPR) virtual
Sets the number of encoder ticks per revolution.
Parameters | |
---|---|
iTPR | number of measured units per revolution |
Default is 1800.