NDEVR
API Documentation
RealSenseServer

Server that streams RealSense point cloud data to remote clients over UDP. More...

Collaboration diagram for RealSenseServer:
[legend]

Classes

class  WorkerThread
 Background thread for the server update loop. More...

Public Member Functions

 RealSenseServer (RealSenseScannerFactory *scanner_factory)
 Constructs the server with the given scanner factory.
void checkRecieve ()
 Checks for and processes incoming commands from the client.
void initConnections ()
 Initializes the UDP listening connection for incoming commands.
void sendCommandData (const String &data)
 Sends a command response to the connected client.
void sendPointData (const RasterPacketInfo &packet_info)
 Sends point cloud data to the connected client.
void startServer ()
 Starts the server, discovers local scanners, and begins streaming.
void stopServer ()
 Stops the server and disconnects all scanners.
bool updateServer ()
 Runs one update cycle: collects data from scanners and sends to client.

Static Public Member Functions

static void CreateCloudPacket (String &packet, const RasterPacketInfo &packet_info, uint04 data_offset, uint02 data_size, uint04 packet_num)
 Creates a compressed point cloud data packet.
static void CreateCommandPacket (String &packet, const String &command, uint04 packet_num)
 Creates a command packet from a command string.
static void CreateProbeInfoPacket (String &packet, const RasterPacketInfo &packet_info, uint04 packet_num)
 Creates a probe info packet with scanner metadata.
static uint04 ReadNetworkPacket (const String &packet, RasterPacketInfo &packet_info, uint04 offset, String &command_response)
 Reads and parses a network packet from a raw data buffer.

Public Attributes

Buffer< RealSenseScanner * > m_connected_scanners
 List of connected local scanners.
RasterPacketInfo m_packet_info
 Current raster packet info being transmitted.
Connectionm_rx_connection = nullptr
 UDP connection for receiving commands.
RealSenseScannerFactorym_scanner_factory = nullptr
 Factory for discovering local scanners.
WorkerThreadm_thread
 Background server thread.
Connectionm_tx_connection = nullptr
 UDP connection for transmitting data.
String m_tx_packet
 Reusable transmit packet buffer.
uint04 m_tx_packet_count = 0
 Transmit packet sequence counter.

Static Public Attributes

static constexpr uint04 rx_port_number = 31458
 UDP port for receiving commands.
static constexpr uint04 tx_port_number = 31459
 UDP port for transmitting data.

Detailed Description

Server that streams RealSense point cloud data to remote clients over UDP.

Manages local scanner connections, serializes point cloud and metadata into packets, and transmits them to connected clients.

Definition at line 76 of file RealSenseServer.h.

Constructor & Destructor Documentation

◆ RealSenseServer()

RealSenseServer::RealSenseServer ( RealSenseScannerFactory * scanner_factory)
inline

Constructs the server with the given scanner factory.

Parameters
[in]scanner_factoryThe factory for discovering local scanners.

Definition at line 300 of file RealSenseServer.h.

References m_scanner_factory, and m_thread.

Referenced by RealSenseServer::WorkerThread::WorkerThread().

Member Function Documentation

◆ CreateCloudPacket()

void RealSenseServer::CreateCloudPacket ( String & packet,
const RasterPacketInfo & packet_info,
uint04 data_offset,
uint02 data_size,
uint04 packet_num )
inlinestatic

Creates a compressed point cloud data packet.

Parameters
[in]packetThe output buffer to write the packet into.
[in]packet_infoThe packet info containing point and color data.
[in]data_offsetThe starting offset in the point data buffer.
[in]data_sizeThe number of points to include.
[in]packet_numThe packet sequence number.

Definition at line 128 of file RealSenseServer.h.

References RasterPacketInfo::active_color_data, RasterPacketInfo::active_point_data, cast(), DataPacketHeader::compressed_color_data_size, DataPacketHeader::compressed_point_data_size, DataPacketHeader::data_size, e_cloud_data, RealsensePacketHeader::packet_num, RealsensePacketHeader::packet_type, and Compressor::ZLibCompress().

Referenced by sendPointData().

◆ CreateCommandPacket()

void RealSenseServer::CreateCommandPacket ( String & packet,
const String & command,
uint04 packet_num )
inlinestatic

Creates a command packet from a command string.

Parameters
[in]packetThe output buffer to write the packet into.
[in]commandThe command string.
[in]packet_numThe packet sequence number.

Definition at line 86 of file RealSenseServer.h.

References cast(), e_probe_info_packet, CommandPacket::packet_info, RealsensePacketHeader::packet_num, and RealsensePacketHeader::packet_type.

Referenced by sendCommandData().

◆ CreateProbeInfoPacket()

void RealSenseServer::CreateProbeInfoPacket ( String & packet,
const RasterPacketInfo & packet_info,
uint04 packet_num )
inlinestatic

Creates a probe info packet with scanner metadata.

Parameters
[in]packetThe output buffer to write the packet into.
[in]packet_infoThe scanner metadata to encode.
[in]packet_numThe packet sequence number.

Definition at line 105 of file RealSenseServer.h.

References cast(), e_probe_info_packet, InfoPacketHeader::frame_time, RasterPacketInfo::frame_time, InfoPacketHeader::gyro_status, RasterPacketInfo::gyro_status, RasterPacketInfo::mat, InfoPacketHeader::matrix, RealsensePacketHeader::packet_num, RealsensePacketHeader::packet_type, InfoPacketHeader::scanner_id, and RasterPacketInfo::scanner_id.

Referenced by sendPointData().

◆ ReadNetworkPacket()

uint04 RealSenseServer::ReadNetworkPacket ( const String & packet,
RasterPacketInfo & packet_info,
uint04 offset,
String & command_response )
inlinestatic

◆ sendCommandData()

void RealSenseServer::sendCommandData ( const String & data)
inline

Sends a command response to the connected client.

Parameters
[in]dataThe command string to send.

Definition at line 326 of file RealSenseServer.h.

References CreateCommandPacket(), m_tx_connection, m_tx_packet, and m_tx_packet_count.

Referenced by checkRecieve().

◆ sendPointData()

void RealSenseServer::sendPointData ( const RasterPacketInfo & packet_info)
inline

Sends point cloud data to the connected client.

Parameters
[in]packet_infoThe raster packet info containing point and color data.

Definition at line 308 of file RealSenseServer.h.

References RasterPacketInfo::active_color_data, cast(), CreateCloudPacket(), CreateProbeInfoPacket(), getMin(), m_tx_connection, m_tx_packet, and m_tx_packet_count.

Referenced by updateServer().

◆ updateServer()

bool RealSenseServer::updateServer ( )
inline

Runs one update cycle: collects data from scanners and sends to client.

Returns
True if any data was sent.

Definition at line 392 of file RealSenseServer.h.

References checkRecieve(), initConnections(), QTTools::log(), m_connected_scanners, m_packet_info, m_rx_connection, m_tx_connection, and sendPointData().


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