staubli_driver_ros2 main
ROS2 control driver for Staubli robots
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | List of all members
staubli_robot_driver::RobotDriver Class Reference

Main interface for controlling Staubli robots. More...

#include <robot_driver.hpp>

Classes

struct  NetworkConfig
 Configuration structure for the communication. More...
 

Public Member Functions

 RobotDriver ()
 Constructor.
 
 ~RobotDriver ()
 Destructor.
 
bool connect (const std::string &robot_ip, int timeout_ms)
 Connect to the robot with the default network configuration.
 
bool connect (const NetworkConfig &config, int timeout_ms=5000)
 Connect to the robot with a specific network configuration.
 
bool disconnect ()
 Disconnect from the robot.
 
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 send_robot_command (const RobotCommandMessage &command)
 Send a command to the robot.
 
bool read_robot_state (RobotStateMessage &state)
 Get the current (latest) robot state.
 
bool read_diagnostic_data (DiagnosticDataMessage &data)
 Get the latest diagnostic data, see update_robot_state() for notes.
 
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.
 
size_t get_current_message_sequence () const
 Get the sequence ID of the last valid received robot state message.
 

Protected Member Functions

void reset_data ()
 
bool is_state_msg_valid () const
 
bool is_diagnostic_msg_valid () const
 

Detailed Description

Main interface for controlling Staubli robots.

This class provides methods to connect to a Staubli robot, send commands, and receive state and diagnostic information.

Constructor & Destructor Documentation

◆ RobotDriver()

staubli_robot_driver::RobotDriver::RobotDriver ( )

Constructor.

◆ ~RobotDriver()

staubli_robot_driver::RobotDriver::~RobotDriver ( )

Destructor.

Member Function Documentation

◆ connect() [1/2]

bool staubli_robot_driver::RobotDriver::connect ( const std::string &  robot_ip,
int  timeout_ms 
)

Connect to the robot with the default network configuration.

Parameters
robot_ipIP address of the robot
timeout_msConnection timeout in milliseconds
Returns
True if connected successfully, false otherwise

◆ connect() [2/2]

bool staubli_robot_driver::RobotDriver::connect ( const NetworkConfig config,
int  timeout_ms = 5000 
)

Connect to the robot with a specific network configuration.

Parameters
configNetwork configuration
timeout_msConnection timeout in milliseconds
Returns
True if connected successfully, false otherwise

◆ disconnect()

bool staubli_robot_driver::RobotDriver::disconnect ( )

Disconnect from the robot.

Returns
True if disconnected successfully, false otherwise

◆ is_connected()

bool staubli_robot_driver::RobotDriver::is_connected ( ) const

Check if connected to the robot (does not check for message staleness)

Returns
True if connected, false otherwise

◆ send_stop_all_command()

bool staubli_robot_driver::RobotDriver::send_stop_all_command ( )

Send a STOP command to the robot (halts motion and sets IOs to zero)

Returns
True if command was sent successfully, false otherwise

◆ send_robot_command()

bool staubli_robot_driver::RobotDriver::send_robot_command ( const RobotCommandMessage command)

Send a command to the robot.

Parameters
commandCommand to send
Returns
True if command was valid and sent successfully, false otherwise

◆ read_robot_state()

bool staubli_robot_driver::RobotDriver::read_robot_state ( RobotStateMessage state)

Get the current (latest) robot state.

Note
This should be called at a regular interval (e.g. in a control loop). The method will update the internal state while checking for staleness. If the state is stale, this method will return false. In that case, the user should take appropriate action (e.g. stop the robot) based on previous readings only.
Parameters
[out]stateRobot state
Returns
True if state was successfully retrieved, false otherwise

◆ read_diagnostic_data()

bool staubli_robot_driver::RobotDriver::read_diagnostic_data ( DiagnosticDataMessage data)

Get the latest diagnostic data, see update_robot_state() for notes.

Parameters
[out]dataDiagnostic data
Returns
True if data was successfully retrieved, false otherwise

◆ set_state_staleness_timeout()

void staubli_robot_driver::RobotDriver::set_state_staleness_timeout ( rclcpp::Duration  staleness_timeout = rclcpp::Duration(0, 1e8))

Set the staleness timeout after which the robot state is considered stale.

Parameters
staleness_timeoutTimeout for staleness check; default is 100 ms.
Returns
True if timeout was set successfully, false otherwise

◆ set_diagnostic_staleness_timeout()

void staubli_robot_driver::RobotDriver::set_diagnostic_staleness_timeout ( rclcpp::Duration  staleness_timeout = rclcpp::Duration(0, 1e8))

Set the staleness timeout after which the diagnostic data is considered stale.

Parameters
staleness_timeoutTimeout for staleness check; default is 100 ms.
Returns
True if timeout was set successfully, false otherwise

◆ get_current_message_sequence()

size_t staubli_robot_driver::RobotDriver::get_current_message_sequence ( ) const
inline

Get the sequence ID of the last valid received robot state message.

Returns
Sequence ID of the last valid robot state message

◆ reset_data()

void staubli_robot_driver::RobotDriver::reset_data ( )
protected

◆ is_state_msg_valid()

bool staubli_robot_driver::RobotDriver::is_state_msg_valid ( ) const
protected

◆ is_diagnostic_msg_valid()

bool staubli_robot_driver::RobotDriver::is_diagnostic_msg_valid ( ) const
protected

The documentation for this class was generated from the following file: