35 : p(
std::numeric_limits<double>::quiet_NaN())
37 ,
d(
std::numeric_limits<double>::quiet_NaN())
38 , input(
std::numeric_limits<double>::quiet_NaN())
40 , dx(
std::numeric_limits<double>::quiet_NaN())
50 , limit_i(
std::numeric_limits<double>::quiet_NaN())
51 , limit_output(
std::numeric_limits<double>::quiet_NaN())
81 template <
typename T>
static inline T&
checknan(T& value)
83 if (std::isnan(value)) value = T();
90 double dt_sec = dt.
toSec();
105 if (std::isnan(error))
return 0.0;
106 double dt_sec = dt.
toSec();
135 if (antiwindup && (error * dt_sec * antiwindup > 0.0))
state_.
i -= error * dt_sec;
143 double dt_sec = dt.
toSec();
144 filtered_error =
checknan(filtered_error);
145 if (dt_sec + time_constant > 0.0) {
146 filtered_error = (time_constant * filtered_error + dt_sec *
state_.
p) / (dt_sec + time_constant);
148 return filtered_error;
struct hector_quadrotor_controller::PID::parameters parameters_
static T & checknan(T &value)
void init(const ros::NodeHandle ¶m_nh)
double update(double input, double x, double dx, const ros::Duration &dt)
bool getParam(const std::string &key, std::string &s) const
struct hector_quadrotor_controller::PID::state state_
double getFilteredControlError(double &filtered_error, double time_constant, const ros::Duration &dt)