|
LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
|
#include <asyncWrapper.hpp>
Public Member Functions | |
| AsyncWrapper (const std::shared_ptr< ControllerInput< Input > > &iinput, const std::shared_ptr< ControllerOutput< Output > > &ioutput, const std::shared_ptr< IterativeController< Input, Output > > &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< Input, Output > &&other)=delete | |
| AsyncWrapper< Input, Output > & | operator= (AsyncWrapper< Input, Output > &&other)=delete |
| ~AsyncWrapper () override | |
| void | setTarget (const Input itarget) override |
| Sets the target for the controller. | |
| void | controllerSet (const Input ivalue) override |
| Writes the value of the controller output. | |
| Input | getTarget () override |
| Gets the last set target, or the default target if none was set. | |
| Input | getProcessValue () const override |
| Output | getOutput () const |
| Returns the last calculated output of the controller. | |
| Output | 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 Output imax, const Output imin) |
| Set controller output bounds. | |
| void | setControllerSetTargetLimits (double itargetMax, double itargetMin) |
| Sets the (soft) limits for the target range that controllerSet() scales into. | |
| Output | getMaxOutput () |
| Get the upper output bound. | |
| Output | 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. | |
| CrossplatformThread * | getThread () const |
| Returns the underlying thread handle. | |
Public Member Functions inherited from okapi::ClosedLoopController< Input, Output > | |
| virtual | ~ClosedLoopController ()=default |
Protected Member Functions | |
| void | loop () |
| virtual void | resumeMovement () |
| Resumes moving after the controller is reset. | |
Static Protected Member Functions | |
| static void | trampoline (void *context) |
Protected Attributes | |
| std::shared_ptr< Logger > | logger |
| Supplier< std::unique_ptr< AbstractRate > > | rateSupplier |
| std::shared_ptr< ControllerInput< Input > > | input |
| std::shared_ptr< ControllerOutput< Output > > | output |
| std::shared_ptr< IterativeController< Input, Output > > | controller |
| bool | hasFirstTarget {false} |
| Input | lastTarget |
| double | ratio |
| std::atomic_bool | dtorCalled {false} |
| CrossplatformThread * | task {nullptr} |
Definition at line 22 of file asyncWrapper.hpp.
|
inline |
A wrapper class that transforms an IterativeController into an AsyncController by running it in another task.
The input controller will act like an AsyncController.
| iinput | controller input, passed to the IterativeController |
| ioutput | controller output, written to from the IterativeController |
| icontroller | the controller to use |
| irateSupplier | used for rates used in the main loop and in waitUntilSettled |
| iratio | Any external gear ratio. |
| ilogger | The logger this instance will log to. |
Definition at line 35 of file asyncWrapper.hpp.
|
delete |
|
inlineoverride |
Definition at line 53 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
Writes the value of the controller output.
This method might be automatically called in another thread by the controller.
| ivalue | the controller's output |
Implements okapi::ControllerOutput< Input >.
Definition at line 74 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
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 >.
Definition at line 182 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
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.
| iisDisabled | whether the controller is disabled |
Implements okapi::ClosedLoopController< Input, Output >.
Definition at line 194 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
Returns the last error of the controller.
Does not update when disabled.
Implements okapi::ClosedLoopController< Input, Output >.
Definition at line 104 of file asyncWrapper.hpp.
|
inline |
Get the upper output bound.
Definition at line 155 of file asyncWrapper.hpp.
|
inline |
Get the lower output bound.
Definition at line 164 of file asyncWrapper.hpp.
|
inline |
Returns the last calculated output of the controller.
Definition at line 97 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
Implements okapi::ClosedLoopController< Input, Output >.
Definition at line 90 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
Gets the last set target, or the default target if none was set.
Implements okapi::ClosedLoopController< Input, Output >.
Definition at line 83 of file asyncWrapper.hpp.
|
inline |
Returns the underlying thread handle.
Definition at line 239 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
Returns whether the controller is currently disabled.
Implements okapi::ClosedLoopController< Input, Output >.
Definition at line 205 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
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.
Implements okapi::ClosedLoopController< Input, Output >.
Definition at line 116 of file asyncWrapper.hpp.
|
inlineprotected |
Definition at line 261 of file asyncWrapper.hpp.
|
delete |
|
inlineoverridevirtual |
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 >.
Definition at line 172 of file asyncWrapper.hpp.
|
inlineprotectedvirtual |
Resumes moving after the controller is reset.
Should not cause movement if the controller is turned off, reset, and turned back on.
Definition at line 276 of file asyncWrapper.hpp.
|
inline |
Sets the (soft) limits for the target range that controllerSet() scales into.
The target computed by controllerSet() is scaled into the range [-itargetMin, itargetMax].
| itargetMax | The new max target for controllerSet(). |
| itargetMin | The new min target for controllerSet(). |
Definition at line 146 of file asyncWrapper.hpp.
|
inline |
Set controller output bounds.
| imax | max output |
| imin | min output |
Definition at line 135 of file asyncWrapper.hpp.
|
inline |
Set time between loops.
| isampleTime | time between loops |
Definition at line 125 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
Sets the target for the controller.
Implements okapi::ClosedLoopController< Input, Output >.
Definition at line 61 of file asyncWrapper.hpp.
|
inline |
Starts the internal thread.
This should not be called by normal users. This method is called by the AsyncControllerFactory when making a new instance of this class.
Definition at line 228 of file asyncWrapper.hpp.
|
inlinestaticprotected |
Definition at line 255 of file asyncWrapper.hpp.
|
inlineoverridevirtual |
Blocks the current task until the controller has settled.
Determining what settling means is implementation-dependent.
Implements okapi::AsyncController< Input, Output >.
Definition at line 213 of file asyncWrapper.hpp.
|
protected |
Definition at line 248 of file asyncWrapper.hpp.
|
protected |
Definition at line 252 of file asyncWrapper.hpp.
|
protected |
Definition at line 249 of file asyncWrapper.hpp.
|
protected |
Definition at line 246 of file asyncWrapper.hpp.
|
protected |
Definition at line 250 of file asyncWrapper.hpp.
|
protected |
Definition at line 244 of file asyncWrapper.hpp.
|
protected |
Definition at line 247 of file asyncWrapper.hpp.
|
protected |
Definition at line 245 of file asyncWrapper.hpp.
|
protected |
Definition at line 251 of file asyncWrapper.hpp.
|
protected |
Definition at line 253 of file asyncWrapper.hpp.