LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::AsyncVelIntegratedController Class Reference

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

#include <asyncVelIntegratedController.hpp>

Inheritance diagram for okapi::AsyncVelIntegratedController:
okapi::AsyncVelocityController< double, double > okapi::AsyncController< Input, Output > okapi::ClosedLoopController< Input, Output > okapi::ControllerOutput< Input >

Public Member Functions

 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.
 
void setTarget (double itarget) override
 Sets the target for the controller.
 
double getTarget () override
 Gets the last set target, or the default target if none was set.
 
double getProcessValue () const override
 
double getError () const override
 Returns the last error of the controller.
 
bool isSettled () 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.
 
bool isDisabled () const 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.
 
- 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 Member Functions

virtual void resumeMovement ()
 

Protected Attributes

std::shared_ptr< Loggerlogger
 
TimeUtil timeUtil
 
std::shared_ptr< AbstractMotormotor
 
AbstractMotor::GearsetRatioPair pair
 
std::int32_t maxVelocity
 
double lastTarget = 0
 
bool controllerIsDisabled = false
 
bool hasFirstTarget = false
 
std::unique_ptr< SettledUtilsettledUtil
 

Detailed Description

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

Input units are whatever units the motor is in.

Definition at line 19 of file asyncVelIntegratedController.hpp.

Constructor & Destructor Documentation

◆ AsyncVelIntegratedController()

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.

Input units are whatever units the motor is in. Throws a std::invalid_argument exception if the gear ratio is zero.

Parameters
imotorThe motor to control.
ipairThe gearset.
imaxVelocityThe maximum velocity after gearing.
itimeUtilThe TimeUtil.
iloggerThe logger this instance will log to.

Member Function Documentation

◆ controllerSet()

void okapi::AsyncVelIntegratedController::controllerSet ( double  ivalue)
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].

Parameters
ivaluethe controller's output in the range [-1, 1]

◆ flipDisable() [1/2]

void okapi::AsyncVelIntegratedController::flipDisable ( )
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 >.

◆ flipDisable() [2/2]

void okapi::AsyncVelIntegratedController::flipDisable ( bool  iisDisabled)
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.

Parameters
iisDisabledwhether the controller is disabled

Implements okapi::ClosedLoopController< Input, Output >.

◆ getError()

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

Returns the last error of the controller.

Does not update when disabled.

Implements okapi::ClosedLoopController< Input, Output >.

◆ getProcessValue()

double okapi::AsyncVelIntegratedController::getProcessValue ( ) const
overridevirtual
Returns
The most recent value of the process variable.

Implements okapi::ClosedLoopController< Input, Output >.

◆ getTarget()

double okapi::AsyncVelIntegratedController::getTarget ( )
overridevirtual

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

Returns
the last target

Implements okapi::ClosedLoopController< Input, Output >.

◆ isDisabled()

bool okapi::AsyncVelIntegratedController::isDisabled ( ) const
overridevirtual

Returns whether the controller is currently disabled.

Returns
whether the controller is currently disabled

Implements okapi::ClosedLoopController< Input, Output >.

◆ isSettled()

bool okapi::AsyncVelIntegratedController::isSettled ( )
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.

Returns
whether the controller is settled

Implements okapi::ClosedLoopController< Input, Output >.

◆ reset()

void okapi::AsyncVelIntegratedController::reset ( )
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 >.

◆ resumeMovement()

virtual void okapi::AsyncVelIntegratedController::resumeMovement ( )
protectedvirtual

◆ setTarget()

void okapi::AsyncVelIntegratedController::setTarget ( double  itarget)
override

Sets the target for the controller.

◆ waitUntilSettled()

void okapi::AsyncVelIntegratedController::waitUntilSettled ( )
overridevirtual

Blocks the current task until the controller has settled.

Determining what settling means is implementation-dependent.

Implements okapi::AsyncController< Input, Output >.

Member Data Documentation

◆ controllerIsDisabled

bool okapi::AsyncVelIntegratedController::controllerIsDisabled = false
protected

Definition at line 118 of file asyncVelIntegratedController.hpp.

◆ hasFirstTarget

bool okapi::AsyncVelIntegratedController::hasFirstTarget = false
protected

Definition at line 119 of file asyncVelIntegratedController.hpp.

◆ lastTarget

double okapi::AsyncVelIntegratedController::lastTarget = 0
protected

Definition at line 117 of file asyncVelIntegratedController.hpp.

◆ logger

std::shared_ptr<Logger> okapi::AsyncVelIntegratedController::logger
protected

Definition at line 112 of file asyncVelIntegratedController.hpp.

◆ maxVelocity

std::int32_t okapi::AsyncVelIntegratedController::maxVelocity
protected

Definition at line 116 of file asyncVelIntegratedController.hpp.

◆ motor

std::shared_ptr<AbstractMotor> okapi::AsyncVelIntegratedController::motor
protected

Definition at line 114 of file asyncVelIntegratedController.hpp.

◆ pair

AbstractMotor::GearsetRatioPair okapi::AsyncVelIntegratedController::pair
protected

Definition at line 115 of file asyncVelIntegratedController.hpp.

◆ settledUtil

std::unique_ptr<SettledUtil> okapi::AsyncVelIntegratedController::settledUtil
protected

Definition at line 120 of file asyncVelIntegratedController.hpp.

◆ timeUtil

TimeUtil okapi::AsyncVelIntegratedController::timeUtil
protected

Definition at line 113 of file asyncVelIntegratedController.hpp.


The documentation for this class was generated from the following file: