Skip to content

Latest commit

 

History

History
376 lines (338 loc) · 7.28 KB

PROTOCOL.md

File metadata and controls

376 lines (338 loc) · 7.28 KB

Romi Control Protocol

The Romi uses a websocket to communicate all of these packets. The address of the websocket is ws://{ROMI_ADDRESS}/test where ROMI_ADDRESS depends on the connection method. It is 192.168.4.1 when running in AP mode.

Data Types

All data sent or received should be Little Endian.

Name Size (bytes)
Unsigned Int 4
Float 4
String >4
Bytes 0+

Strings

Strings are encoded as an int representing the length followed by the character data.

Server(Romi)bound

Joystick Update

Updates the position of the "virtual joystick" in the Romi. The position determines movement of the Romi.

The web client implementation is to dispatch this packet a maximum of 1000 times per second. The packet is not sent if the position has not changed.

Note: The X and Y positions in the packet are ignored by the Romi. The web client always sets them to 1.0.

Packet ID Field Name Field Type Notes
0x20 Position X Float 0.0 - 1.0
Position Y Float 0.0 - 1.0
Angle Float Polar angle, in radians.
Magnitude Float Polar magnitude, 0.0 - 1.0

Slider Update

Updates the position of a slider with the provided ID.

The web client implementation always sends ID 0. The Romi has 4 slider slots, 0 corresponds to the lifting arm.

Packet ID Field Name Field Type Notes
0x30 Slider Number Unsigned Int The slider to update
Value Float 0.0 - 1.0

Button Update

Updates the button state for the given ID.

The web client implementation does not dispatch this packet. The Romi does nothing when it receives this packet.

Packet ID Field Name Field Type Notes
0x40 Button ID Unsigned Int The button to update
State Unsigned Int 0 is up, 1 is down

Heartbeat

Keeps the websocket alive.

The web client implementation sends a heartbeat every 1 second. The Romi keeps track of the latest uuid sent by the client.

Packet ID Field Name Field Type Notes
0x50 Random "UUID" Unsigned Int A random integer, cannot be zero.

Clientbound

Value Update (Single)

This packet is designed to update a single data value on the client.

Note: This packet is not implemented by the web client, and it is never dispatched by the Romi.

Packet ID Field Name Field Type Notes
0x10 Index Unsigned Int The index to update.
Data Unsigned Int | Float The new data.

PID Values Update

Updates the client display for PID values. These are separate from the dynamic values.

The web client implementation is to log the values to the console.

Packet ID Field Name Field Type Notes
0x60 PID Channel Unsigned Int The motor relevant to the PID values.
P Float
I Float
D Float

Heartbeat

Keeps the websocket alive, and proves that the Romi is still active.

Packet ID Field Name Field Type Notes
0x50 Random "UUID" Unsigned Int A random integer, cannot be zero.

Console Data

Used to send an arbitrary log string to the client.

The web client implementation is to console.log the data.

Packet ID Field Name Field Type Notes
0x11 Data String See String encoding above.

Bulk Label Update

Updates or creates a variable number of value indices in the client value dictionary.

Packet ID Field Name Field Type Notes
0x1d Number of labels (n) Unsigned Int
Start of string data Unsigned Int The start position of the Raw String Data, relative to this position, AKA n * 12.
Once for each n Index Unsigned Int The label index to update.
String Offset Unsigned Int The start position of the String, relative to the start of the Raw String Data.
String Length Unsigned Int
Raw String Data Bytes All of the labels concatenated.

Bulk Value Update

Updates a variable number of values in the client value dictionary.

Packet ID Field Name Field Type Notes
0x1e Number of updates (n) Unsigned Int The number (n) of updates to perform.
Once for each n. Index Unsigned Int
Value Unsigned Int The new value for the index.

New Value Index

Creates a new value index in the client value dictionary.

Note: This packet is not implemented by the web client, or dispatched by the Romi.

Packet ID Field Name Field Type Notes
0x1F Index Unsigned Int
Name String See String encoding above.