4#ifndef GREM_CORE_CONTROL_HPP
5#define GREM_CORE_CONTROL_HPP
46 constexpr void reset(T newError) {
64 template <
typename Coefficient>
65 [[nodiscard]]
constexpr auto update(T newSignalError, Coefficient proportionalGain, Coefficient derivativeGain) {
66 const T currentError = newSignalError;
67 const T changeInError = currentError - error;
68 const auto result = currentError * proportionalGain + changeInError * derivativeGain;
112 constexpr void reset(T newIntegral) {
130 template <
typename Coefficient>
131 [[nodiscard]]
constexpr auto update(T newSignalError, Coefficient proportionalGain, Coefficient integralGain) {
132 const T currentError = newSignalError;
133 const T accumulatedError =
integral + currentError;
134 const auto result = currentError * proportionalGain + accumulatedError * integralGain;
182 constexpr void reset(T newError, T newIntegral) {
222 template <
typename Coefficient>
223 [[nodiscard]]
constexpr auto update(T newSignalError, Coefficient proportionalGain, Coefficient integralGain, Coefficient derivativeGain) {
224 const T currentError = newSignalError;
225 const T accumulatedError =
integral + currentError;
226 const T changeInError = currentError - error;
227 const auto result = currentError * proportionalGain + accumulatedError * integralGain + changeInError * derivativeGain;
228 error = currentError;
constexpr PDController(T error)
Construct a PD controller with specific initial values.
Definition control.hpp:31
constexpr auto update(T newSignalError, Coefficient proportionalGain, Coefficient derivativeGain)
Update the controller state and get the next control variable value to use in order to steer the proc...
Definition control.hpp:65
constexpr PDController()=default
Default-construct a PD controller.
constexpr void reset(T newError)
Reset the PD controller to a specific value.
Definition control.hpp:46
constexpr void reset()
Reset the PD controller to the default state.
Definition control.hpp:37
constexpr void reset(T newIntegral)
Reset the PI controller to a specific value.
Definition control.hpp:112
constexpr PIController(T integral)
Construct a PI controller with specific initial values.
Definition control.hpp:97
constexpr void reset()
Reset the PI controller to the default state.
Definition control.hpp:103
constexpr PIController()=default
Default-construct a PI controller.
constexpr auto update(T newSignalError, Coefficient proportionalGain, Coefficient integralGain)
Update the controller state and get the next control variable value to use in order to steer the proc...
Definition control.hpp:131
constexpr PIDController(T error, T integral)
Construct a PID controller with specific initial values.
Definition control.hpp:164
constexpr void reset(T newError, T newIntegral)
Reset the PID controller to specific values.
Definition control.hpp:182
constexpr void reset()
Reset the PID controller to the default state.
Definition control.hpp:171
constexpr PIDController()=default
Default-construct a PID controller.
constexpr void resetIntegral(T newIntegral={})
Reset the PID controller's accumulated integral to a specific value.
Definition control.hpp:201
constexpr auto update(T newSignalError, Coefficient proportionalGain, Coefficient integralGain, Coefficient derivativeGain)
Update the controller state and get the next control variable value to use in order to steer the proc...
Definition control.hpp:223
constexpr void resetError(T newError={})
Reset the PID controller's latest error to a specific value.
Definition control.hpp:192
Definition concepts.hpp:67