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

Abstract interface for communication with the robot. More...

#include <socket.hpp>

Inheritance diagram for staubli_robot_driver::Socket:
[legend]

Public Member Functions

 Socket ()=default
 Default constructor.
 
virtual ~Socket ()=default
 Virtual destructor.
 
virtual bool connect (const std::string &remote_address, uint16_t remote_port, uint16_t local_port)=0
 Connect to the remote endpoint.
 
virtual bool connect (const std::string &remote_address, uint16_t remote_port, const std::string &local_address, uint16_t local_port)=0
 Connect to the remote endpoint with specific local address.
 
virtual bool disconnect ()=0
 Disconnect from the remote endpoint.
 
virtual bool is_connected () const =0
 Check if the connection is established.
 
virtual bool send (std::vector< uint8_t > &data)=0
 Send data to the remote endpoint.
 
virtual bool receive_once (int timeout_ms, std::vector< uint8_t > &data)=0
 Receive data from socket (blocking with timeout)
 
virtual bool start_receive_thread (std::function< void(std::vector< uint8_t > &, size_t)> reception_callback)=0
 Start a receive thread that calls the provided reception_callback when data is received.
 
virtual bool stop_receive_thread ()=0
 Stop the receive thread.
 
virtual bool is_receiving () const =0
 Check if the receive thread is running.
 

Detailed Description

Abstract interface for communication with the robot.

This interface defines the methods required for any communication protocol implementation (UDP / TCP)

Constructor & Destructor Documentation

◆ Socket()

staubli_robot_driver::Socket::Socket ( )
default

Default constructor.

◆ ~Socket()

virtual staubli_robot_driver::Socket::~Socket ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ connect() [1/2]

virtual bool staubli_robot_driver::Socket::connect ( const std::string &  remote_address,
uint16_t  remote_port,
uint16_t  local_port 
)
pure virtual

Connect to the remote endpoint.

Parameters
remote_addressAddress of the remote endpoint (format depends on protocol)
remote_portPort or identifier for the remote endpoint
local_portPort or identifier for the local endpoint
Returns
True if connected successfully, false otherwise

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.

◆ connect() [2/2]

virtual bool staubli_robot_driver::Socket::connect ( const std::string &  remote_address,
uint16_t  remote_port,
const std::string &  local_address,
uint16_t  local_port 
)
pure virtual

Connect to the remote endpoint with specific local address.

Parameters
remote_addressAddress of the remote endpoint (format depends on protocol)
remote_portPort or identifier for the remote endpoint
local_addressLocal IP address to bind to (e.g., "192.168.1.100", "0.0.0.0" for any)
local_portPort or identifier for the local endpoint
Returns
True if connected successfully, false otherwise

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.

◆ disconnect()

virtual bool staubli_robot_driver::Socket::disconnect ( )
pure virtual

Disconnect from the remote endpoint.

Returns
True if disconnected successfully, false otherwise

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.

◆ is_connected()

virtual bool staubli_robot_driver::Socket::is_connected ( ) const
pure virtual

Check if the connection is established.

Returns
True if connected, false otherwise

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.

◆ send()

virtual bool staubli_robot_driver::Socket::send ( std::vector< uint8_t > &  data)
pure virtual

Send data to the remote endpoint.

Parameters
dataData to send
Returns
True if data was sent successfully, false otherwise

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.

◆ receive_once()

virtual bool staubli_robot_driver::Socket::receive_once ( int  timeout_ms,
std::vector< uint8_t > &  data 
)
pure virtual

Receive data from socket (blocking with timeout)

Parameters
timeout_msTimeout in milliseconds
dataWill be filled with received data
Returns
Number of bytes received, 0 on timeout, -1 on error
Warning
The data vector must be preallocated with the max buffer size. The function will resize it to the max buffer size otherwise...

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.

◆ start_receive_thread()

virtual bool staubli_robot_driver::Socket::start_receive_thread ( std::function< void(std::vector< uint8_t > &, size_t)>  reception_callback)
pure virtual

Start a receive thread that calls the provided reception_callback when data is received.

Parameters
reception_callbackFunction to call when data is received
Returns
True if the receive thread was started successfully, false otherwise

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.

◆ stop_receive_thread()

virtual bool staubli_robot_driver::Socket::stop_receive_thread ( )
pure virtual

Stop the receive thread.

Returns
True if the receive thread was stopped successfully, false otherwise

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.

◆ is_receiving()

virtual bool staubli_robot_driver::Socket::is_receiving ( ) const
pure virtual

Check if the receive thread is running.

Returns
True if the receive thread is running, false otherwise

Implemented in staubli_robot_driver::TCPSocket, and staubli_robot_driver::UDPSocket.


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