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>
59 std::shared_ptr<rclcpp::Node> node_;
61 std::string node_prefix_;
64 rclcpp::Publisher<sensor_msgs::msg::JointState>::SharedPtr publisher_joint_states_;
65 rclcpp::Publisher<std_msgs::msg::Float64MultiArray>::SharedPtr publisher_joint_limits_min_;
66 rclcpp::Publisher<std_msgs::msg::Float64MultiArray>::SharedPtr publisher_joint_limits_max_;
67 rclcpp::Publisher<std_msgs::msg::Int32MultiArray>::SharedPtr publisher_home_state_;
69 rclcpp::Subscription<sas_msgs::msg::Bool>::SharedPtr subscriber_shutdown_signal_;
70 bool shutdown_signal_;
71 rclcpp::Subscription<std_msgs::msg::Float64MultiArray>::SharedPtr subscriber_target_joint_positions_;
72 Eigen::VectorXd target_joint_positions_;
73 rclcpp::Subscription<std_msgs::msg::Float64MultiArray>::SharedPtr subscriber_target_joint_velocities_;
74 Eigen::VectorXd target_joint_velocities_;
75 rclcpp::Subscription<std_msgs::msg::Float64MultiArray>::SharedPtr subscriber_target_joint_forces_;
76 Eigen::VectorXd target_joint_forces_;
77 rclcpp::Subscription<std_msgs::msg::Int32MultiArray>::SharedPtr subscriber_homing_signal_;
78 Eigen::VectorXi homing_signal_;
79 rclcpp::Subscription<std_msgs::msg::Int32MultiArray>::SharedPtr subscriber_clear_positions_signal_;
80 Eigen::VectorXi clear_positions_signal_;
81 rclcpp::Subscription<sas_msgs::msg::WatchdogTrigger>::SharedPtr subscriber_watchdog_trigger_;
82 bool watchdog_trigger_status_;
83 bool watchdog_enabled_;
84 double watchdog_period_in_seconds_;
85 double watchdog_maximum_acceptable_delay_in_seconds_;
86 std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> time_point_from_the_client_;
87 std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> time_point_from_the_server_;
89 void _callback_shutdown_signal_(
const sas_msgs::msg::Bool& msg);
90 void _callback_target_joint_positions(
const std_msgs::msg::Float64MultiArray& msg);
91 void _callback_target_joint_velocities(
const std_msgs::msg::Float64MultiArray& msg);
92 void _callback_target_joint_forces(
const std_msgs::msg::Float64MultiArray& msg);
93 void _callback_homing_signal(
const std_msgs::msg::Int32MultiArray& msg);
94 void _callback_clear_positions_signal(
const std_msgs::msg::Int32MultiArray& msg);
95 void _callback_watchdog_trigger_state(
const sas_msgs::msg::WatchdogTrigger& msg);
98 RobotDriverServer() =
delete;
99 RobotDriverServer(
const RobotDriverServer&) =
delete;
107 RobotDriverServer(
const std::shared_ptr<rclcpp::Node>& node,
const std::string& node_prefix =
"GET_FROM_NODE");
178 void send_joint_states(
const Eigen::VectorXd& joint_positions,
const Eigen::VectorXd& joint_velocities,
179 const Eigen::VectorXd& joint_forces);
186 void send_joint_limits(
const std::tuple<Eigen::VectorXd, Eigen::VectorXd>& joint_limits);
201 std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>
210 std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>
Base class for SAS objects.
Definition sas_object.hpp:40
Functionality
Enumeration of optional driver functionalities.
Definition sas_robot_driver.hpp:93
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:241
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:273
bool get_watchdog_trigger_status() const
Get the current watchdog trigger status as last received from the client.
Definition sas_robot_driver_server.cpp:331
Eigen::VectorXi get_clear_positions_signal()
Get the last received clear positions signal vector.
Definition sas_robot_driver_server.cpp:217
double get_watchdog_period() const
Get the configured watchdog period in seconds.
Definition sas_robot_driver_server.cpp:354
Eigen::VectorXd get_target_joint_positions() const
Get the most recent target joint positions received from clients.
Definition sas_robot_driver_server.cpp:172
Eigen::VectorXd get_target_joint_velocities() const
Get the most recent target joint velocities received from clients.
Definition sas_robot_driver_server.cpp:181
bool is_watchdog_enabled() const
Query whether the watchdog is enabled on the server.
Definition sas_robot_driver_server.cpp:345
RobotDriver::Functionality get_currently_active_functionality() const
Get the currently active functionality of the robot driver.
Definition sas_robot_driver_server.cpp:230
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:301
Eigen::VectorXi get_homing_signal() const
Get the last received homing signal vector.
Definition sas_robot_driver_server.cpp:204
void send_home_state(const Eigen::VectorXi &home_state)
Publish the home state vector to clients.
Definition sas_robot_driver_server.cpp:266
double get_watchdog_maximum_acceptable_delay() const
Get the configured maximum acceptable delay for the watchdog in seconds.
Definition sas_robot_driver_server.cpp:365
bool get_shutdown_signal() const
Get the current shutdown signal state as last received from clients.
Definition sas_robot_driver_server.cpp:375
Eigen::VectorXd get_target_joint_forces() const
Get the most recent target joint forces received from clients.
Definition sas_robot_driver_server.cpp:191
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:317
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:255