class
AsyncPosIntegratedControllerClosed-loop controller that uses the V5 motor's onboard control to move.
Contents
Input units are whatever units the motor is in.
Base classes
-
template<typename Input, typename Output>class AsyncPositionController
Constructors, destructors, conversion operators
-
AsyncPosIntegratedController(const std::shared_ptr<AbstractMotor>& imotor,
const AbstractMotor::
GearsetRatioPair& ipair, std::int32_t imaxVelocity, const TimeUtil& itimeUtil, const std::shared_ptr<Logger>& ilogger = Logger:: getDefaultLogger()) - Closed-loop controller that uses the V5 motor's onboard control to move.
Public functions
- void setTarget(double itarget) override
- Sets the target for the controller.
- auto getTarget() -> double override
- Gets the last set target, or the default target if none was set.
- auto getProcessValue() const -> double override
- 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 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.
- void waitUntilSettled() override
- Blocks the current task until the controller has settled.
- void controllerSet(double ivalue) override
- Writes the value of the controller output.
- void tarePosition() override
- Sets the "absolute" zero position of the controller to its current position.
- void setMaxVelocity(std::int32_t imaxVelocity) override
- Sets a new maximum velocity in motor RPM [0-600].
- void stop() virtual
- Stops the motor mid-movement.
Protected functions
- void resumeMovement() virtual
- Resumes moving after the controller is reset.
Protected variables
- std::shared_ptr<Logger> logger
- TimeUtil timeUtil
- std::shared_ptr<AbstractMotor> motor
-
AbstractMotor::
GearsetRatioPair pair - std::int32_t maxVelocity
- double lastTarget
- double offset
- bool controllerIsDisabled
- bool hasFirstTarget
- std::unique_ptr<SettledUtil> settledUtil
Function documentation
okapi:: AsyncPosIntegratedController:: AsyncPosIntegratedController(const std::shared_ptr<AbstractMotor>& imotor,
const AbstractMotor:: GearsetRatioPair& ipair,
std::int32_t imaxVelocity,
const TimeUtil& itimeUtil,
const std::shared_ptr<Logger>& ilogger = Logger:: getDefaultLogger())
Closed-loop controller that uses the V5 motor's onboard control to move.
Parameters | |
---|---|
imotor | The motor to control. |
ipair | The gearset. |
imaxVelocity | The maximum velocity after gearing. |
itimeUtil | The TimeUtil. |
ilogger | The logger this instance will log to. |
Input units are whatever units the motor is in. Throws a std::invalid_argument exception if the gear ratio is zero.
double okapi:: AsyncPosIntegratedController:: getTarget() override
Gets the last set target, or the default target if none was set.
Returns | the last target |
---|
double okapi:: AsyncPosIntegratedController:: getProcessValue() const override
Returns | The most recent value of the process variable. |
---|
double okapi:: AsyncPosIntegratedController:: getError() const override
Returns the last error of the controller.
Does not update when disabled.
bool okapi:: AsyncPosIntegratedController:: 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 okapi:: AsyncPosIntegratedController:: 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:: AsyncPosIntegratedController:: 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:: AsyncPosIntegratedController:: isDisabled() const override
Returns whether the controller is currently disabled.
Returns | whether the controller is currently disabled |
---|
void okapi:: AsyncPosIntegratedController:: waitUntilSettled() override
Blocks the current task until the controller has settled.
Determining what settling means is implementation-dependent.
void okapi:: AsyncPosIntegratedController:: 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].
void okapi:: AsyncPosIntegratedController:: setMaxVelocity(std::int32_t imaxVelocity) override
Sets a new maximum velocity in motor RPM [0-600].
Parameters | |
---|---|
imaxVelocity | The new maximum velocity in motor RPM [0-600]. |
void okapi:: AsyncPosIntegratedController:: stop() virtual
Stops the motor mid-movement.
Does not change the last set target.
void okapi:: AsyncPosIntegratedController:: resumeMovement() virtual protected
Resumes moving after the controller is reset.
Should not cause movement if the controller is turned off, reset, and turned back on.