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

#include <asyncPosPidController.hpp>

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

Public Member Functions

 AsyncPosPIDController (const std::shared_ptr< ControllerInput< double > > &iinput, const std::shared_ptr< ControllerOutput< double > > &ioutput, const TimeUtil &itimeUtil, double ikP, double ikI, double ikD, double ikBias=0, double iratio=1, std::unique_ptr< Filter > iderivativeFilter=std::make_unique< PassthroughFilter >(), const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
 An async position PID controller.
 
 AsyncPosPIDController (const std::shared_ptr< OffsetableControllerInput > &iinput, const std::shared_ptr< ControllerOutput< double > > &ioutput, const TimeUtil &itimeUtil, double ikP, double ikI, double ikD, double ikBias=0, double iratio=1, std::unique_ptr< Filter > iderivativeFilter=std::make_unique< PassthroughFilter >(), const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
 An async position PID controller.
 
void tarePosition () override
 Sets the "absolute" zero position of the controller to its current position.
 
void setMaxVelocity (std::int32_t imaxVelocity) override
 This implementation does not respect the maximum velocity.
 
void setGains (const IterativePosPIDController::Gains &igains)
 Set controller gains.
 
IterativePosPIDController::Gains getGains () const
 Gets the current gains.
 
- Public Member Functions inherited from okapi::AsyncWrapper< double, double >
 AsyncWrapper (const std::shared_ptr< ControllerInput< double > > &iinput, const std::shared_ptr< ControllerOutput< double > > &ioutput, const std::shared_ptr< IterativeController< double, double > > &icontroller, const Supplier< std::unique_ptr< AbstractRate > > &irateSupplier, const double iratio=1, std::shared_ptr< Logger > ilogger=Logger::getDefaultLogger())
 A wrapper class that transforms an IterativeController into an AsyncController by running it in another task.
 
 AsyncWrapper (AsyncWrapper< double, double > &&other)=delete
 
AsyncWrapper< double, double > & operator= (AsyncWrapper< double, double > &&other)=delete
 
 ~AsyncWrapper () override
 
void setTarget (const double itarget) override
 Sets the target for the controller.
 
void controllerSet (const 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
 Returns the last calculated output of the controller.
 
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 (const QTime &isampleTime)
 Set time between loops.
 
void setOutputLimits (const double imax, const double imin)
 Set controller output bounds.
 
void setControllerSetTargetLimits (double itargetMax, double itargetMin)
 Sets the (soft) limits for the target range that controllerSet() scales into.
 
double getMaxOutput ()
 Get the upper output bound.
 
double getMinOutput ()
 Get the lower output bound.
 
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 (const 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 startThread ()
 Starts the internal thread.
 
CrossplatformThreadgetThread () const
 Returns the underlying thread handle.
 
- 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< OffsetableControllerInputoffsettableInput
 
std::shared_ptr< IterativePosPIDControllerinternalController
 
- Protected Attributes inherited from okapi::AsyncWrapper< double, double >
std::shared_ptr< Loggerlogger
 
Supplier< std::unique_ptr< AbstractRate > > rateSupplier
 
std::shared_ptr< ControllerInput< double > > input
 
std::shared_ptr< ControllerOutput< double > > output
 
std::shared_ptr< IterativeController< double, double > > controller
 
bool hasFirstTarget
 
double lastTarget
 
double ratio
 
std::atomic_bool dtorCalled
 
CrossplatformThreadtask
 

Additional Inherited Members

- Protected Member Functions inherited from okapi::AsyncWrapper< double, double >
void loop ()
 
virtual void resumeMovement ()
 Resumes moving after the controller is reset.
 
- Static Protected Member Functions inherited from okapi::AsyncWrapper< double, double >
static void trampoline (void *context)
 

Detailed Description

Definition at line 17 of file asyncPosPidController.hpp.

Constructor & Destructor Documentation

◆ AsyncPosPIDController() [1/2]

okapi::AsyncPosPIDController::AsyncPosPIDController ( const std::shared_ptr< ControllerInput< double > > &  iinput,
const std::shared_ptr< ControllerOutput< double > > &  ioutput,
const TimeUtil itimeUtil,
double  ikP,
double  ikI,
double  ikD,
double  ikBias = 0,
double  iratio = 1,
std::unique_ptr< Filter iderivativeFilter = std::make_unique< PassthroughFilter >(),
const std::shared_ptr< Logger > &  ilogger = Logger::getDefaultLogger() 
)

An async position PID controller.

Parameters
iinputThe controller input. Will be turned into an OffsettableControllerInput.
ioutputThe controller output.
itimeUtilThe TimeUtil.
ikPThe proportional gain.
ikIThe integral gain.
ikDThe derivative gain.
ikBiasThe controller bias.
iratioAny external gear ratio.
iderivativeFilterThe derivative filter.

◆ AsyncPosPIDController() [2/2]

okapi::AsyncPosPIDController::AsyncPosPIDController ( const std::shared_ptr< OffsetableControllerInput > &  iinput,
const std::shared_ptr< ControllerOutput< double > > &  ioutput,
const TimeUtil itimeUtil,
double  ikP,
double  ikI,
double  ikD,
double  ikBias = 0,
double  iratio = 1,
std::unique_ptr< Filter iderivativeFilter = std::make_unique< PassthroughFilter >(),
const std::shared_ptr< Logger > &  ilogger = Logger::getDefaultLogger() 
)

An async position PID controller.

Parameters
iinputThe controller input.
ioutputThe controller output.
itimeUtilThe TimeUtil.
ikPThe proportional gain.
ikIThe integral gain.
ikDThe derivative gain.
ikBiasThe controller bias.
iratioAny external gear ratio.
iderivativeFilterThe derivative filter.

Member Function Documentation

◆ getGains()

IterativePosPIDController::Gains okapi::AsyncPosPIDController::getGains ( ) const

Gets the current gains.

Returns
The current gains.

◆ setGains()

void okapi::AsyncPosPIDController::setGains ( const IterativePosPIDController::Gains igains)

Set controller gains.

Parameters
igainsThe new gains.

◆ setMaxVelocity()

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

This implementation does not respect the maximum velocity.

Parameters
imaxVelocityIgnored.

Implements okapi::AsyncPositionController< double, double >.

◆ tarePosition()

void okapi::AsyncPosPIDController::tarePosition ( )
overridevirtual

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

Implements okapi::AsyncPositionController< double, double >.

Member Data Documentation

◆ internalController

std::shared_ptr<IterativePosPIDController> okapi::AsyncPosPIDController::internalController
protected

Definition at line 98 of file asyncPosPidController.hpp.

◆ offsettableInput

std::shared_ptr<OffsetableControllerInput> okapi::AsyncPosPIDController::offsettableInput
protected

Definition at line 97 of file asyncPosPidController.hpp.


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