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

Class for handling bidirectional UDP communication. More...

#include <udp_socket.hpp>

Inheritance diagram for staubli_robot_driver::UDPSocket:
[legend]
Collaboration diagram for staubli_robot_driver::UDPSocket:
[legend]

Public Member Functions

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

Detailed Description

Class for handling bidirectional UDP communication.

Constructor & Destructor Documentation

◆ UDPSocket()

staubli_robot_driver::UDPSocket::UDPSocket ( )

◆ ~UDPSocket()

staubli_robot_driver::UDPSocket::~UDPSocket ( )
override

Member Function Documentation

◆ connect() [1/2]

bool staubli_robot_driver::UDPSocket::connect ( const std::string &  remote_address,
uint16_t  remote_port,
uint16_t  local_port 
)
overridevirtual

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

Implements staubli_robot_driver::Socket.

◆ connect() [2/2]

bool staubli_robot_driver::UDPSocket::connect ( const std::string &  remote_address,
uint16_t  remote_port,
const std::string &  local_address,
uint16_t  local_port 
)
overridevirtual

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

Implements staubli_robot_driver::Socket.

◆ disconnect()

bool staubli_robot_driver::UDPSocket::disconnect ( )
overridevirtual

Disconnect from the remote endpoint.

Returns
True if disconnected successfully, false otherwise

Implements staubli_robot_driver::Socket.

◆ is_connected()

bool staubli_robot_driver::UDPSocket::is_connected ( ) const
overridevirtual

Check if the connection is established.

Returns
True if connected, false otherwise

Implements staubli_robot_driver::Socket.

◆ send()

bool staubli_robot_driver::UDPSocket::send ( std::vector< uint8_t > &  data)
overridevirtual

Send data to the remote endpoint.

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

Implements staubli_robot_driver::Socket.

◆ receive_once()

bool staubli_robot_driver::UDPSocket::receive_once ( int  timeout_ms,
std::vector< uint8_t > &  data 
)
overridevirtual

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...

Implements staubli_robot_driver::Socket.

◆ start_receive_thread()

bool staubli_robot_driver::UDPSocket::start_receive_thread ( std::function< void(std::vector< uint8_t > &, size_t)>  reception_callback)
overridevirtual

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

Implements staubli_robot_driver::Socket.

◆ stop_receive_thread()

bool staubli_robot_driver::UDPSocket::stop_receive_thread ( )
overridevirtual

Stop the receive thread.

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

Implements staubli_robot_driver::Socket.

◆ is_receiving()

bool staubli_robot_driver::UDPSocket::is_receiving ( ) const
overridevirtual

Check if the receive thread is running.

Returns
True if the receive thread is running, false otherwise

Implements staubli_robot_driver::Socket.


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