38 LOG_INFO(
"ControllerRunner: runUntilSettled(AsyncController): Set target to " +
39 std::to_string(itarget));
43 rate->delayUntil(10_ms);
46 LOG_INFO(
"ControllerRunner: runUntilSettled(AsyncController): Done waiting to settle");
61 LOG_INFO(
"ControllerRunner: runUntilSettled(IterativeController): Set target to " +
62 std::to_string(itarget));
67 rate->delayUntil(10_ms);
70 LOG_INFO(
"ControllerRunner: runUntilSettled(IterativeController): Done waiting to settle");
83 LOG_INFO(
"ControllerRunner: runUntilAtTarget(AsyncController): Set target to " +
84 std::to_string(itarget));
87 double error = icontroller.
getError();
88 double lastError = error;
89 while (error != 0 && std::copysign(1.0, error) == std::copysign(1.0, lastError)) {
91 rate->delayUntil(10_ms);
95 LOG_INFO(
"ControllerRunner: runUntilAtTarget(AsyncController): Done waiting to settle");
110 LOG_INFO(
"ControllerRunner: runUntilAtTarget(IterativeController): Set target to " +
111 std::to_string(itarget));
114 double error = icontroller.
getError();
115 double lastError = error;
116 while (error != 0 && std::copysign(1.0, error) == std::copysign(1.0, lastError)) {
119 rate->delayUntil(10_ms);
123 LOG_INFO(
"ControllerRunner: runUntilAtTarget(IterativeController): Done waiting to settle");
129 std::unique_ptr<AbstractRate>
rate;
Closed-loop controller that steps on its own in another thread and automatically writes to the output...
virtual Output getError() const =0
Returns the last error of the controller.
virtual void setTarget(Input itarget)=0
Sets the target for the controller.
virtual bool isSettled()=0
Returns whether the controller has settled at the target.
virtual void controllerSet(T ivalue)=0
Writes the value of the controller output.
std::shared_ptr< Logger > logger
ControllerRunner(const TimeUtil &itimeUtil, const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
A utility class that runs a closed-loop controller.
virtual Output runUntilSettled(const Input itarget, AsyncController< Input, Output > &icontroller)
Runs the controller until it has settled.
virtual Output runUntilAtTarget(const Input itarget, AsyncController< Input, Output > &icontroller)
Runs the controller until it has reached its target, but not necessarily settled.
virtual Output runUntilSettled(const Input itarget, IterativeController< Input, Output > &icontroller, ControllerOutput< Output > &ioutput)
Runs the controller until it has settled.
std::unique_ptr< AbstractRate > rate
virtual Output runUntilAtTarget(const Input itarget, IterativeController< Input, Output > &icontroller, ControllerOutput< Output > &ioutput)
Runs the controller until it has reached its target, but not necessarily settled.
Closed-loop controller that steps iteratively using the step method below.
virtual Output getOutput() const =0
Returns the last calculated output of the controller.
static std::shared_ptr< Logger > getDefaultLogger()
Utility class for holding an AbstractTimer, AbstractRate, and SettledUtil together in one class since...