33#ifndef CONTROL_TOOLBOX__PID_ROS_HPP_
34#define CONTROL_TOOLBOX__PID_ROS_HPP_
39#include "control_msgs/msg/pid_state.hpp"
41#include "rclcpp/clock.hpp"
42#include "rclcpp/duration.hpp"
43#include "rclcpp/node.hpp"
45#include "realtime_tools/realtime_buffer.hpp"
46#include "realtime_tools/realtime_publisher.hpp"
48#include "control_toolbox/pid.hpp"
72 std::shared_ptr<NodeT> node_ptr,
73 std::string prefix = std::string(
""),
74 bool prefix_is_for_params =
false
77 node_ptr->get_node_base_interface(),
78 node_ptr->get_node_logging_interface(),
79 node_ptr->get_node_parameters_interface(),
80 node_ptr->get_node_topics_interface(),
81 prefix, prefix_is_for_params)
86 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
87 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
88 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_params,
89 rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr topics_interface,
90 std::string prefix = std::string(
""),
bool prefix_is_for_params =
false);
103 void initPid(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup);
139 double computeCommand(
double error,
double error_dot, rclcpp::Duration dt);
158 void setGains(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup =
false);
203 inline rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr
206 return parameter_callback_;
210 std::string topic_prefix_;
211 std::string param_prefix_;
214 void setParameterEventCallback();
216 void publishPIDState(
double cmd,
double error, rclcpp::Duration dt);
218 void declareParam(
const std::string & param_name, rclcpp::ParameterValue param_value);
220 bool getDoubleParam(
const std::string & param_name,
double & value);
222 bool getBooleanParam(
const std::string & param_name,
bool & value);
230 void initialize(std::string topic_prefix);
232 rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr parameter_callback_;
234 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_;
235 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_;
236 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_params_;
237 rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr topics_interface_;
239 std::shared_ptr<realtime_tools::RealtimePublisher<control_msgs::msg::PidState>> rt_state_pub_;
240 std::shared_ptr<rclcpp::Publisher<control_msgs::msg::PidState>> state_pub_;