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

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

#include <asyncPosIntegratedController.hpp>

Inheritance diagram for okapi::AsyncPosIntegratedController:
okapi::AsyncPositionController< double, double > okapi::AsyncController< Input, Output > okapi::ClosedLoopController< Input, Output > okapi::ControllerOutput< Input >

Public Member Functions

 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.
 
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.
 
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].
 
virtual void stop ()
 Stops the motor mid-movement.
 
- 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 ()
 Resumes moving after the controller is reset.
 

Protected Attributes

std::shared_ptr< Loggerlogger
 
TimeUtil timeUtil
 
std::shared_ptr< AbstractMotormotor
 
AbstractMotor::GearsetRatioPair pair
 
std::int32_t maxVelocity
 
double lastTarget {0}
 
double offset {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 18 of file asyncPosIntegratedController.hpp.

Constructor & Destructor Documentation

◆ AsyncPosIntegratedController()

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.

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::AsyncPosIntegratedController::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::AsyncPosIntegratedController::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::AsyncPosIntegratedController::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::AsyncPosIntegratedController::getError ( ) const
overridevirtual

Returns the last error of the controller.

Does not update when disabled.

Implements okapi::ClosedLoopController< Input, Output >.

◆ getProcessValue()

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

Implements okapi::ClosedLoopController< Input, Output >.

◆ getTarget()

double okapi::AsyncPosIntegratedController::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::AsyncPosIntegratedController::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::AsyncPosIntegratedController::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::AsyncPosIntegratedController::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::AsyncPosIntegratedController::resumeMovement ( )
protectedvirtual

Resumes moving after the controller is reset.

Should not cause movement if the controller is turned off, reset, and turned back on.

◆ setMaxVelocity()

void okapi::AsyncPosIntegratedController::setMaxVelocity ( std::int32_t  imaxVelocity)
overridevirtual

Sets a new maximum velocity in motor RPM [0-600].

Parameters
imaxVelocityThe new maximum velocity in motor RPM [0-600].

Implements okapi::AsyncPositionController< double, double >.

◆ setTarget()

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

Sets the target for the controller.

◆ stop()

virtual void okapi::AsyncPosIntegratedController::stop ( )
virtual

Stops the motor mid-movement.

Does not change the last set target.

◆ tarePosition()

void okapi::AsyncPosIntegratedController::tarePosition ( )
overridevirtual

Sets the "absolute" zero position of the controller to its current position.

Implements okapi::AsyncPositionController< double, double >.

◆ waitUntilSettled()

void okapi::AsyncPosIntegratedController::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::AsyncPosIntegratedController::controllerIsDisabled {false}
protected

Definition at line 135 of file asyncPosIntegratedController.hpp.

◆ hasFirstTarget

bool okapi::AsyncPosIntegratedController::hasFirstTarget {false}
protected

Definition at line 136 of file asyncPosIntegratedController.hpp.

◆ lastTarget

double okapi::AsyncPosIntegratedController::lastTarget {0}
protected

Definition at line 133 of file asyncPosIntegratedController.hpp.

◆ logger

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

Definition at line 128 of file asyncPosIntegratedController.hpp.

◆ maxVelocity

std::int32_t okapi::AsyncPosIntegratedController::maxVelocity
protected

Definition at line 132 of file asyncPosIntegratedController.hpp.

◆ motor

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

Definition at line 130 of file asyncPosIntegratedController.hpp.

◆ offset

double okapi::AsyncPosIntegratedController::offset {0}
protected

Definition at line 134 of file asyncPosIntegratedController.hpp.

◆ pair

AbstractMotor::GearsetRatioPair okapi::AsyncPosIntegratedController::pair
protected

Definition at line 131 of file asyncPosIntegratedController.hpp.

◆ settledUtil

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

Definition at line 137 of file asyncPosIntegratedController.hpp.

◆ timeUtil

TimeUtil okapi::AsyncPosIntegratedController::timeUtil
protected

Definition at line 129 of file asyncPosIntegratedController.hpp.


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