2#include "RealSenseInterface/Headers/RealSenseScanner.h"
3#include "RealSenseInterface/Headers/RealSenseScannerFactory.h"
4#include "Design/Headers/DesignObjectLookup.h"
5#include <NDEVR/Connection.h>
6#include <NDEVR/OrientationSensor.h>
7#include "Widgets/Headers/QTTools.h"
8#include "Base/Headers/Translator.h"
9#include "Base/Headers/BasicThread.h"
96 memmove(info.
packet_info, command.begin(), command.size());
141 , compressed_point_data_size, compressed_point_data_size);
143 packet_offset += compressed_point_data_size;
148 , compressed_point_data_size, compressed_point_data_size);
150 packet_offset += compressed_point_data_size;
177 return getMax(packet.size(), 7U) - 7U;
178 offset = index_value;
186 return Constant<uint04>::Invalid;
239 memcpy(packet_info.
active_point_data.begin(point_data_offset), packet.begin(offset), decompressed_size);
254 memcpy(packet_info.
active_color_data.begin(point_data_offset), packet.begin(offset), decompressed_size);
354 scanner->orientationSensor()->requestGyroAlignment(
false);
362 tx_connection_info.
type =
"UDP";
372 scanner->invalidateTime();
380 rx_connection_info.
type =
"UDPLH";
396 bool has_update =
false;
426 for (QPointer<Connection> connection : connections)
428 if (connection ==
nullptr)
431 if (controller->isValid())
433 controller->setIsNetworkServer(
true);
434 QTimer::singleShot(2000, [controller]
436 controller->orientationSensor()->requestGyroAlignment(
false);
The equivelent of std::vector but with a bit more control.
void addSpace(t_index_type space_to_add)
Adds a space to the end of the buffer.
static sint04 ZLibDecompress(const uint01 *compressed, uint01 *uncompressed, size_t compressed_size, size_t &decompressed_size)
A simple, raw call into zlibs uncompress function.
static sint04 ZLibCompress(uint01 *compressed, const uint01 *uncompressed, size_t &compressed_size, size_t decompressed_size)
A simple, raw call into zlibs compress function, except if the compressed size is larger than the unc...
A standard interface for all types of connections that allow transmitting and receiving of data betwe...
void dataAvailableSignal()
Emitted when data is available to be read.
Templated logic for doing matrix multiplication.
Represents a color in the RGB space with optional alpha transparency.
Connection subclass for a locally or remotely connected RealSense device.
Factory for discovering and connecting to RealSense 3D scanners.
3D scanner implementation for Intel RealSense depth cameras.
Background thread for the server update loop.
void run() override
Runs the server update loop.
RealSenseServer * m_server
The owning server.
WorkerThread(RealSenseServer *server)
Constructs the worker thread.
static void CreateProbeInfoPacket(String &packet, const RasterPacketInfo &packet_info, uint04 packet_num)
Creates a probe info packet with scanner metadata.
void stopServer()
Stops the server and disconnects all scanners.
Connection * m_rx_connection
UDP connection for receiving commands.
static constexpr uint04 tx_port_number
UDP port for transmitting data.
String m_tx_packet
Reusable transmit packet buffer.
void startServer()
Starts the server, discovers local scanners, and begins streaming.
static void CreateCommandPacket(String &packet, const String &command, uint04 packet_num)
Creates a command packet from a command string.
Buffer< RealSenseScanner * > m_connected_scanners
List of connected local scanners.
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 checkRecieve()
Checks for and processes incoming commands from the client.
uint04 m_tx_packet_count
Transmit packet sequence counter.
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.
bool updateServer()
Runs one update cycle: collects data from scanners and sends to client.
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.
Connection * m_tx_connection
UDP connection for transmitting data.
RealSenseScannerFactory * m_scanner_factory
Factory for discovering local scanners.
WorkerThread * m_thread
Background server thread.
static constexpr uint04 rx_port_number
UDP port for receiving commands.
RealSenseServer(RealSenseScannerFactory *scanner_factory)
Constructs the server with the given scanner factory.
void initConnections()
Initializes the UDP listening connection for incoming commands.
RasterPacketInfo m_packet_info
Current raster packet info being transmitted.
The root Model that is responsible for storing the underlying data for all Scene Models.
The core String View class for the NDEVR API.
t_type getAs() const
Converts a string into an object.
The core String class for the NDEVR API.
uint04 indexOf(const StringView &sub_string, bool ignore_case=false, uint04 start_index=0) const
Given a substring specified by the input, returns the first index of that string, if it exists.
bool hasSubString(const StringView &sub_string, bool ignore_case=false, uint04 start_idx=0) const
Tests if this String contains the specified substring.
StringViewBuffer split(char delimiter, bool preserve_empty=true) const
Given a delimiter, breaks the string into subsections, returning an array of each subsection.
static void RequestSleep(const TimeSpan &interval)
Puts the current thread to sleep for a specified duration.
Stores a time span, or difference between two times, with an optional start time.
Represents a timestamp with utilities for manipulation and conversion.
static void SetSystemTime(const Time &time)
Sets the application's system clock to a specified Time.
static Time SystemTime()
Retrieves the current system time which is a combination of std::chrono::steady_clock to ensure smoot...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
PacketType
Enumeration of RealSense network packet types.
@ e_probe_info_packet
A scanner info/metadata packet.
@ e_cloud_data
A point cloud data packet.
@ e_command_packet
A text command packet.
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator The only requirement is that t_type have > ...
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
int16_t sint02
-Defines an alias representing a 2 byte, signed integer.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
RealSenseDeviceType
Enumeration of supported RealSense device types.
@ e_unknown
Unknown device type.
@ e_write_only
Open for writing only.
@ e_read_only
Open for reading only.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Packet payload for text commands between client and server.
char packet_info[255]
Null-terminated command string.
A structure designed to store information about a specific Connection.
ConnectionOpenType connect_mode
The mode in which to open the connection.
String type
The connection type (e.g., "serial", "tcp", "bluetooth").
String address
The address or port of the connection.
A series of paths to use for finding potential hardware connections.
Packet of colored point data sent from the raster scanner for live and inactive display.
uint01 packet_num
Sequence number for ordering packets.
sint02 gyro_status
Gyro calibration status (0=uncalibrated, max=calibrated, negative=error).
UUID scanner_id
UUID of the source scanner.
Matrix< fltp08 > mat
Transform matrix for the packet.
Time frame_time
Timestamp of the packet.
Buffer< Vertex< 3, fltp04 > > active_point_data
Live display point positions.
Buffer< RGBColor > active_color_data
Live display point colors.
Checksum union for identifying valid RealSense network packets.
char char_value[8]
The magic number as raw bytes.
uint08 index_value
The magic number value.