34#include <rclcpp/rclcpp.hpp>
35#include <geometry_msgs/msg/pose_stamped.hpp>
36#include <std_msgs/msg/float64_multi_array.hpp>
37#include <std_msgs/msg/int32_multi_array.hpp>
38#include <sensor_msgs/msg/joint_state.hpp>
40#include <sas_core/sas_robot_driver.hpp>
41#include <sas_core/sas_object.hpp>
42#include <sas_msgs/msg/watchdog_trigger.hpp>
43#include <sas_msgs/msg/bool.hpp>
60 std::shared_ptr<rclcpp::Node> node_;
62 std::string node_prefix_;
63 RobotDriver::Functionality currently_active_functionality_;
65 rclcpp::Publisher<sensor_msgs::msg::JointState>::SharedPtr publisher_joint_states_;
66 rclcpp::Publisher<std_msgs::msg::Float64MultiArray>::SharedPtr publisher_joint_limits_min_;
67 rclcpp::Publisher<std_msgs::msg::Float64MultiArray>::SharedPtr publisher_joint_limits_max_;
68 rclcpp::Publisher<std_msgs::msg::Int32MultiArray>::SharedPtr publisher_home_state_;
71 rclcpp::Subscription<sas_msgs::msg::Bool>::SharedPtr subscriber_shutdown_signal_;
72 bool shutdown_signal_;
73 rclcpp::Subscription<std_msgs::msg::Float64MultiArray>::SharedPtr subscriber_target_joint_positions_;
74 Eigen::VectorXd target_joint_positions_;
75 rclcpp::Subscription<std_msgs::msg::Float64MultiArray>::SharedPtr subscriber_target_joint_velocities_;
76 Eigen::VectorXd target_joint_velocities_;
77 rclcpp::Subscription<std_msgs::msg::Float64MultiArray>::SharedPtr subscriber_target_joint_forces_;
78 Eigen::VectorXd target_joint_forces_;
79 rclcpp::Subscription<std_msgs::msg::Int32MultiArray>::SharedPtr subscriber_homing_signal_;
80 Eigen::VectorXi homing_signal_;
81 rclcpp::Subscription<std_msgs::msg::Int32MultiArray>::SharedPtr subscriber_clear_positions_signal_;
82 Eigen::VectorXi clear_positions_signal_;
83 rclcpp::Subscription<sas_msgs::msg::WatchdogTrigger>::SharedPtr subscriber_watchdog_trigger_;
84 bool watchdog_trigger_status_;
85 bool watchdog_enabled_;
86 double watchdog_period_in_seconds_;
87 double watchdog_maximum_acceptable_delay_in_seconds_;
88 std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> time_point_from_the_client_;
89 std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> time_point_from_the_server_;
91 void _callback_shutdown_signal_(
const sas_msgs::msg::Bool& msg);
92 void _callback_target_joint_positions(
const std_msgs::msg::Float64MultiArray &msg);
93 void _callback_target_joint_velocities(
const std_msgs::msg::Float64MultiArray &msg);
94 void _callback_target_joint_forces(
const std_msgs::msg::Float64MultiArray &msg);
95 void _callback_homing_signal(
const std_msgs::msg::Int32MultiArray& msg);
96 void _callback_clear_positions_signal(
const std_msgs::msg::Int32MultiArray &msg);
97 void _callback_watchdog_trigger_state(
const sas_msgs::msg::WatchdogTrigger& msg);
99 RobotDriverServer() =
delete;
100 RobotDriverServer(
const RobotDriverServer&) =
delete;
108 RobotDriverServer(
const std::shared_ptr<rclcpp::Node> &node,
const std::string& node_prefix=
"GET_FROM_NODE");
169 bool is_enabled(
const RobotDriver::Functionality& supported_functionality=RobotDriver::Functionality::PositionControl)
const;
179 const Eigen::VectorXd& joint_velocities,
180 const Eigen::VectorXd& joint_forces);
187 void send_joint_limits(
const std::tuple<Eigen::VectorXd, Eigen::VectorXd>& joint_limits);
Base class for SAS objects.
Definition sas_object.hpp:40
void send_joint_states(const Eigen::VectorXd &joint_positions, const Eigen::VectorXd &joint_velocities, const Eigen::VectorXd &joint_forces)
Publish joint states (positions, velocities and forces) to clients.
Definition sas_robot_driver_server.cpp:230
bool is_enabled(const RobotDriver::Functionality &supported_functionality=RobotDriver::Functionality::PositionControl) const
Check whether the server supports and is enabled for a functionality.
Definition sas_robot_driver_server.cpp:262
bool get_watchdog_trigger_status() const
Get the current watchdog trigger status as last received from the client.
Definition sas_robot_driver_server.cpp:314
Eigen::VectorXi get_clear_positions_signal()
Get the last received clear positions signal vector.
Definition sas_robot_driver_server.cpp:207
double get_watchdog_period() const
Get the configured watchdog period in seconds.
Definition sas_robot_driver_server.cpp:335
Eigen::VectorXd get_target_joint_positions() const
Get the most recent target joint positions received from clients.
Definition sas_robot_driver_server.cpp:167
Eigen::VectorXd get_target_joint_velocities() const
Get the most recent target joint velocities received from clients.
Definition sas_robot_driver_server.cpp:175
bool is_watchdog_enabled() const
Query whether the watchdog is enabled on the server.
Definition sas_robot_driver_server.cpp:326
RobotDriver::Functionality get_currently_active_functionality() const
Get the currently active functionality of the robot driver.
Definition sas_robot_driver_server.cpp:219
std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > get_watchdog_time_point_from_the_client() const
Get the time point received from the client for watchdog synchronization.
Definition sas_robot_driver_server.cpp:289
Eigen::VectorXi get_homing_signal() const
Get the last received homing signal vector.
Definition sas_robot_driver_server.cpp:195
void send_home_state(const Eigen::VectorXi &home_state)
Publish the home state vector to clients.
Definition sas_robot_driver_server.cpp:254
double get_watchdog_maximum_acceptable_delay() const
Get the configured maximum acceptable delay for the watchdog in seconds.
Definition sas_robot_driver_server.cpp:346
bool get_shutdown_signal() const
Get the current shutdown signal state as last received from clients.
Definition sas_robot_driver_server.cpp:356
Eigen::VectorXd get_target_joint_forces() const
Get the most recent target joint forces received from clients.
Definition sas_robot_driver_server.cpp:183
std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > get_watchdog_time_point_from_the_server() const
Get the time point captured on the server for watchdog synchronization.
Definition sas_robot_driver_server.cpp:302
void send_joint_limits(const std::tuple< Eigen::VectorXd, Eigen::VectorXd > &joint_limits)
Publish joint limits (min and max) to clients.
Definition sas_robot_driver_server.cpp:243