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

#include <asyncVelPidController.hpp>

Inheritance diagram for okapi::AsyncVelPIDController:
okapi::AsyncWrapper< double, double > okapi::AsyncVelocityController< 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

 AsyncVelPIDController (const std::shared_ptr< ControllerInput< double > > &iinput, const std::shared_ptr< ControllerOutput< double > > &ioutput, const TimeUtil &itimeUtil, double ikP, double ikD, double ikF, double ikSF, std::unique_ptr< VelMath > ivelMath, double iratio=1, std::unique_ptr< Filter > iderivativeFilter=std::make_unique< PassthroughFilter >(), const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
 An async velocity PID controller.
 
void setGains (const IterativeVelPIDController::Gains &igains)
 Set controller gains.
 
IterativeVelPIDController::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< IterativeVelPIDControllerinternalController
 
- 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 asyncVelPidController.hpp.

Constructor & Destructor Documentation

◆ AsyncVelPIDController()

okapi::AsyncVelPIDController::AsyncVelPIDController ( const std::shared_ptr< ControllerInput< double > > &  iinput,
const std::shared_ptr< ControllerOutput< double > > &  ioutput,
const TimeUtil itimeUtil,
double  ikP,
double  ikD,
double  ikF,
double  ikSF,
std::unique_ptr< VelMath ivelMath,
double  iratio = 1,
std::unique_ptr< Filter iderivativeFilter = std::make_unique< PassthroughFilter >(),
const std::shared_ptr< Logger > &  ilogger = Logger::getDefaultLogger() 
)

An async velocity PID controller.

Parameters
iinputThe controller input.
ioutputThe controller output.
itimeUtilThe TimeUtil.
ikPThe proportional gain.
ikDThe derivative gain.
ikFThe feed-forward gain.
ikSFA feed-forward gain to counteract static friction.
ivelMathThe VelMath used for calculating velocity.
iratioAny external gear ratio.
iderivativeFilterThe derivative filter.

Member Function Documentation

◆ getGains()

IterativeVelPIDController::Gains okapi::AsyncVelPIDController::getGains ( ) const

Gets the current gains.

Returns
The current gains.

◆ setGains()

void okapi::AsyncVelPIDController::setGains ( const IterativeVelPIDController::Gains igains)

Set controller gains.

Parameters
igainsThe new gains.

Member Data Documentation

◆ internalController

std::shared_ptr<IterativeVelPIDController> okapi::AsyncVelPIDController::internalController
protected

Definition at line 62 of file asyncVelPidController.hpp.


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