class
IterativeMotorVelocityController
Contents
Base classes
-
template<typename Input, typename Output>class IterativeVelocityController
Constructors, destructors, conversion operators
- IterativeMotorVelocityController(const std::shared_ptr<AbstractMotor>& imotor, const std::shared_ptr<IterativeVelocityController<double, double>>& icontroller)
- Velocity controller that automatically writes to the motor.
Public functions
- auto step(double ireading) -> 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 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.
Protected variables
- std::shared_ptr<AbstractMotor> motor
- std::shared_ptr<IterativeVelocityController<double, double>> controller
Function documentation
double okapi:: IterativeMotorVelocityController:: step(double ireading) override
Do one iteration of the controller.
Returns | controller output |
---|
void okapi:: IterativeMotorVelocityController:: 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 okapi:: IterativeMotorVelocityController:: getTarget() override
Gets the last set target, or the default target if none was set.
Returns | the last target |
---|
double okapi:: IterativeMotorVelocityController:: getProcessValue() const override
Returns | The most recent value of the process variable. |
---|
double okapi:: IterativeMotorVelocityController:: getMaxOutput() override
Get the upper output bound.
Returns | the upper output bound |
---|
double okapi:: IterativeMotorVelocityController:: getMinOutput() override
Get the lower output bound.
Returns | the lower output bound |
---|
double okapi:: IterativeMotorVelocityController:: getError() const override
Returns the last error of the controller.
Does not update when disabled.
bool okapi:: IterativeMotorVelocityController:: isSettled() override
Returns whether the controller has settled at the target.
Returns | whether the controller is settled |
---|
Determining what settling means is implementation-dependent.
void okapi:: IterativeMotorVelocityController:: setSampleTime(QTime isampleTime) override
Set time between loops in ms.
Parameters | |
---|---|
isampleTime | time between loops in ms |
void okapi:: IterativeMotorVelocityController:: setOutputLimits(double imax,
double imin) override
Set controller output bounds.
Parameters | |
---|---|
imax | max output |
imin | min output |
void okapi:: IterativeMotorVelocityController:: 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 okapi:: IterativeMotorVelocityController:: 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 okapi:: IterativeMotorVelocityController:: 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 okapi:: IterativeMotorVelocityController:: isDisabled() const override
Returns whether the controller is currently disabled.
Returns | whether the controller is currently disabled |
---|
QTime okapi:: IterativeMotorVelocityController:: getSampleTime() const override
Get the last set sample time.
Returns | sample time |
---|