okapi::AsyncVelIntegratedController class

Closed-loop controller that uses the V5 motor's onboard control to move.

Input units are whatever units the motor is in.

Base classes

template<typename Input, typename Output>
class AsyncVelocityController

Constructors, destructors, conversion operators

AsyncVelIntegratedController(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.

Protected functions

void resumeMovement() virtual

Protected variables

std::shared_ptr<Logger> logger
TimeUtil timeUtil
std::shared_ptr<AbstractMotor> motor
AbstractMotor::GearsetRatioPair pair
std::int32_t maxVelocity
double lastTarget
bool controllerIsDisabled
bool hasFirstTarget
std::unique_ptr<SettledUtil> settledUtil

Function documentation

okapi::AsyncVelIntegratedController::AsyncVelIntegratedController(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::AsyncVelIntegratedController::getTarget() override

Gets the last set target, or the default target if none was set.

Returns the last target

double okapi::AsyncVelIntegratedController::getProcessValue() const override

Returns The most recent value of the process variable.

double okapi::AsyncVelIntegratedController::getError() const override

Returns the last error of the controller.

Does not update when disabled.

bool okapi::AsyncVelIntegratedController::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::AsyncVelIntegratedController::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::AsyncVelIntegratedController::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::AsyncVelIntegratedController::isDisabled() const override

Returns whether the controller is currently disabled.

Returns whether the controller is currently disabled

void okapi::AsyncVelIntegratedController::waitUntilSettled() override

Blocks the current task until the controller has settled.

Determining what settling means is implementation-dependent.

void okapi::AsyncVelIntegratedController::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].