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"
70 template <
class NodeT>
71 [[deprecated(
"Use overloads with explicit prefixes for params and topics")]]
explicit PidROS(
72 std::shared_ptr<NodeT>
node_ptr, std::string
prefix = std::string(
""),
96 template <
class NodeT>
120 template <
class NodeT>
131 [[deprecated(
"Use overloads with explicit prefixes for params and topics")]]
PidROS(
132 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
node_base,
133 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr
node_logging,
134 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr
node_params,
150 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
node_base,
151 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr
node_logging,
152 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr
node_params,
172 [[deprecated(
"Use initialize_from_args with AntiWindupStrategy instead.")]]
174 double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup);
189 [[deprecated(
"Use initialize_from_args() instead")]]
void initPid(
190 double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup);
208 [[deprecated(
"Use initialize_from_args with AntiWindupStrategy instead.")]]
224 [[deprecated(
"Use initialize_from_args() instead")]]
void initPid(
244 double p,
double i,
double d,
double u_max,
double u_min,
258 [[deprecated(
"Use initialize_from_ros_parameters() instead")]]
bool initPid();
296 [[deprecated(
"Use compute_command() instead")]]
double computeCommand(
297 double error, rclcpp::Duration
dt);
323 [[deprecated(
"Use compute_command() instead")]]
double computeCommand(
324 double error,
double error_dot, rclcpp::Duration
dt);
356 [[deprecated(
"Use set_gains with AntiWindupStrategy instead.")]]
376 double p,
double i,
double d,
double u_max,
double u_min,
393 [[deprecated(
"Use set_gains() instead")]]
void setGains(
394 double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup =
false);
424 [[deprecated(
"Use set_current_cmd() instead")]]
void setCurrentCmd(
double cmd);
436 [[deprecated(
"Use get_current_cmd() instead")]]
double getCurrentCmd();
448 [[deprecated(
"Use get_pid_state_publisher() instead")]]
466 double &
pe,
double &
ie,
double &
de);
476 [[deprecated(
"Use print_values() instead")]]
void printValues();
482 inline rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr
485 return parameter_callback_;
492 [[deprecated(
"Use get_parameters_callback_handle() instead")]]
493 inline rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr
500 std::string topic_prefix_;
501 std::string param_prefix_;
506 [[deprecated]]
void setParameterEventCallback();
508 [[deprecated]]
void publishPIDState(
double cmd,
double error, rclcpp::Duration
dt);
510 [[deprecated]]
void declareParam(
513 [[deprecated]]
bool getDoubleParam(
const std::string &
param_name,
double & value);
515 [[deprecated]]
bool getBooleanParam(
const std::string &
param_name,
bool & value);
523 [[deprecated]]
void initialize(std::string
topic_prefix);
526 void set_parameter_event_callback();
528 void publish_pid_state(
double cmd,
double error, rclcpp::Duration
dt);
532 bool get_double_param(
const std::string &
param_name,
double & value);
534 bool get_boolean_param(
const std::string &
param_name,
bool & value);
536 bool get_string_param(
const std::string &
param_name, std::string & value);
545 [[deprecated]]
void set_prefixes(
const std::string &
topic_prefix);
547 rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr parameter_callback_;
549 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_;
550 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_;
551 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_params_;
552 rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr topics_interface_;
554 std::shared_ptr<realtime_tools::RealtimePublisher<control_msgs::msg::PidState>> rt_state_pub_;
555 control_msgs::msg::PidState pid_state_msg_;
556 std::shared_ptr<rclcpp::Publisher<control_msgs::msg::PidState>> state_pub_;