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

#include <iterativeMotorVelocityController.hpp>

Inheritance diagram for okapi::IterativeMotorVelocityController:
okapi::IterativeVelocityController< double, double > okapi::IterativeController< Input, Output > okapi::ClosedLoopController< Input, Output > okapi::ControllerOutput< Input >

Public Member Functions

 IterativeMotorVelocityController (const std::shared_ptr< AbstractMotor > &imotor, const std::shared_ptr< IterativeVelocityController< double, double > > &icontroller)
 Velocity controller that automatically writes to the motor.
 
double step (double ireading) 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.
 
double getTarget () override
 Gets the last set target, or the default target if none was set.
 
double getProcessValue () const override
 
double getOutput () const override
 Returns the last calculated output of the controller.
 
double getMaxOutput () override
 Get the upper output bound.
 
double getMinOutput () override
 Get the lower output bound.
 
double getError () const override
 Returns the last error of the controller.
 
bool isSettled () 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.
 
bool isDisabled () const override
 Returns whether the controller is currently disabled.
 
QTime getSampleTime () const override
 Get the last set sample time.
 
- Public Member Functions inherited from okapi::IterativeController< Input, Output >
virtual Output step (Input ireading)=0
 Do one iteration of the controller.
 
virtual void setOutputLimits (Output imax, Output imin)=0
 Set controller output bounds.
 
virtual void setControllerSetTargetLimits (Output itargetMax, Output itargetMin)=0
 Sets the (soft) limits for the target range that controllerSet() scales into.
 
- 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 Attributes

std::shared_ptr< AbstractMotormotor
 
std::shared_ptr< IterativeVelocityController< double, double > > controller
 

Detailed Description

Definition at line 14 of file iterativeMotorVelocityController.hpp.

Constructor & Destructor Documentation

◆ IterativeMotorVelocityController()

okapi::IterativeMotorVelocityController::IterativeMotorVelocityController ( const std::shared_ptr< AbstractMotor > &  imotor,
const std::shared_ptr< IterativeVelocityController< double, double > > &  icontroller 
)

Velocity controller that automatically writes to the motor.

Member Function Documentation

◆ controllerSet()

void okapi::IterativeMotorVelocityController::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::IterativeMotorVelocityController::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::IterativeMotorVelocityController::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::IterativeMotorVelocityController::getError ( ) const
overridevirtual

Returns the last error of the controller.

Does not update when disabled.

Implements okapi::ClosedLoopController< Input, Output >.

◆ getMaxOutput()

double okapi::IterativeMotorVelocityController::getMaxOutput ( )
overridevirtual

Get the upper output bound.

Returns
the upper output bound

Implements okapi::IterativeController< Input, Output >.

◆ getMinOutput()

double okapi::IterativeMotorVelocityController::getMinOutput ( )
overridevirtual

Get the lower output bound.

Returns
the lower output bound

Implements okapi::IterativeController< Input, Output >.

◆ getOutput()

double okapi::IterativeMotorVelocityController::getOutput ( ) const
overridevirtual

Returns the last calculated output of the controller.

Implements okapi::IterativeController< Input, Output >.

◆ getProcessValue()

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

Implements okapi::ClosedLoopController< Input, Output >.

◆ getSampleTime()

QTime okapi::IterativeMotorVelocityController::getSampleTime ( ) const
overridevirtual

Get the last set sample time.

Returns
sample time

Implements okapi::IterativeController< Input, Output >.

◆ getTarget()

double okapi::IterativeMotorVelocityController::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::IterativeMotorVelocityController::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::IterativeMotorVelocityController::isSettled ( )
overridevirtual

Returns whether the controller has settled at the target.

Determining what settling means is implementation-dependent.

Returns
whether the controller is settled

Implements okapi::ClosedLoopController< Input, Output >.

◆ reset()

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

◆ setControllerSetTargetLimits()

void okapi::IterativeMotorVelocityController::setControllerSetTargetLimits ( double  itargetMax,
double  itargetMin 
)
override

Sets the (soft) limits for the target range that controllerSet() scales into.

The target computed by controllerSet() is scaled into the range [-itargetMin, itargetMax].

Parameters
itargetMaxThe new max target for controllerSet().
itargetMinThe new min target for controllerSet().

◆ setOutputLimits()

void okapi::IterativeMotorVelocityController::setOutputLimits ( double  imax,
double  imin 
)
override

Set controller output bounds.

Parameters
imaxmax output
iminmin output

◆ setSampleTime()

void okapi::IterativeMotorVelocityController::setSampleTime ( QTime  isampleTime)
overridevirtual

Set time between loops in ms.

Parameters
isampleTimetime between loops in ms

Implements okapi::IterativeController< Input, Output >.

◆ setTarget()

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

Sets the target for the controller.

◆ step()

double okapi::IterativeMotorVelocityController::step ( double  ireading)
override

Do one iteration of the controller.

Parameters
inewReadingnew measurement
Returns
controller output

Member Data Documentation

◆ controller

std::shared_ptr<IterativeVelocityController<double, double> > okapi::IterativeMotorVelocityController::controller
protected

Definition at line 148 of file iterativeMotorVelocityController.hpp.

◆ motor

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

Definition at line 147 of file iterativeMotorVelocityController.hpp.


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