21template <
typename Input,
typename Output>
38 const Supplier<std::unique_ptr<AbstractRate>> &irateSupplier,
39 const double iratio = 1,
54 dtorCalled.store(
true, std::memory_order_release);
62 LOG_INFO(
"AsyncWrapper: Set target to " + std::to_string(itarget));
147 controller->setControllerSetTargetLimits(itargetMax, itargetMin);
195 LOG_INFO(
"AsyncWrapper: flipDisable " + std::to_string(iisDisabled));
214 LOG_INFO_S(
"AsyncWrapper: Waiting to settle");
221 LOG_INFO_S(
"AsyncWrapper: Done waiting to settle");
246 std::shared_ptr<ControllerInput<Input>>
input;
247 std::shared_ptr<ControllerOutput<Output>>
output;
248 std::shared_ptr<IterativeController<Input, Output>>
controller;
268 rate->delayUntil(
controller->getSampleTime());
Closed-loop controller that steps on its own in another thread and automatically writes to the output...
void waitUntilSettled() override
Blocks the current task until the controller has settled.
Input getTarget() override
Gets the last set target, or the default target if none was set.
CrossplatformThread * getThread() const
Returns the underlying thread handle.
Output getMinOutput()
Get the lower output bound.
std::shared_ptr< IterativeController< Input, Output > > controller
void startThread()
Starts the internal thread.
Output getError() const override
Returns the last error of the controller.
void setOutputLimits(const Output imax, const Output imin)
Set controller output bounds.
virtual void resumeMovement()
Resumes moving after the controller is reset.
AsyncWrapper(AsyncWrapper< Input, Output > &&other)=delete
Output getOutput() const
Returns the last calculated output of the controller.
std::shared_ptr< ControllerOutput< Output > > output
bool isDisabled() const override
Returns whether the controller is currently disabled.
CrossplatformThread * task
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,...
Output getMaxOutput()
Get the upper output bound.
std::shared_ptr< ControllerInput< Input > > input
std::shared_ptr< Logger > logger
void setControllerSetTargetLimits(double itargetMax, double itargetMin)
Sets the (soft) limits for the target range that controllerSet() scales into.
void setTarget(const Input itarget) override
Sets the target for the controller.
AsyncWrapper< Input, Output > & operator=(AsyncWrapper< Input, Output > &&other)=delete
static void trampoline(void *context)
std::atomic_bool dtorCalled
void flipDisable(const bool iisDisabled) override
Sets whether the controller is off or on.
Input getProcessValue() const override
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 anoth...
Supplier< std::unique_ptr< AbstractRate > > rateSupplier
void controllerSet(const Input ivalue) override
Writes the value of the controller output.
void flipDisable() override
Changes whether the controller is off or on.
void setSampleTime(const QTime &isampleTime)
Set time between loops.
Closed-loop controller that steps iteratively using the step method below.
static std::shared_ptr< Logger > getDefaultLogger()
A supplier of instances of T.
static constexpr std::int8_t motorUpdateRate
The polling frequency of V5 motors in milliseconds.