Projekt

Obecné

Profil

Task #8508 » deltarobot_protocol_v1.md

Oto Šťáva, 2021-04-11 11:51

 

Deltarobot VR communication protocol

This communication protocol serves the purpose of continuous transfer of data about the current state of an exercise from the Deltarobot C++/Qt application to the Unity VR visualizer application. The Qt application is the leader and is responsible for the correct operation of the exercise robot. The Unity application is the follower and connects to the Qt application as a client.

Messages

The protocol is binary. Its data is transferred in the form of messages. Each message begins with a 16-bit identifier, followed by the message's contents.

The identifier is split into two parts - a 4-bit size identifier and a 12-bit unsigned type identifier, in the order from MSB to LSB. The size identifier specifies the length of the message's content. The type identifier specifies the message's meaning.

Unless stated otherwise:

  • All values in the protocol are represented as little endian
  • All floating point values in the protocol are represented in IEEE-754 (single precision for 32-bits, double precision for 64-bits)

Message content length

The first two bits of the message identifier represent a size identifier. The protocol distinguishes between 4 lengths of a message's contents:

  • 0000 (0x0) - 8-bit contents
  • 0001 (0x1) - 16-bit contents
  • 0010 (0x2) - 32-bit contents
  • 0011 (0x3) - 64-bit contents
  • 0100 (0x4) - 128-bit contents
  • 1111 (0xF) - variable-length contents
  • (behaviour undefined if other values are used)

If the size identifier has the value of 0xF, the message identifier is followed by a 32-bit unsigned integer, whose value specifies the number of 8-bit bytes representing the message's contents. This may be used for string values in the protocol.

This system allows for forward compatibility, since every implementation of a client and/or server can always determine the length of a message. This way messages unknown to a particular implementation may simply be skipped without affecting any subsequent messages. Furthermore, implementations may simply choose to ignore any messages they do not have a use for.

Glossary

  • LSB - Least significant bit
  • MSB - Most significant bit
(1-1/2)