1#ifndef FANG_ROBOTICS_MCB_TRAP_SMOOTH_PID_HPP
2#define FANG_ROBOTICS_MCB_TRAP_SMOOTH_PID_HPP
20 template<
typename ErrorType,
typename ControlType,
typename TimeUnit>
28 : m_smoothPid{
config}, m_lastError{initialLastError}
46 ControlType
runController(
const ErrorType& error,
const TimeUnit& deltaTime)
48 const ErrorType deltaError{error - m_lastError};
49 const double errorDerivative{
static_cast<double>(deltaError) /
static_cast<double>(deltaTime)};
53 m_lastDerivative = errorDerivative;
63 ControlType
runController(ErrorType error,
double errorDerivative, TimeUnit deltaTime)
65 float result {m_smoothPid.
runController(
static_cast<float>(error),
static_cast<float>(errorDerivative),
static_cast<float>(deltaTime))};
67 static float testResult{};
69 return ControlType{result};
73 static constexpr double k_lowPassAlpha{0.0};
75 ErrorType m_lastError{0};
76 double m_lastDerivative{0};
Definition simple_timer.hpp:12
Microseconds getDurationAndReset()
Definition simple_timer.cpp:20
Definition smooth_pid.hpp:57
virtual float runController(float error, float errorDerivative, float dt)
Definition smooth_pid.cpp:41
Definition smooth_pid.hpp:22
ControlType runController(ErrorType error)
Definition smooth_pid.hpp:37
SmoothPid(const Config &config, ErrorType initialLastError=ErrorType{0.0})
Definition smooth_pid.hpp:27
ControlType runController(const ErrorType &error, const TimeUnit &deltaTime)
Definition smooth_pid.hpp:46
ControlType runController(ErrorType error, double errorDerivative, TimeUnit deltaTime)
Definition smooth_pid.hpp:63
#define FANG_ASSERT(CONDITION, DESC)
Definition fang_assert.hpp:24
Definition pwm_info.hpp:4
float lowPassFilter(float prevValue, float newValue, float alpha)
Definition math_user_utils.hpp:113
Definition dimensional_smooth_pid.hpp:8
Definition smooth_pid.hpp:36