The format of a MaxREAL streaming data packet is:
Byte 0
|
Data Type encoded as an ASCII character. The Data Type is the same as the number of single or double floating point numbers in the Data section of the packet for each point/rigid body encoded as an ASCII Hex number.
Invalid Points or Rigid Bodies are represented with all elements set to 0.
Currently the following Data Types are available:
'3'
|
The data is 3D points and contains X/Y/Z coordinates for each point up to number of points. The format of the coordinates depends on the version number.
|
'6'
|
The data contains 6DOF (6 Degree Of Freedom) data where each point contains the 3D coordinate of the origin of the rigid body followed by 3 rotation angles. First is rotation about X-axis, second is about Y-axis and third angle is about Z-axis. The rotation angles are in respect to the global coordinate system.
|
'7'
|
Data type Quaternions. The data is the 3D coordinate of the origin of the rigid body followed by 4 floating points or doubles depending on the data version. The order of the 4 quaternions is X, Y, Z with W being the 4th. The rotation angles are in respect to the global coordinate system.
|
'C'
|
The data contains 6DOF (6 Degree Of Freedom) data where each point contains the 3D coordinate of the origin of the rigid body followed by the 3x3 rotation matrix of the rigid body in respect to the global coordinate system.
|
|
Byte 1
|
Version of data format. This indicates the format of the data. The following version numbers are currently available:
'1'
|
All data is represented in single precision IEEE floating point
|
'2'
|
All data is represented in double precision IEEE floating point
|
|
Byte 2..5
|
Frame number as a 32 bit unsigned integer. Once the frame number have reached 0xFFFFFFFF it will wrap around to 0x00000000.
|
Byte 6..7
|
Number of Points (Data Type '3') or Rigid Bodies (Data Type '6', '7' and 'C') in packet.
|
Byte 8...n
|
Data. Format depends on Type and Version
|
Example of a struct in C
Data package used with data version '1', single precision floating points
struct STREAM_DATA_S
{
char cType;
char cVersion;
unsigned int dwFrameNo;
short int nPoints;
float fData[MAX_DATA]
}
Data package used with data version '2', double precision floating points
struct STREAM_DATA_S
{
char cType;
char cVersion;
unsigned int dwFrameNo;
short int nPoints;
double dData[MAX_DATA]
}
|