18#ifndef STAUBLI_ROBOT_DRIVER__ROBOT_DRIVER_HPP_
19#define STAUBLI_ROBOT_DRIVER__ROBOT_DRIVER_HPP_
24#include <condition_variable>
154 return last_valid_sequence_id_;
165 rclcpp::Logger logger_;
169 std::shared_ptr<Socket> control_socket_;
170 std::shared_ptr<Socket> diagnostics_socket_;
179 size_t last_valid_sequence_id_ = 0;
184 rclcpp::Duration state_staleness_timeout_;
185 rclcpp::Duration diagnostic_staleness_timeout_;
Diagnostic data.
Definition messages.hpp:191
Bilateral real-time socket interface for pub/sub communication.
Definition real_time_socket_interface.hpp:39
Robot command message.
Definition messages.hpp:139
Main interface for controlling Staubli robots.
Definition robot_driver.hpp:42
bool is_connected() const
Check if connected to the robot (does not check for message staleness)
bool send_stop_all_command()
Send a STOP command to the robot (halts motion and sets IOs to zero)
bool disconnect()
Disconnect from the robot.
bool connect(const NetworkConfig &config, int timeout_ms=5000)
Connect to the robot with a specific network configuration.
bool send_robot_command(const RobotCommandMessage &command)
Send a command to the robot.
void set_state_staleness_timeout(rclcpp::Duration staleness_timeout=rclcpp::Duration(0, 1e8))
Set the staleness timeout after which the robot state is considered stale.
void set_diagnostic_staleness_timeout(rclcpp::Duration staleness_timeout=rclcpp::Duration(0, 1e8))
Set the staleness timeout after which the diagnostic data is considered stale.
~RobotDriver()
Destructor.
bool is_diagnostic_msg_valid() const
RobotDriver()
Constructor.
bool is_state_msg_valid() const
size_t get_current_message_sequence() const
Get the sequence ID of the last valid received robot state message.
Definition robot_driver.hpp:153
bool connect(const std::string &robot_ip, int timeout_ms)
Connect to the robot with the default network configuration.
bool read_diagnostic_data(DiagnosticDataMessage &data)
Get the latest diagnostic data, see update_robot_state() for notes.
bool read_robot_state(RobotStateMessage &state)
Get the current (latest) robot state.
Robot state message.
Definition messages.hpp:62
Definition messages.hpp:23
constexpr uint16_t DEFAULT_CONTROL_PORT
Default port for the control socket.
Definition protocol.hpp:45
constexpr uint16_t DEFAULT_DIAGNOSTICS_PORT
Default port for the diagnostics socket.
Definition protocol.hpp:50
Configuration structure for the communication.
Definition robot_driver.hpp:45
uint16_t local_diagnostics_port
Port for diagnostics communication on ROS2 side.
Definition robot_driver.hpp:57
uint16_t local_control_port
Port for control communication on ROS2 side.
Definition robot_driver.hpp:53
std::string local_ip
Local IP address to bind to (empty string binds to any interface)
Definition robot_driver.hpp:49
uint16_t diagnostics_port
Port for diagnostics communication on the robot.
Definition robot_driver.hpp:55
std::string robot_ip
IP address of the Staubli robot.
Definition robot_driver.hpp:47
uint16_t control_port
Port for control communication on the robot.
Definition robot_driver.hpp:51