mirror of
https://github.com/BotChain-Robots/flatbuffers.git
synced 2026-07-08 09:37:21 +02:00
Cleanup for release
This commit is contained in:
18
Frontend/RobotConfiguration.fbs
Normal file
18
Frontend/RobotConfiguration.fbs
Normal 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;
|
||||
7
Messaging/AngleControlMessage.fbs
Normal file
7
Messaging/AngleControlMessage.fbs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Messaging;
|
||||
|
||||
table AngleControlMessage {
|
||||
angle: int16;
|
||||
}
|
||||
|
||||
root_type AngleControlMessage;
|
||||
35
Messaging/ConfigMessage.fbs
Normal file
35
Messaging/ConfigMessage.fbs
Normal 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
19
Messaging/MPIMessage.fbs
Normal 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
9
Messaging/OTAPacket.fbs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Messaging;
|
||||
|
||||
table OTAPacket {
|
||||
sequence_number: uint16;
|
||||
length: uint16;
|
||||
payload: [ubyte];
|
||||
}
|
||||
|
||||
root_type OTAPacket;
|
||||
9
Messaging/RPCCall/ReturnCall.fbs
Normal file
9
Messaging/RPCCall/ReturnCall.fbs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Messaging;
|
||||
|
||||
table ReturnCall {
|
||||
unique_id: uint8;
|
||||
length: uint16;
|
||||
return_value: [ubyte];
|
||||
}
|
||||
|
||||
root_type ReturnCall;
|
||||
10
Messaging/RPCCall/SendCall.fbs
Normal file
10
Messaging/RPCCall/SendCall.fbs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Messaging;
|
||||
|
||||
table SendCall {
|
||||
tag: uint8;
|
||||
unique_id: uint8;
|
||||
length: uint16;
|
||||
parameters: [ubyte];
|
||||
}
|
||||
|
||||
root_type SendCall;
|
||||
42
Messaging/SensorMessage.fbs
Normal file
42
Messaging/SensorMessage.fbs
Normal 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;
|
||||
7
Messaging/TextControlMessage.fbs
Normal file
7
Messaging/TextControlMessage.fbs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Messaging;
|
||||
|
||||
table TextControlMessage {
|
||||
message: string;
|
||||
}
|
||||
|
||||
root_type TextControlMessage;
|
||||
21
Messaging/TopologyMessage.fbs
Normal file
21
Messaging/TopologyMessage.fbs
Normal 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
26
README.md
Normal 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
42
RobotModule.fbs
Normal 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
29
movement.fbs
Normal 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
19
topology.fbs
Normal 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;
|
||||
Reference in New Issue
Block a user