mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 09:37:21 +02:00
New flatbuffer code
This commit is contained in:
@@ -0,0 +1,206 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_ROBOTCONFIGURATION_FRONTEND_H_
|
||||
#define FLATBUFFERS_GENERATED_ROBOTCONFIGURATION_FRONTEND_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
// static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
// FLATBUFFERS_VERSION_MINOR == 2 &&
|
||||
// FLATBUFFERS_VERSION_REVISION == 10,
|
||||
// "Non-compatible flatbuffers version included");
|
||||
|
||||
#include "RobotModule_generated.h"
|
||||
|
||||
namespace Frontend {
|
||||
|
||||
struct ModuleConnection;
|
||||
struct ModuleConnectionBuilder;
|
||||
|
||||
struct RobotConfiguration;
|
||||
struct RobotConfigurationBuilder;
|
||||
|
||||
struct ModuleConnection FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef ModuleConnectionBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_FROM_MODULE_ID = 4,
|
||||
VT_TO_MODULE_ID = 6,
|
||||
VT_FROM_SOCKET = 8,
|
||||
VT_TO_SOCKET = 10,
|
||||
VT_ORIENTATION = 12
|
||||
};
|
||||
uint8_t from_module_id() const {
|
||||
return GetField<uint8_t>(VT_FROM_MODULE_ID, 0);
|
||||
}
|
||||
uint8_t to_module_id() const {
|
||||
return GetField<uint8_t>(VT_TO_MODULE_ID, 0);
|
||||
}
|
||||
uint8_t from_socket() const {
|
||||
return GetField<uint8_t>(VT_FROM_SOCKET, 0);
|
||||
}
|
||||
uint8_t to_socket() const {
|
||||
return GetField<uint8_t>(VT_TO_SOCKET, 0);
|
||||
}
|
||||
Orientation orientation() const {
|
||||
return static_cast<Orientation>(GetField<int8_t>(VT_ORIENTATION, 0));
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint8_t>(verifier, VT_FROM_MODULE_ID, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_TO_MODULE_ID, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_FROM_SOCKET, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_TO_SOCKET, 1) &&
|
||||
VerifyField<int8_t>(verifier, VT_ORIENTATION, 1) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct ModuleConnectionBuilder {
|
||||
typedef ModuleConnection Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_from_module_id(uint8_t from_module_id) {
|
||||
fbb_.AddElement<uint8_t>(ModuleConnection::VT_FROM_MODULE_ID, from_module_id, 0);
|
||||
}
|
||||
void add_to_module_id(uint8_t to_module_id) {
|
||||
fbb_.AddElement<uint8_t>(ModuleConnection::VT_TO_MODULE_ID, to_module_id, 0);
|
||||
}
|
||||
void add_from_socket(uint8_t from_socket) {
|
||||
fbb_.AddElement<uint8_t>(ModuleConnection::VT_FROM_SOCKET, from_socket, 0);
|
||||
}
|
||||
void add_to_socket(uint8_t to_socket) {
|
||||
fbb_.AddElement<uint8_t>(ModuleConnection::VT_TO_SOCKET, to_socket, 0);
|
||||
}
|
||||
void add_orientation(Orientation orientation) {
|
||||
fbb_.AddElement<int8_t>(ModuleConnection::VT_ORIENTATION, static_cast<int8_t>(orientation), 0);
|
||||
}
|
||||
explicit ModuleConnectionBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<ModuleConnection> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<ModuleConnection>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<ModuleConnection> CreateModuleConnection(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
uint8_t from_module_id = 0,
|
||||
uint8_t to_module_id = 0,
|
||||
uint8_t from_socket = 0,
|
||||
uint8_t to_socket = 0,
|
||||
Orientation orientation = Orientation_Deg0) {
|
||||
ModuleConnectionBuilder builder_(_fbb);
|
||||
builder_.add_orientation(orientation);
|
||||
builder_.add_to_socket(to_socket);
|
||||
builder_.add_from_socket(from_socket);
|
||||
builder_.add_to_module_id(to_module_id);
|
||||
builder_.add_from_module_id(from_module_id);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct RobotConfiguration FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef RobotConfigurationBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_MODULES = 4,
|
||||
VT_CONNECTIONS = 6
|
||||
};
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>> *modules() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>> *>(VT_MODULES);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Frontend::ModuleConnection>> *connections() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Frontend::ModuleConnection>> *>(VT_CONNECTIONS);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_MODULES) &&
|
||||
verifier.VerifyVector(modules()) &&
|
||||
verifier.VerifyVectorOfTables(modules()) &&
|
||||
VerifyOffset(verifier, VT_CONNECTIONS) &&
|
||||
verifier.VerifyVector(connections()) &&
|
||||
verifier.VerifyVectorOfTables(connections()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct RobotConfigurationBuilder {
|
||||
typedef RobotConfiguration Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_modules(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>>> modules) {
|
||||
fbb_.AddOffset(RobotConfiguration::VT_MODULES, modules);
|
||||
}
|
||||
void add_connections(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Frontend::ModuleConnection>>> connections) {
|
||||
fbb_.AddOffset(RobotConfiguration::VT_CONNECTIONS, connections);
|
||||
}
|
||||
explicit RobotConfigurationBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<RobotConfiguration> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<RobotConfiguration>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<RobotConfiguration> CreateRobotConfiguration(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>>> modules = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Frontend::ModuleConnection>>> connections = 0) {
|
||||
RobotConfigurationBuilder builder_(_fbb);
|
||||
builder_.add_connections(connections);
|
||||
builder_.add_modules(modules);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RobotConfiguration> CreateRobotConfigurationDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const std::vector<::flatbuffers::Offset<RobotModule>> *modules = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<Frontend::ModuleConnection>> *connections = nullptr) {
|
||||
auto modules__ = modules ? _fbb.CreateVector<::flatbuffers::Offset<RobotModule>>(*modules) : 0;
|
||||
auto connections__ = connections ? _fbb.CreateVector<::flatbuffers::Offset<Frontend::ModuleConnection>>(*connections) : 0;
|
||||
return Frontend::CreateRobotConfiguration(
|
||||
_fbb,
|
||||
modules__,
|
||||
connections__);
|
||||
}
|
||||
|
||||
inline const Frontend::RobotConfiguration *GetRobotConfiguration(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Frontend::RobotConfiguration>(buf);
|
||||
}
|
||||
|
||||
inline const Frontend::RobotConfiguration *GetSizePrefixedRobotConfiguration(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Frontend::RobotConfiguration>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyRobotConfigurationBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<Frontend::RobotConfiguration>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedRobotConfigurationBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<Frontend::RobotConfiguration>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishRobotConfigurationBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Frontend::RobotConfiguration> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedRobotConfigurationBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Frontend::RobotConfiguration> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
} // namespace Frontend
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_ROBOTCONFIGURATION_FRONTEND_H_
|
||||
@@ -24,36 +24,33 @@ enum ModuleType : int8_t {
|
||||
ModuleType_SERVO_1 = 1,
|
||||
ModuleType_DC_MOTOR = 2,
|
||||
ModuleType_BATTERY = 3,
|
||||
ModuleType_SERVO_2 = 4,
|
||||
ModuleType_MIN = ModuleType_SPLITTER,
|
||||
ModuleType_MAX = ModuleType_SERVO_2
|
||||
ModuleType_MAX = ModuleType_BATTERY
|
||||
};
|
||||
|
||||
inline const ModuleType (&EnumValuesModuleType())[5] {
|
||||
inline const ModuleType (&EnumValuesModuleType())[4] {
|
||||
static const ModuleType values[] = {
|
||||
ModuleType_SPLITTER,
|
||||
ModuleType_SERVO_1,
|
||||
ModuleType_DC_MOTOR,
|
||||
ModuleType_BATTERY,
|
||||
ModuleType_SERVO_2
|
||||
ModuleType_BATTERY
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesModuleType() {
|
||||
static const char * const names[6] = {
|
||||
static const char * const names[5] = {
|
||||
"SPLITTER",
|
||||
"SERVO_1",
|
||||
"DC_MOTOR",
|
||||
"BATTERY",
|
||||
"SERVO_2",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameModuleType(ModuleType e) {
|
||||
if (::flatbuffers::IsOutRange(e, ModuleType_SPLITTER, ModuleType_SERVO_2)) return "";
|
||||
if (::flatbuffers::IsOutRange(e, ModuleType_SPLITTER, ModuleType_BATTERY)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesModuleType()[index];
|
||||
}
|
||||
|
||||
@@ -20,6 +20,36 @@ namespace Messaging {
|
||||
struct TopologyMessage;
|
||||
struct TopologyMessageBuilder;
|
||||
|
||||
enum ConnectionType : int8_t {
|
||||
ConnectionType_DIRECT = 0,
|
||||
ConnectionType_HOP = 1,
|
||||
ConnectionType_MIN = ConnectionType_DIRECT,
|
||||
ConnectionType_MAX = ConnectionType_HOP
|
||||
};
|
||||
|
||||
inline const ConnectionType (&EnumValuesConnectionType())[2] {
|
||||
static const ConnectionType values[] = {
|
||||
ConnectionType_DIRECT,
|
||||
ConnectionType_HOP
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesConnectionType() {
|
||||
static const char * const names[3] = {
|
||||
"DIRECT",
|
||||
"HOP",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameConnectionType(ConnectionType e) {
|
||||
if (::flatbuffers::IsOutRange(e, ConnectionType_DIRECT, ConnectionType_HOP)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesConnectionType()[index];
|
||||
}
|
||||
|
||||
struct TopologyMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TopologyMessageBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
@@ -27,7 +57,10 @@ struct TopologyMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VT_MODULE_TYPE = 6,
|
||||
VT_NUM_CHANNELS = 8,
|
||||
VT_CHANNEL_TO_MODULE = 10,
|
||||
VT_CHANNEL_TO_ORIENTATION = 12
|
||||
VT_CHANNEL_TO_ORIENTATION = 12,
|
||||
VT_CONNECTION = 14,
|
||||
VT_LEADER = 16,
|
||||
VT_FIRMWARE = 18
|
||||
};
|
||||
uint8_t module_id() const {
|
||||
return GetField<uint8_t>(VT_MODULE_ID, 0);
|
||||
@@ -44,6 +77,15 @@ struct TopologyMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
const ::flatbuffers::Vector<int8_t> *channel_to_orientation() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<int8_t> *>(VT_CHANNEL_TO_ORIENTATION);
|
||||
}
|
||||
Messaging::ConnectionType connection() const {
|
||||
return static_cast<Messaging::ConnectionType>(GetField<int8_t>(VT_CONNECTION, 0));
|
||||
}
|
||||
uint8_t leader() const {
|
||||
return GetField<uint8_t>(VT_LEADER, 0);
|
||||
}
|
||||
const ::flatbuffers::String *firmware() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_FIRMWARE);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint8_t>(verifier, VT_MODULE_ID, 1) &&
|
||||
@@ -53,6 +95,10 @@ struct TopologyMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
verifier.VerifyVector(channel_to_module()) &&
|
||||
VerifyOffset(verifier, VT_CHANNEL_TO_ORIENTATION) &&
|
||||
verifier.VerifyVector(channel_to_orientation()) &&
|
||||
VerifyField<int8_t>(verifier, VT_CONNECTION, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_LEADER, 1) &&
|
||||
VerifyOffset(verifier, VT_FIRMWARE) &&
|
||||
verifier.VerifyString(firmware()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
@@ -76,6 +122,15 @@ struct TopologyMessageBuilder {
|
||||
void add_channel_to_orientation(::flatbuffers::Offset<::flatbuffers::Vector<int8_t>> channel_to_orientation) {
|
||||
fbb_.AddOffset(TopologyMessage::VT_CHANNEL_TO_ORIENTATION, channel_to_orientation);
|
||||
}
|
||||
void add_connection(Messaging::ConnectionType connection) {
|
||||
fbb_.AddElement<int8_t>(TopologyMessage::VT_CONNECTION, static_cast<int8_t>(connection), 0);
|
||||
}
|
||||
void add_leader(uint8_t leader) {
|
||||
fbb_.AddElement<uint8_t>(TopologyMessage::VT_LEADER, leader, 0);
|
||||
}
|
||||
void add_firmware(::flatbuffers::Offset<::flatbuffers::String> firmware) {
|
||||
fbb_.AddOffset(TopologyMessage::VT_FIRMWARE, firmware);
|
||||
}
|
||||
explicit TopologyMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
@@ -93,10 +148,16 @@ inline ::flatbuffers::Offset<TopologyMessage> CreateTopologyMessage(
|
||||
ModuleType module_type = ModuleType_SPLITTER,
|
||||
uint8_t num_channels = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> channel_to_module = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<int8_t>> channel_to_orientation = 0) {
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<int8_t>> channel_to_orientation = 0,
|
||||
Messaging::ConnectionType connection = Messaging::ConnectionType_DIRECT,
|
||||
uint8_t leader = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> firmware = 0) {
|
||||
TopologyMessageBuilder builder_(_fbb);
|
||||
builder_.add_firmware(firmware);
|
||||
builder_.add_channel_to_orientation(channel_to_orientation);
|
||||
builder_.add_channel_to_module(channel_to_module);
|
||||
builder_.add_leader(leader);
|
||||
builder_.add_connection(connection);
|
||||
builder_.add_num_channels(num_channels);
|
||||
builder_.add_module_type(module_type);
|
||||
builder_.add_module_id(module_id);
|
||||
@@ -109,16 +170,23 @@ inline ::flatbuffers::Offset<TopologyMessage> CreateTopologyMessageDirect(
|
||||
ModuleType module_type = ModuleType_SPLITTER,
|
||||
uint8_t num_channels = 0,
|
||||
const std::vector<uint8_t> *channel_to_module = nullptr,
|
||||
const std::vector<int8_t> *channel_to_orientation = nullptr) {
|
||||
const std::vector<int8_t> *channel_to_orientation = nullptr,
|
||||
Messaging::ConnectionType connection = Messaging::ConnectionType_DIRECT,
|
||||
uint8_t leader = 0,
|
||||
const char *firmware = nullptr) {
|
||||
auto channel_to_module__ = channel_to_module ? _fbb.CreateVector<uint8_t>(*channel_to_module) : 0;
|
||||
auto channel_to_orientation__ = channel_to_orientation ? _fbb.CreateVector<int8_t>(*channel_to_orientation) : 0;
|
||||
auto firmware__ = firmware ? _fbb.CreateString(firmware) : 0;
|
||||
return Messaging::CreateTopologyMessage(
|
||||
_fbb,
|
||||
module_id,
|
||||
module_type,
|
||||
num_channels,
|
||||
channel_to_module__,
|
||||
channel_to_orientation__);
|
||||
channel_to_orientation__,
|
||||
connection,
|
||||
leader,
|
||||
firmware__);
|
||||
}
|
||||
|
||||
inline const Messaging::TopologyMessage *GetTopologyMessage(const void *buf) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define ACTUATOR_CMD_TAG 5
|
||||
#define TOPOLOGY_CMD_TAG 6
|
||||
|
||||
#define METADATA_PERIOD_MS 5000
|
||||
#define METADATA_PERIOD_MS 1000
|
||||
|
||||
[[noreturn]] void LoopManager::control_loop() const {
|
||||
const auto actuator = ActuatorFactory::create_actuator(ConfigManager::get_module_type());
|
||||
|
||||
Reference in New Issue
Block a user