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(
""),
80 template <
class NodeT>
99 template <
class NodeT>
121 template <
class NodeT>
132 [[deprecated(
"Use overloads with explicit prefixes for params and topics")]]
PidROS(
133 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
node_base,
134 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr
node_logging,
135 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr
node_params,
151 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
node_base,
152 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr
node_logging,
153 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr
node_params,
173 [[deprecated(
"Use initialize_from_args with AntiWindupStrategy instead.")]]
175 double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup);
190 [[deprecated(
"Use initialize_from_args() instead")]]
void initPid(
191 double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup);
209 [[deprecated(
"Use initialize_from_args with AntiWindupStrategy instead.")]]
225 [[deprecated(
"Use initialize_from_args() instead")]]
void initPid(
245 double p,
double i,
double d,
double u_max,
double u_min,
259 [[deprecated(
"Use initialize_from_ros_parameters() instead")]]
bool initPid();
297 [[deprecated(
"Use compute_command() instead")]]
double computeCommand(
298 double error, rclcpp::Duration
dt);
324 [[deprecated(
"Use compute_command() instead")]]
double computeCommand(
325 double error,
double error_dot, rclcpp::Duration
dt);
357 [[deprecated(
"Use set_gains with AntiWindupStrategy instead.")]]
377 double p,
double i,
double d,
double u_max,
double u_min,
394 [[deprecated(
"Use set_gains() instead")]]
void setGains(
395 double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup =
false);
425 [[deprecated(
"Use set_current_cmd() instead")]]
void setCurrentCmd(
double cmd);
437 [[deprecated(
"Use get_current_cmd() instead")]]
double getCurrentCmd();
449 [[deprecated(
"Use get_pid_state_publisher() instead")]]
467 double &
pe,
double &
ie,
double &
de);
477 [[deprecated(
"Use print_values() instead")]]
void printValues();
483 inline rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr
486 return parameter_callback_;
493 [[deprecated(
"Use get_parameters_callback_handle() instead")]]
494 inline rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr
501 std::string topic_prefix_;
502 std::string param_prefix_;
507 [[deprecated]]
void setParameterEventCallback();
509 [[deprecated]]
void publishPIDState(
double cmd,
double error, rclcpp::Duration
dt);
511 [[deprecated]]
void declareParam(
514 [[deprecated]]
bool getDoubleParam(
const std::string &
param_name,
double & value);
516 [[deprecated]]
bool getBooleanParam(
const std::string &
param_name,
bool & value);
524 [[deprecated]]
void initialize(std::string
topic_prefix);
527 void set_parameter_event_callback();
529 void publish_pid_state(
double cmd,
double error, rclcpp::Duration
dt);
533 bool get_double_param(
const std::string &
param_name,
double & value);
535 bool get_boolean_param(
const std::string &
param_name,
bool & value);
537 bool get_string_param(
const std::string &
param_name, std::string & value);
546 [[deprecated]]
void set_prefixes(
const std::string &
topic_prefix);
548 rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr parameter_callback_;
550 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_;
551 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_;
552 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_params_;
553 rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr topics_interface_;
555 std::shared_ptr<realtime_tools::RealtimePublisher<control_msgs::msg::PidState>> rt_state_pub_;
556 control_msgs::msg::PidState pid_state_msg_;
557 std::shared_ptr<rclcpp::Publisher<control_msgs::msg::PidState>> state_pub_;