Cleanup for release

This commit is contained in:
2026-03-28 23:10:58 -04:00
parent 40093c8534
commit 0056e7a9de
14 changed files with 293 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
include "../RobotModule.fbs";
namespace Frontend;
table ModuleConnection {
from_module_id: uint8;
to_module_id: uint8;
from_socket: uint8;
to_socket: uint8;
orientation: Orientation;
}
table RobotConfiguration{
modules: [RobotModule];
connections: [ModuleConnection];
}
root_type RobotConfiguration;

View File

@@ -0,0 +1,7 @@
namespace Messaging;
table AngleControlMessage {
angle: int16;
}
root_type AngleControlMessage;

View File

@@ -0,0 +1,35 @@
namespace Messaging;
enum EntryType : byte {
NONE = 0,
I32,
U32,
I64,
U64,
STRING,
BLOB
}
table I32Value { value: int32; }
table U32Value { value: uint32; }
table I64Value { value: int64; }
table U64Value { value: uint64; }
table StringValue { value: string; }
table BlobValue { value: [ubyte]; }
union NvsValue {
I32Value,
U32Value,
I64Value,
U64Value,
StringValue,
BlobValue
}
table ConfigMessage {
key: string;
type: EntryType;
value: NvsValue;
}
root_type ConfigMessage;

19
Messaging/MPIMessage.fbs Normal file
View File

@@ -0,0 +1,19 @@
namespace Messaging;
enum MessageType : byte {
BROADCAST = 0,
PTP = 1,
}
table MPIMessage {
type: MessageType;
sender: uint8;
destination: uint8;
sequence_number: uint16;
is_durable: bool;
length: uint16;
tag: uint8;
payload: [ubyte];
}
root_type MPIMessage;

9
Messaging/OTAPacket.fbs Normal file
View File

@@ -0,0 +1,9 @@
namespace Messaging;
table OTAPacket {
sequence_number: uint16;
length: uint16;
payload: [ubyte];
}
root_type OTAPacket;

View File

@@ -0,0 +1,9 @@
namespace Messaging;
table ReturnCall {
unique_id: uint8;
length: uint16;
return_value: [ubyte];
}
root_type ReturnCall;

View File

@@ -0,0 +1,10 @@
namespace Messaging;
table SendCall {
tag: uint8;
unique_id: uint8;
length: uint16;
parameters: [ubyte];
}
root_type SendCall;

View File

@@ -0,0 +1,42 @@
namespace Messaging;
table TargetAngle {
value: int16;
}
table CurrentText {
value: string;
}
table CurrentAngle {
value: int16;
}
table Distance {
value: float;
}
table Temperature {
value: float;
}
table Position {
heading: float;
pitch: float;
roll: float;
}
union SensorValue {
TargetAngle,
CurrentAngle,
CurrentText,
Distance,
Temperature,
Position
}
table SensorMessage {
values: [SensorValue];
}
root_type SensorMessage;

View File

@@ -0,0 +1,7 @@
namespace Messaging;
table TextControlMessage {
message: string;
}
root_type TextControlMessage;

View File

@@ -0,0 +1,21 @@
include "../RobotModule.fbs";
namespace Messaging;
enum ConnectionType : byte {
DIRECT = 0,
HOP = 1,
}
table TopologyMessage{
module_id: uint8;
module_type: ModuleType;
num_channels: uint8;
channel_to_module: [uint8]; // index is channel, value is connected board; 0 represents no connection
channel_to_orientation: [Orientation]; // index is channel, value is orientation
connection: ConnectionType;
leader: uint8;
firmware: string;
}
root_type TopologyMessage;

26
README.md Normal file
View File

@@ -0,0 +1,26 @@
# Flatbuffers
We use [Google's Flatbuffers](https://flatbuffers.dev) for serialization. The main benefit of Flatbuffers over other serialization libraries is that Flatbuffers is small and fast (it does not require an unpacking step).
This repository contains all the Flatbuffer definition files (`.fbs`). It should only contain definition files.
Unless there is a good reason to add fields to the middle of a schema, please only add new fields to the end of schema files (to help maintain backward compatibility).
## Compiling
The schema definitions need to be compiled into code files for the languages we use.
The documentation for Flatbuffer's `flatc` tool can be found [here](https://flatbuffers.dev/flatc).
The generated files should then be copied into the respective repositories. Flatbuffers offers backward and forward compatibility.
### Installation
#### MacOS
Install `flatc` with homebrew
```
brew install flatbuffers
```
### Generating
```
flatc --cpp <filename>
```

42
RobotModule.fbs Normal file
View File

@@ -0,0 +1,42 @@
enum ModuleType: byte {
SPLITTER = 0,
SERVO_1 = 1,
DC_MOTOR = 2,
BATTERY = 3,
SERVO_2 = 4,
DISPLAY = 5,
GRIPPER = 6,
SPEAKER = 7,
IMU = 8,
DISTANCE_SENSOR = 9,
SPLITTER_2 = 10,
SPLITTER_3 = 11,
SPLITTER_4 = 12,
SPLITTER_5 = 13,
SPLITTER_6 = 14,
SPLITTER_7 = 15,
SPLITTER_8 = 16
}
enum Orientation : byte {
Deg0 = 0,
Deg90 = 1,
Deg180 = 2,
Deg270 = 3,
}
table MotorState {
angle: int;
}
union ModuleState {
MotorState
}
table RobotModule {
id: uint8;
module_type: ModuleType;
configuration: ModuleState;
}
root_type RobotModule;

29
movement.fbs Normal file
View File

@@ -0,0 +1,29 @@
namespace Movement;
struct ConditionBlob {
value: ushort;
cond: ubyte;
module_type: ubyte;
in_use: ubyte;
}
table MovementEntry {
board_id: ushort;
module_type: ubyte;
value_action: ushort;
condition: ConditionBlob;
ack: ubyte;
ack_ttl_ms: ushort;
post_delay_ms: ushort;
}
table MovementVector {
key: ubyte (key); // map key
movements: [MovementEntry]; // vector value
}
table MovementSet {
movement_map: [MovementVector];
}
root_type MovementSet;

19
topology.fbs Normal file
View File

@@ -0,0 +1,19 @@
namespace Topology;
struct ChannelBoardConn {
channel: ubyte;
board_id: ushort;
}
table NeighbourBlob {
curr_board_id: ushort;
num_connections: ubyte;
neighbour_connections: [ChannelBoardConn];
}
table TopologyInfo {
num_boards: ushort;
boards: [NeighbourBlob];
}
root_type TopologyInfo;