mirror of
https://github.com/BotChain-Robots/control.git
synced 2026-03-09 16:22:26 +01:00
Oled implementation (#1)
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -45,3 +45,7 @@
|
|||||||
/cmake-build-debug
|
/cmake-build-debug
|
||||||
/.cache
|
/.cache
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
|
CMakeCache.txt
|
||||||
|
/CMakeFiles
|
||||||
|
/examples/display/build
|
||||||
|
*.log
|
||||||
|
|||||||
@@ -39,10 +39,11 @@ endif()
|
|||||||
|
|
||||||
target_include_directories(c_control PUBLIC include)
|
target_include_directories(c_control PUBLIC include)
|
||||||
target_link_libraries(c_control
|
target_link_libraries(c_control
|
||||||
|
PUBLIC
|
||||||
|
spdlog::spdlog
|
||||||
PRIVATE
|
PRIVATE
|
||||||
librpc::librpc
|
librpc::librpc
|
||||||
Eigen3::Eigen
|
Eigen3::Eigen
|
||||||
spdlog::spdlog
|
|
||||||
sentry-native::sentry-native
|
sentry-native::sentry-native
|
||||||
sentry-crashpad::sentry-crashpad
|
sentry-crashpad::sentry-crashpad
|
||||||
)
|
)
|
||||||
@@ -63,10 +64,11 @@ add_library(control SHARED
|
|||||||
|
|
||||||
target_include_directories(control PUBLIC include)
|
target_include_directories(control PUBLIC include)
|
||||||
target_link_libraries(control
|
target_link_libraries(control
|
||||||
|
PUBLIC
|
||||||
|
spdlog::spdlog
|
||||||
PRIVATE
|
PRIVATE
|
||||||
librpc::librpc
|
librpc::librpc
|
||||||
Eigen3::Eigen
|
Eigen3::Eigen
|
||||||
spdlog::spdlog
|
|
||||||
sentry-native::sentry-native
|
sentry-native::sentry-native
|
||||||
sentry-crashpad::sentry-crashpad
|
sentry-crashpad::sentry-crashpad
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
"conan": {}
|
"conan": {}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"build/RelWithDebInfo/generators/CMakePresets.json"
|
"build/Release/generators/CMakePresets.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
19
examples/display/CMakeLists.txt
Normal file
19
examples/display/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
project(DisplayExample)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
find_package(libcontrol REQUIRED)
|
||||||
|
find_package(spdlog REQUIRED)
|
||||||
|
find_package(librpc REQUIRED)
|
||||||
|
|
||||||
|
add_executable(DisplayExample main.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(DisplayExample
|
||||||
|
PRIVATE
|
||||||
|
libcontrol::libcontrol
|
||||||
|
spdlog::spdlog
|
||||||
|
librpc::librpc
|
||||||
|
)
|
||||||
9
examples/display/CMakeUserPresets.json
Normal file
9
examples/display/CMakeUserPresets.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"vendor": {
|
||||||
|
"conan": {}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"build/CMakePresets.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
10
examples/display/README.md
Normal file
10
examples/display/README.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Display Example
|
||||||
|
|
||||||
|
## Compiling
|
||||||
|
```
|
||||||
|
conan install . --build=missing --output-folder=build -s build_type=Release
|
||||||
|
cmake -S . -B "build" -DCMAKE_TOOLCHAIN_FILE="build/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE="Release"
|
||||||
|
cmake --build "./build" --config "Release"
|
||||||
|
|
||||||
|
./build/DisplayExample
|
||||||
|
```
|
||||||
9
examples/display/conanfile.txt
Normal file
9
examples/display/conanfile.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[requires]
|
||||||
|
libcontrol/1.0.0
|
||||||
|
flatbuffers/24.12.23
|
||||||
|
spdlog/1.16.0
|
||||||
|
librpc/1.1.6
|
||||||
|
|
||||||
|
[generators]
|
||||||
|
CMakeDeps
|
||||||
|
CMakeToolchain
|
||||||
31
examples/display/main.cpp
Normal file
31
examples/display/main.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include <chrono>
|
||||||
|
#include <iostream>
|
||||||
|
#include <format>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
#include "libcontrol.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
const auto controller = std::make_unique<RobotController>();
|
||||||
|
|
||||||
|
controller->fetchDirectlyConnectedModules(true);
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "Found " << controller->getModules().size() << " modules" << std::endl;
|
||||||
|
|
||||||
|
for (const auto& maybe_module : controller->getModules()) {
|
||||||
|
if (const auto& module = maybe_module.lock()) {
|
||||||
|
std::cout << "Found module " << (int)module->get_device_id();
|
||||||
|
|
||||||
|
if (module->get_type() == ModuleType_DISPLAY) {
|
||||||
|
module->actuate(std::format("BotChain \n\n\nModule ID: {}", module->get_device_id()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -13,15 +13,18 @@ class Hub final : public Module {
|
|||||||
public:
|
public:
|
||||||
explicit Hub(uint8_t device_id) : Module(device_id) {};
|
explicit Hub(uint8_t device_id) : Module(device_id) {};
|
||||||
|
|
||||||
Hub(uint8_t device_id, ModuleType module_type) : Module(device_id, module_type) {};
|
Hub(uint8_t device_id, ModuleType module_type)
|
||||||
|
: Module(device_id, module_type) {};
|
||||||
|
|
||||||
Hub(uint8_t device_id, ModuleType module_type, Messaging::ConnectionType connection_type,
|
Hub(uint8_t device_id, ModuleType module_type,
|
||||||
uint8_t leader)
|
Messaging::ConnectionType connection_type, uint8_t leader)
|
||||||
: Module(device_id, module_type, connection_type, leader) {};
|
: Module(device_id, module_type, connection_type, leader) {};
|
||||||
|
|
||||||
double get_position() override;
|
double get_position() override;
|
||||||
|
std::string get_text() override;
|
||||||
void actuate(double position) override;
|
void actuate(double position) override;
|
||||||
void actuate(double x, double y) override;
|
void actuate(double x, double y) override;
|
||||||
|
void actuate(const std::string &t) override;
|
||||||
std::vector<uint8_t> get_actuation_message() override;
|
std::vector<uint8_t> get_actuation_message() override;
|
||||||
void update_sensor_data(const Flatbuffers::sensor_value &value) override;
|
void update_sensor_data(const Flatbuffers::sensor_value &value) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "flatbuffers/SensorMessageBuilder.h"
|
#include "flatbuffers/SensorMessageBuilder.h"
|
||||||
#include "flatbuffers_generated/RobotModule_generated.h"
|
#include "flatbuffers_generated/RobotModule_generated.h"
|
||||||
@@ -25,10 +26,10 @@ class Module {
|
|||||||
Module(uint8_t device_id, ModuleType module_type)
|
Module(uint8_t device_id, ModuleType module_type)
|
||||||
: m_device_id(device_id), m_module_type(module_type) {};
|
: m_device_id(device_id), m_module_type(module_type) {};
|
||||||
|
|
||||||
Module(uint8_t device_id, ModuleType module_type, Messaging::ConnectionType connection_type,
|
Module(uint8_t device_id, ModuleType module_type,
|
||||||
uint8_t leader)
|
Messaging::ConnectionType connection_type, uint8_t leader)
|
||||||
: m_device_id(device_id), m_module_type(module_type), m_connection_type(connection_type),
|
: m_device_id(device_id), m_module_type(module_type),
|
||||||
m_leader(leader) {};
|
m_connection_type(connection_type), m_leader(leader) {};
|
||||||
|
|
||||||
std::vector<neighbour> get_neighbours();
|
std::vector<neighbour> get_neighbours();
|
||||||
|
|
||||||
@@ -42,10 +43,11 @@ class Module {
|
|||||||
|
|
||||||
std::chrono::time_point<std::chrono::system_clock> get_last_updated_time();
|
std::chrono::time_point<std::chrono::system_clock> get_last_updated_time();
|
||||||
|
|
||||||
|
// Not all modules implement all actuation/sensor values, some are no-ops
|
||||||
virtual double get_position() = 0;
|
virtual double get_position() = 0;
|
||||||
|
virtual std::string get_text() = 0;
|
||||||
virtual void actuate(double x) = 0;
|
virtual void actuate(double x) = 0;
|
||||||
|
virtual void actuate(const std::string &text) = 0;
|
||||||
// There are no modules with 2D actuation support, this is an example of how to implement it.
|
|
||||||
virtual void actuate(double x, double y) = 0;
|
virtual void actuate(double x, double y) = 0;
|
||||||
|
|
||||||
void update_module_metadata(const Messaging::TopologyMessage &message);
|
void update_module_metadata(const Messaging::TopologyMessage &message);
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ class Actuator : public Module {
|
|||||||
public:
|
public:
|
||||||
explicit Actuator(uint8_t device_id) : Module(device_id) {};
|
explicit Actuator(uint8_t device_id) : Module(device_id) {};
|
||||||
|
|
||||||
Actuator(uint8_t device_id, ModuleType module_type) : Module(device_id, module_type) {};
|
Actuator(uint8_t device_id, ModuleType module_type)
|
||||||
|
: Module(device_id, module_type) {};
|
||||||
|
|
||||||
Actuator(uint8_t device_id, ModuleType module_type, Messaging::ConnectionType connection_type,
|
Actuator(uint8_t device_id, ModuleType module_type,
|
||||||
uint8_t leader)
|
Messaging::ConnectionType connection_type, uint8_t leader)
|
||||||
: Module(device_id, module_type, connection_type, leader) {};
|
: Module(device_id, module_type, connection_type, leader) {};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef CONTROL_BOUNDED1DPOSITIONALACTUATOR_H
|
#ifndef CONTROL_BOUNDED1DPOSITIONALACTUATOR_H
|
||||||
#define CONTROL_BOUNDED1DPOSITIONALACTUATOR_H
|
#define CONTROL_BOUNDED1DPOSITIONALACTUATOR_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "actuators/Actuator.h"
|
#include "actuators/Actuator.h"
|
||||||
#include "flatbuffers/AngleControlMessageBuilder.h"
|
#include "flatbuffers/AngleControlMessageBuilder.h"
|
||||||
#include "flatbuffers/SensorMessageBuilder.h"
|
#include "flatbuffers/SensorMessageBuilder.h"
|
||||||
@@ -12,15 +14,18 @@
|
|||||||
class BoundedPositionalActuator1D : public Actuator {
|
class BoundedPositionalActuator1D : public Actuator {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BoundedPositionalActuator1D(uint8_t device_id, ModuleType type, double max_value,
|
BoundedPositionalActuator1D(uint8_t device_id, ModuleType type,
|
||||||
double min_value, double initial_position)
|
double max_value, double min_value,
|
||||||
: Actuator(device_id, type), m_target_position(initial_position), m_max_value(max_value),
|
double initial_position)
|
||||||
m_min_value(min_value),
|
: Actuator(device_id, type), m_target_position(initial_position),
|
||||||
acm_builder(std::make_unique<Flatbuffers::AngleControlMessageBuilder>()) {
|
m_max_value(max_value), m_min_value(min_value),
|
||||||
}
|
acm_builder(
|
||||||
|
std::make_unique<Flatbuffers::AngleControlMessageBuilder>()) {}
|
||||||
|
|
||||||
double get_position() override;
|
double get_position() override;
|
||||||
|
std::string get_text() override; // no-op
|
||||||
void actuate(double position) override;
|
void actuate(double position) override;
|
||||||
|
void actuate(const std::string &text) override; // no-op
|
||||||
void actuate(double x, double y) override; // no-op
|
void actuate(double x, double y) override; // no-op
|
||||||
|
|
||||||
std::vector<uint8_t> get_actuation_message() override;
|
std::vector<uint8_t> get_actuation_message() override;
|
||||||
|
|||||||
38
include/actuators/OledActuator.h
Normal file
38
include/actuators/OledActuator.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// Created by Johnathon Slightham on 2025-11-13.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef CONTROL_OLEDACTUATOR_H
|
||||||
|
#define CONTROL_OLEDACTUATOR_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "actuators/Actuator.h"
|
||||||
|
#include "flatbuffers/SensorMessageBuilder.h"
|
||||||
|
#include "flatbuffers/TextControlMessageBuilder.h"
|
||||||
|
|
||||||
|
class OledActuator : public Actuator {
|
||||||
|
|
||||||
|
public:
|
||||||
|
OledActuator(uint8_t device_id, ModuleType type)
|
||||||
|
: Actuator(device_id, type),
|
||||||
|
m_text_message_builder(
|
||||||
|
std::make_unique<Flatbuffers::TextControlMessageBuilder>()) {}
|
||||||
|
|
||||||
|
double get_position() override;
|
||||||
|
std::string get_text() override;
|
||||||
|
void actuate(double position) override;
|
||||||
|
void actuate(double x, double y) override; // no-op
|
||||||
|
void actuate(const std::string &text) override;
|
||||||
|
|
||||||
|
std::vector<uint8_t> get_actuation_message() override;
|
||||||
|
void update_sensor_data(const Flatbuffers::sensor_value &value) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_current_text = "";
|
||||||
|
std::string m_target_text = "";
|
||||||
|
std::unique_ptr<Flatbuffers::TextControlMessageBuilder>
|
||||||
|
m_text_message_builder;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONTROL_OLEDACTUATOR_H
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef CONTROL_1DPOSITIONALACTUATOR_H
|
#ifndef CONTROL_1DPOSITIONALACTUATOR_H
|
||||||
#define CONTROL_1DPOSITIONALACTUATOR_H
|
#define CONTROL_1DPOSITIONALACTUATOR_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "actuators/Actuator.h"
|
#include "actuators/Actuator.h"
|
||||||
#include "flatbuffers/AngleControlMessageBuilder.h"
|
#include "flatbuffers/AngleControlMessageBuilder.h"
|
||||||
#include "flatbuffers/SensorMessageBuilder.h"
|
#include "flatbuffers/SensorMessageBuilder.h"
|
||||||
@@ -14,10 +16,13 @@ class PositionalActuator1D final : public Actuator {
|
|||||||
public:
|
public:
|
||||||
PositionalActuator1D(uint8_t device_id, ModuleType type)
|
PositionalActuator1D(uint8_t device_id, ModuleType type)
|
||||||
: Actuator(device_id, type),
|
: Actuator(device_id, type),
|
||||||
m_acm_builder(std::make_unique<Flatbuffers::AngleControlMessageBuilder>()) {};
|
m_acm_builder(
|
||||||
|
std::make_unique<Flatbuffers::AngleControlMessageBuilder>()) {};
|
||||||
|
|
||||||
double get_position() override;
|
double get_position() override;
|
||||||
|
std::string get_text() override; // no-op
|
||||||
void actuate(double position) override;
|
void actuate(double position) override;
|
||||||
|
void actuate(const std::string &text) override; // no-op
|
||||||
void actuate(double x, double y) override; // no-op
|
void actuate(double x, double y) override; // no-op
|
||||||
|
|
||||||
std::vector<uint8_t> get_actuation_message() override;
|
std::vector<uint8_t> get_actuation_message() override;
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
namespace Flatbuffers {
|
namespace Flatbuffers {
|
||||||
class AngleControlMessageBuilder {
|
class AngleControlMessageBuilder {
|
||||||
public:
|
public:
|
||||||
AngleControlMessageBuilder() : builder_(256) {
|
AngleControlMessageBuilder() : builder_(256) {}
|
||||||
}
|
|
||||||
|
|
||||||
SerializedMessage build_angle_control_message(int16_t angle);
|
SerializedMessage build_angle_control_message(int16_t angle);
|
||||||
static const Messaging::AngleControlMessage *parse_angle_control_message(const uint8_t *buffer);
|
static const Messaging::AngleControlMessage *
|
||||||
|
parse_angle_control_message(const uint8_t *buffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
flatbuffers::FlatBufferBuilder builder_;
|
flatbuffers::FlatBufferBuilder builder_;
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ struct ModuleConnectionInstance {
|
|||||||
|
|
||||||
class RobotConfigurationBuilder {
|
class RobotConfigurationBuilder {
|
||||||
public:
|
public:
|
||||||
RobotConfigurationBuilder() : builder_(1024) {
|
RobotConfigurationBuilder() : builder_(1024) {}
|
||||||
}
|
|
||||||
|
|
||||||
SerializedMessage
|
SerializedMessage build_robot_configuration(
|
||||||
build_robot_configuration(const std::vector<ModuleInstance> &modules,
|
const std::vector<ModuleInstance> &modules,
|
||||||
const std::vector<ModuleConnectionInstance> &connections);
|
const std::vector<ModuleConnectionInstance> &connections);
|
||||||
|
|
||||||
static const Frontend::RobotConfiguration *
|
static const Frontend::RobotConfiguration *
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#ifndef SENSORMESSAGEBUILDER_H
|
#ifndef SENSORMESSAGEBUILDER_H
|
||||||
#define SENSORMESSAGEBUILDER_H
|
#define SENSORMESSAGEBUILDER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include "flatbuffers_generated/SensorMessage_generated.h"
|
#include "flatbuffers_generated/SensorMessage_generated.h"
|
||||||
@@ -19,17 +20,22 @@ struct current_angle {
|
|||||||
int16_t angle;
|
int16_t angle;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::variant<target_angle, current_angle> sensor_value;
|
struct current_text {
|
||||||
|
std::string text;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::variant<target_angle, current_angle, current_text> sensor_value;
|
||||||
|
|
||||||
class SensorMessageBuilder {
|
class SensorMessageBuilder {
|
||||||
public:
|
public:
|
||||||
SensorMessageBuilder() : builder_(1024) {
|
SensorMessageBuilder() : builder_(1024) {}
|
||||||
}
|
|
||||||
|
|
||||||
static const Messaging::SensorMessage *parse_sensor_message(const std::uint8_t *buffer);
|
static const Messaging::SensorMessage *
|
||||||
|
parse_sensor_message(const std::uint8_t *buffer);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static std::optional<sensor_value> build_sensor_value(Messaging::SensorValue type, T value) {
|
static std::optional<sensor_value>
|
||||||
|
build_sensor_value(Messaging::SensorValue type, T value) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Messaging::SensorValue_TargetAngle: {
|
case Messaging::SensorValue_TargetAngle: {
|
||||||
const Messaging::TargetAngle *target =
|
const Messaging::TargetAngle *target =
|
||||||
@@ -41,6 +47,11 @@ class SensorMessageBuilder {
|
|||||||
static_cast<const Messaging::CurrentAngle *>(value);
|
static_cast<const Messaging::CurrentAngle *>(value);
|
||||||
return current_angle{current->value()};
|
return current_angle{current->value()};
|
||||||
}
|
}
|
||||||
|
case Messaging::SensorValue_CurrentText: {
|
||||||
|
const Messaging::CurrentText *current =
|
||||||
|
static_cast<const Messaging::CurrentText *>(value);
|
||||||
|
return current_text{current->value()->str()};
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|||||||
27
include/flatbuffers/TextControlMessageBuilder.h
Normal file
27
include/flatbuffers/TextControlMessageBuilder.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Created by Johnathon Slightham on 2025-06-30.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef TEXTCONTROLMESSAGEBUILDER_H_
|
||||||
|
#define TEXTCONTROLMESSAGEBUILDER_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "SerializedMessage.h"
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
#include "flatbuffers_generated/TextControlMessage_generated.h"
|
||||||
|
|
||||||
|
namespace Flatbuffers {
|
||||||
|
class TextControlMessageBuilder {
|
||||||
|
public:
|
||||||
|
TextControlMessageBuilder() : builder_(256) {}
|
||||||
|
|
||||||
|
SerializedMessage build_text_control_message(std::string &t);
|
||||||
|
|
||||||
|
private:
|
||||||
|
flatbuffers::FlatBufferBuilder builder_;
|
||||||
|
};
|
||||||
|
} // namespace Flatbuffers
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -13,14 +13,15 @@
|
|||||||
namespace Flatbuffers {
|
namespace Flatbuffers {
|
||||||
class TopologyMessageBuilder {
|
class TopologyMessageBuilder {
|
||||||
public:
|
public:
|
||||||
TopologyMessageBuilder() : builder_(1024) {
|
TopologyMessageBuilder() : builder_(1024) {}
|
||||||
}
|
|
||||||
|
|
||||||
SerializedMessage build_topology_message(uint8_t module_id, ModuleType module_type,
|
SerializedMessage
|
||||||
|
build_topology_message(uint8_t module_id, ModuleType module_type,
|
||||||
const std::vector<uint8_t> &channel_to_module,
|
const std::vector<uint8_t> &channel_to_module,
|
||||||
const std::vector<int8_t> &orientation_to_module);
|
const std::vector<int8_t> &orientation_to_module);
|
||||||
|
|
||||||
static const Messaging::TopologyMessage *parse_topology_message(const uint8_t *buffer);
|
static const Messaging::TopologyMessage *
|
||||||
|
parse_topology_message(const uint8_t *buffer);
|
||||||
|
|
||||||
static bool is_valid_topology_message(const uint8_t *buffer, size_t size);
|
static bool is_valid_topology_message(const uint8_t *buffer, size_t size);
|
||||||
|
|
||||||
|
|||||||
@@ -17,15 +17,16 @@ namespace Messaging {
|
|||||||
struct AngleControlMessage;
|
struct AngleControlMessage;
|
||||||
struct AngleControlMessageBuilder;
|
struct AngleControlMessageBuilder;
|
||||||
|
|
||||||
struct AngleControlMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct AngleControlMessage FLATBUFFERS_FINAL_CLASS
|
||||||
|
: private ::flatbuffers::Table {
|
||||||
typedef AngleControlMessageBuilder Builder;
|
typedef AngleControlMessageBuilder Builder;
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_ANGLE = 4 };
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
int16_t angle() const {
|
VT_ANGLE = 4
|
||||||
return GetField<int16_t>(VT_ANGLE, 0);
|
};
|
||||||
}
|
int16_t angle() const { return GetField<int16_t>(VT_ANGLE, 0); }
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyField<int16_t>(verifier, VT_ANGLE, 2) &&
|
return VerifyTableStart(verifier) &&
|
||||||
verifier.EndTable();
|
VerifyField<int16_t>(verifier, VT_ANGLE, 2) && verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,7 +37,8 @@ struct AngleControlMessageBuilder {
|
|||||||
void add_angle(int16_t angle) {
|
void add_angle(int16_t angle) {
|
||||||
fbb_.AddElement<int16_t>(AngleControlMessage::VT_ANGLE, angle, 0);
|
fbb_.AddElement<int16_t>(AngleControlMessage::VT_ANGLE, angle, 0);
|
||||||
}
|
}
|
||||||
explicit AngleControlMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit AngleControlMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<AngleControlMessage> Finish() {
|
::flatbuffers::Offset<AngleControlMessage> Finish() {
|
||||||
@@ -47,30 +49,36 @@ struct AngleControlMessageBuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<AngleControlMessage>
|
inline ::flatbuffers::Offset<AngleControlMessage>
|
||||||
CreateAngleControlMessage(::flatbuffers::FlatBufferBuilder &_fbb, int16_t angle = 0) {
|
CreateAngleControlMessage(::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
int16_t angle = 0) {
|
||||||
AngleControlMessageBuilder builder_(_fbb);
|
AngleControlMessageBuilder builder_(_fbb);
|
||||||
builder_.add_angle(angle);
|
builder_.add_angle(angle);
|
||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Messaging::AngleControlMessage *GetAngleControlMessage(const void *buf) {
|
inline const Messaging::AngleControlMessage *
|
||||||
|
GetAngleControlMessage(const void *buf) {
|
||||||
return ::flatbuffers::GetRoot<Messaging::AngleControlMessage>(buf);
|
return ::flatbuffers::GetRoot<Messaging::AngleControlMessage>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Messaging::AngleControlMessage *GetSizePrefixedAngleControlMessage(const void *buf) {
|
inline const Messaging::AngleControlMessage *
|
||||||
return ::flatbuffers::GetSizePrefixedRoot<Messaging::AngleControlMessage>(buf);
|
GetSizePrefixedAngleControlMessage(const void *buf) {
|
||||||
|
return ::flatbuffers::GetSizePrefixedRoot<Messaging::AngleControlMessage>(
|
||||||
|
buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifyAngleControlMessageBuffer(::flatbuffers::Verifier &verifier) {
|
inline bool VerifyAngleControlMessageBuffer(::flatbuffers::Verifier &verifier) {
|
||||||
return verifier.VerifyBuffer<Messaging::AngleControlMessage>(nullptr);
|
return verifier.VerifyBuffer<Messaging::AngleControlMessage>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifySizePrefixedAngleControlMessageBuffer(::flatbuffers::Verifier &verifier) {
|
inline bool
|
||||||
return verifier.VerifySizePrefixedBuffer<Messaging::AngleControlMessage>(nullptr);
|
VerifySizePrefixedAngleControlMessageBuffer(::flatbuffers::Verifier &verifier) {
|
||||||
|
return verifier.VerifySizePrefixedBuffer<Messaging::AngleControlMessage>(
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void FinishAngleControlMessageBuffer(
|
||||||
FinishAngleControlMessageBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
::flatbuffers::Offset<Messaging::AngleControlMessage> root) {
|
::flatbuffers::Offset<Messaging::AngleControlMessage> root) {
|
||||||
fbb.Finish(root);
|
fbb.Finish(root);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,24 +34,20 @@ struct ModuleConnection FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
uint8_t from_module_id() const {
|
uint8_t from_module_id() const {
|
||||||
return GetField<uint8_t>(VT_FROM_MODULE_ID, 0);
|
return GetField<uint8_t>(VT_FROM_MODULE_ID, 0);
|
||||||
}
|
}
|
||||||
uint8_t to_module_id() const {
|
uint8_t to_module_id() const { return GetField<uint8_t>(VT_TO_MODULE_ID, 0); }
|
||||||
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); }
|
||||||
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 {
|
Orientation orientation() const {
|
||||||
return static_cast<Orientation>(GetField<int8_t>(VT_ORIENTATION, 0));
|
return static_cast<Orientation>(GetField<int8_t>(VT_ORIENTATION, 0));
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_FROM_MODULE_ID, 1) &&
|
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_TO_MODULE_ID, 1) &&
|
||||||
VerifyField<uint8_t>(verifier, VT_FROM_SOCKET, 1) &&
|
VerifyField<uint8_t>(verifier, VT_FROM_SOCKET, 1) &&
|
||||||
VerifyField<uint8_t>(verifier, VT_TO_SOCKET, 1) &&
|
VerifyField<uint8_t>(verifier, VT_TO_SOCKET, 1) &&
|
||||||
VerifyField<int8_t>(verifier, VT_ORIENTATION, 1) && verifier.EndTable();
|
VerifyField<int8_t>(verifier, VT_ORIENTATION, 1) &&
|
||||||
|
verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -60,10 +56,12 @@ struct ModuleConnectionBuilder {
|
|||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
::flatbuffers::uoffset_t start_;
|
::flatbuffers::uoffset_t start_;
|
||||||
void add_from_module_id(uint8_t from_module_id) {
|
void add_from_module_id(uint8_t from_module_id) {
|
||||||
fbb_.AddElement<uint8_t>(ModuleConnection::VT_FROM_MODULE_ID, from_module_id, 0);
|
fbb_.AddElement<uint8_t>(ModuleConnection::VT_FROM_MODULE_ID,
|
||||||
|
from_module_id, 0);
|
||||||
}
|
}
|
||||||
void add_to_module_id(uint8_t to_module_id) {
|
void add_to_module_id(uint8_t to_module_id) {
|
||||||
fbb_.AddElement<uint8_t>(ModuleConnection::VT_TO_MODULE_ID, to_module_id, 0);
|
fbb_.AddElement<uint8_t>(ModuleConnection::VT_TO_MODULE_ID, to_module_id,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
void add_from_socket(uint8_t from_socket) {
|
void add_from_socket(uint8_t from_socket) {
|
||||||
fbb_.AddElement<uint8_t>(ModuleConnection::VT_FROM_SOCKET, from_socket, 0);
|
fbb_.AddElement<uint8_t>(ModuleConnection::VT_FROM_SOCKET, from_socket, 0);
|
||||||
@@ -72,10 +70,11 @@ struct ModuleConnectionBuilder {
|
|||||||
fbb_.AddElement<uint8_t>(ModuleConnection::VT_TO_SOCKET, to_socket, 0);
|
fbb_.AddElement<uint8_t>(ModuleConnection::VT_TO_SOCKET, to_socket, 0);
|
||||||
}
|
}
|
||||||
void add_orientation(Orientation orientation) {
|
void add_orientation(Orientation orientation) {
|
||||||
fbb_.AddElement<int8_t>(ModuleConnection::VT_ORIENTATION, static_cast<int8_t>(orientation),
|
fbb_.AddElement<int8_t>(ModuleConnection::VT_ORIENTATION,
|
||||||
0);
|
static_cast<int8_t>(orientation), 0);
|
||||||
}
|
}
|
||||||
explicit ModuleConnectionBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit ModuleConnectionBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<ModuleConnection> Finish() {
|
::flatbuffers::Offset<ModuleConnection> Finish() {
|
||||||
@@ -86,8 +85,9 @@ struct ModuleConnectionBuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<ModuleConnection>
|
inline ::flatbuffers::Offset<ModuleConnection>
|
||||||
CreateModuleConnection(::flatbuffers::FlatBufferBuilder &_fbb, uint8_t from_module_id = 0,
|
CreateModuleConnection(::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
uint8_t to_module_id = 0, uint8_t from_socket = 0, uint8_t to_socket = 0,
|
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) {
|
Orientation orientation = Orientation_Deg0) {
|
||||||
ModuleConnectionBuilder builder_(_fbb);
|
ModuleConnectionBuilder builder_(_fbb);
|
||||||
builder_.add_orientation(orientation);
|
builder_.add_orientation(orientation);
|
||||||
@@ -98,26 +98,31 @@ CreateModuleConnection(::flatbuffers::FlatBufferBuilder &_fbb, uint8_t from_modu
|
|||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RobotConfiguration FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct RobotConfiguration FLATBUFFERS_FINAL_CLASS
|
||||||
|
: private ::flatbuffers::Table {
|
||||||
typedef RobotConfigurationBuilder Builder;
|
typedef RobotConfigurationBuilder Builder;
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
VT_MODULES = 4,
|
VT_MODULES = 4,
|
||||||
VT_CONNECTIONS = 6
|
VT_CONNECTIONS = 6
|
||||||
};
|
};
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>> *modules() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>> *
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>> *>(
|
modules() const {
|
||||||
|
return GetPointer<
|
||||||
|
const ::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>> *>(
|
||||||
VT_MODULES);
|
VT_MODULES);
|
||||||
}
|
}
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Frontend::ModuleConnection>> *
|
const ::flatbuffers::Vector<
|
||||||
|
::flatbuffers::Offset<Frontend::ModuleConnection>> *
|
||||||
connections() const {
|
connections() const {
|
||||||
return GetPointer<
|
return GetPointer<const ::flatbuffers::Vector<
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Frontend::ModuleConnection>> *>(
|
::flatbuffers::Offset<Frontend::ModuleConnection>> *>(VT_CONNECTIONS);
|
||||||
VT_CONNECTIONS);
|
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_MODULES) &&
|
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_MODULES) &&
|
||||||
verifier.VerifyVector(modules()) && verifier.VerifyVectorOfTables(modules()) &&
|
verifier.VerifyVector(modules()) &&
|
||||||
VerifyOffset(verifier, VT_CONNECTIONS) && verifier.VerifyVector(connections()) &&
|
verifier.VerifyVectorOfTables(modules()) &&
|
||||||
|
VerifyOffset(verifier, VT_CONNECTIONS) &&
|
||||||
|
verifier.VerifyVector(connections()) &&
|
||||||
verifier.VerifyVectorOfTables(connections()) && verifier.EndTable();
|
verifier.VerifyVectorOfTables(connections()) && verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -126,16 +131,18 @@ struct RobotConfigurationBuilder {
|
|||||||
typedef RobotConfiguration Table;
|
typedef RobotConfiguration Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
::flatbuffers::uoffset_t start_;
|
::flatbuffers::uoffset_t start_;
|
||||||
void add_modules(
|
void add_modules(::flatbuffers::Offset<
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>>> modules) {
|
::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>>>
|
||||||
|
modules) {
|
||||||
fbb_.AddOffset(RobotConfiguration::VT_MODULES, modules);
|
fbb_.AddOffset(RobotConfiguration::VT_MODULES, modules);
|
||||||
}
|
}
|
||||||
void add_connections(::flatbuffers::Offset<
|
void add_connections(::flatbuffers::Offset<::flatbuffers::Vector<
|
||||||
::flatbuffers::Vector<::flatbuffers::Offset<Frontend::ModuleConnection>>>
|
::flatbuffers::Offset<Frontend::ModuleConnection>>>
|
||||||
connections) {
|
connections) {
|
||||||
fbb_.AddOffset(RobotConfiguration::VT_CONNECTIONS, connections);
|
fbb_.AddOffset(RobotConfiguration::VT_CONNECTIONS, connections);
|
||||||
}
|
}
|
||||||
explicit RobotConfigurationBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit RobotConfigurationBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<RobotConfiguration> Finish() {
|
::flatbuffers::Offset<RobotConfiguration> Finish() {
|
||||||
@@ -147,8 +154,11 @@ struct RobotConfigurationBuilder {
|
|||||||
|
|
||||||
inline ::flatbuffers::Offset<RobotConfiguration> CreateRobotConfiguration(
|
inline ::flatbuffers::Offset<RobotConfiguration> CreateRobotConfiguration(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>>> modules = 0,
|
::flatbuffers::Offset<
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Frontend::ModuleConnection>>>
|
::flatbuffers::Vector<::flatbuffers::Offset<RobotModule>>>
|
||||||
|
modules = 0,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::Vector<
|
||||||
|
::flatbuffers::Offset<Frontend::ModuleConnection>>>
|
||||||
connections = 0) {
|
connections = 0) {
|
||||||
RobotConfigurationBuilder builder_(_fbb);
|
RobotConfigurationBuilder builder_(_fbb);
|
||||||
builder_.add_connections(connections);
|
builder_.add_connections(connections);
|
||||||
@@ -159,20 +169,26 @@ inline ::flatbuffers::Offset<RobotConfiguration> CreateRobotConfiguration(
|
|||||||
inline ::flatbuffers::Offset<RobotConfiguration> CreateRobotConfigurationDirect(
|
inline ::flatbuffers::Offset<RobotConfiguration> CreateRobotConfigurationDirect(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
const std::vector<::flatbuffers::Offset<RobotModule>> *modules = nullptr,
|
const std::vector<::flatbuffers::Offset<RobotModule>> *modules = nullptr,
|
||||||
const std::vector<::flatbuffers::Offset<Frontend::ModuleConnection>> *connections = nullptr) {
|
const std::vector<::flatbuffers::Offset<Frontend::ModuleConnection>>
|
||||||
auto modules__ = modules ? _fbb.CreateVector<::flatbuffers::Offset<RobotModule>>(*modules) : 0;
|
*connections = nullptr) {
|
||||||
|
auto modules__ =
|
||||||
|
modules ? _fbb.CreateVector<::flatbuffers::Offset<RobotModule>>(*modules)
|
||||||
|
: 0;
|
||||||
auto connections__ =
|
auto connections__ =
|
||||||
connections
|
connections
|
||||||
? _fbb.CreateVector<::flatbuffers::Offset<Frontend::ModuleConnection>>(*connections)
|
? _fbb.CreateVector<
|
||||||
|
::flatbuffers::Offset<Frontend::ModuleConnection>>(*connections)
|
||||||
: 0;
|
: 0;
|
||||||
return Frontend::CreateRobotConfiguration(_fbb, modules__, connections__);
|
return Frontend::CreateRobotConfiguration(_fbb, modules__, connections__);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Frontend::RobotConfiguration *GetRobotConfiguration(const void *buf) {
|
inline const Frontend::RobotConfiguration *
|
||||||
|
GetRobotConfiguration(const void *buf) {
|
||||||
return ::flatbuffers::GetRoot<Frontend::RobotConfiguration>(buf);
|
return ::flatbuffers::GetRoot<Frontend::RobotConfiguration>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Frontend::RobotConfiguration *GetSizePrefixedRobotConfiguration(const void *buf) {
|
inline const Frontend::RobotConfiguration *
|
||||||
|
GetSizePrefixedRobotConfiguration(const void *buf) {
|
||||||
return ::flatbuffers::GetSizePrefixedRoot<Frontend::RobotConfiguration>(buf);
|
return ::flatbuffers::GetSizePrefixedRoot<Frontend::RobotConfiguration>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,12 +196,14 @@ inline bool VerifyRobotConfigurationBuffer(::flatbuffers::Verifier &verifier) {
|
|||||||
return verifier.VerifyBuffer<Frontend::RobotConfiguration>(nullptr);
|
return verifier.VerifyBuffer<Frontend::RobotConfiguration>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifySizePrefixedRobotConfigurationBuffer(::flatbuffers::Verifier &verifier) {
|
inline bool
|
||||||
return verifier.VerifySizePrefixedBuffer<Frontend::RobotConfiguration>(nullptr);
|
VerifySizePrefixedRobotConfigurationBuffer(::flatbuffers::Verifier &verifier) {
|
||||||
|
return verifier.VerifySizePrefixedBuffer<Frontend::RobotConfiguration>(
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void FinishRobotConfigurationBuffer(
|
||||||
FinishRobotConfigurationBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
::flatbuffers::Offset<Frontend::RobotConfiguration> root) {
|
::flatbuffers::Offset<Frontend::RobotConfiguration> root) {
|
||||||
fbb.Finish(root);
|
fbb.Finish(root);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,25 +24,44 @@ enum ModuleType : int8_t {
|
|||||||
ModuleType_DC_MOTOR = 2,
|
ModuleType_DC_MOTOR = 2,
|
||||||
ModuleType_BATTERY = 3,
|
ModuleType_BATTERY = 3,
|
||||||
ModuleType_SERVO_2 = 4,
|
ModuleType_SERVO_2 = 4,
|
||||||
|
ModuleType_DISPLAY = 5,
|
||||||
|
ModuleType_GRIPPER = 6,
|
||||||
|
ModuleType_SPEAKER = 7,
|
||||||
|
ModuleType_IMU = 8,
|
||||||
|
ModuleType_DISTANCE_SENSOR = 9,
|
||||||
|
ModuleType_SPLITTER_2 = 10,
|
||||||
|
ModuleType_SPLITTER_3 = 11,
|
||||||
|
ModuleType_SPLITTER_4 = 12,
|
||||||
|
ModuleType_SPLITTER_5 = 13,
|
||||||
|
ModuleType_SPLITTER_6 = 14,
|
||||||
|
ModuleType_SPLITTER_7 = 15,
|
||||||
|
ModuleType_SPLITTER_8 = 16,
|
||||||
ModuleType_MIN = ModuleType_SPLITTER,
|
ModuleType_MIN = ModuleType_SPLITTER,
|
||||||
ModuleType_MAX = ModuleType_SERVO_2
|
ModuleType_MAX = ModuleType_SPLITTER_8
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const ModuleType (&EnumValuesModuleType())[5] {
|
inline const ModuleType (&EnumValuesModuleType())[17] {
|
||||||
static const ModuleType values[] = {ModuleType_SPLITTER, ModuleType_SERVO_1,
|
static const ModuleType values[] = {
|
||||||
ModuleType_DC_MOTOR, ModuleType_BATTERY,
|
ModuleType_SPLITTER, ModuleType_SERVO_1, ModuleType_DC_MOTOR,
|
||||||
ModuleType_SERVO_2};
|
ModuleType_BATTERY, ModuleType_SERVO_2, ModuleType_DISPLAY,
|
||||||
|
ModuleType_GRIPPER, ModuleType_SPEAKER, ModuleType_IMU,
|
||||||
|
ModuleType_DISTANCE_SENSOR, ModuleType_SPLITTER_2, ModuleType_SPLITTER_3,
|
||||||
|
ModuleType_SPLITTER_4, ModuleType_SPLITTER_5, ModuleType_SPLITTER_6,
|
||||||
|
ModuleType_SPLITTER_7, ModuleType_SPLITTER_8};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *const *EnumNamesModuleType() {
|
inline const char *const *EnumNamesModuleType() {
|
||||||
static const char *const names[6] = {"SPLITTER", "SERVO_1", "DC_MOTOR",
|
static const char *const names[18] = {
|
||||||
"BATTERY", "SERVO_2", nullptr};
|
"SPLITTER", "SERVO_1", "DC_MOTOR", "BATTERY", "SERVO_2",
|
||||||
|
"DISPLAY", "GRIPPER", "SPEAKER", "IMU", "DISTANCE_SENSOR",
|
||||||
|
"SPLITTER_2", "SPLITTER_3", "SPLITTER_4", "SPLITTER_5", "SPLITTER_6",
|
||||||
|
"SPLITTER_7", "SPLITTER_8", nullptr};
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *EnumNameModuleType(ModuleType e) {
|
inline const char *EnumNameModuleType(ModuleType e) {
|
||||||
if (::flatbuffers::IsOutRange(e, ModuleType_SPLITTER, ModuleType_SERVO_2))
|
if (::flatbuffers::IsOutRange(e, ModuleType_SPLITTER, ModuleType_SPLITTER_8))
|
||||||
return "";
|
return "";
|
||||||
const size_t index = static_cast<size_t>(e);
|
const size_t index = static_cast<size_t>(e);
|
||||||
return EnumNamesModuleType()[index];
|
return EnumNamesModuleType()[index];
|
||||||
@@ -58,13 +77,14 @@ enum Orientation : int8_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline const Orientation (&EnumValuesOrientation())[4] {
|
inline const Orientation (&EnumValuesOrientation())[4] {
|
||||||
static const Orientation values[] = {Orientation_Deg0, Orientation_Deg90, Orientation_Deg180,
|
static const Orientation values[] = {Orientation_Deg0, Orientation_Deg90,
|
||||||
Orientation_Deg270};
|
Orientation_Deg180, Orientation_Deg270};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *const *EnumNamesOrientation() {
|
inline const char *const *EnumNamesOrientation() {
|
||||||
static const char *const names[5] = {"Deg0", "Deg90", "Deg180", "Deg270", nullptr};
|
static const char *const names[5] = {"Deg0", "Deg90", "Deg180", "Deg270",
|
||||||
|
nullptr};
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +103,8 @@ enum ModuleState : uint8_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline const ModuleState (&EnumValuesModuleState())[2] {
|
inline const ModuleState (&EnumValuesModuleState())[2] {
|
||||||
static const ModuleState values[] = {ModuleState_NONE, ModuleState_MotorState};
|
static const ModuleState values[] = {ModuleState_NONE,
|
||||||
|
ModuleState_MotorState};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,20 +128,22 @@ template <> struct ModuleStateTraits<MotorState> {
|
|||||||
static const ModuleState enum_value = ModuleState_MotorState;
|
static const ModuleState enum_value = ModuleState_MotorState;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool VerifyModuleState(::flatbuffers::Verifier &verifier, const void *obj, ModuleState type);
|
bool VerifyModuleState(::flatbuffers::Verifier &verifier, const void *obj,
|
||||||
bool VerifyModuleStateVector(::flatbuffers::Verifier &verifier,
|
ModuleState type);
|
||||||
|
bool VerifyModuleStateVector(
|
||||||
|
::flatbuffers::Verifier &verifier,
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values,
|
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values,
|
||||||
const ::flatbuffers::Vector<uint8_t> *types);
|
const ::flatbuffers::Vector<uint8_t> *types);
|
||||||
|
|
||||||
struct MotorState FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct MotorState FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
typedef MotorStateBuilder Builder;
|
typedef MotorStateBuilder Builder;
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_ANGLE = 4 };
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
int32_t angle() const {
|
VT_ANGLE = 4
|
||||||
return GetField<int32_t>(VT_ANGLE, 0);
|
};
|
||||||
}
|
int32_t angle() const { return GetField<int32_t>(VT_ANGLE, 0); }
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_ANGLE, 4) &&
|
return VerifyTableStart(verifier) &&
|
||||||
verifier.EndTable();
|
VerifyField<int32_t>(verifier, VT_ANGLE, 4) && verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -131,7 +154,8 @@ struct MotorStateBuilder {
|
|||||||
void add_angle(int32_t angle) {
|
void add_angle(int32_t angle) {
|
||||||
fbb_.AddElement<int32_t>(MotorState::VT_ANGLE, angle, 0);
|
fbb_.AddElement<int32_t>(MotorState::VT_ANGLE, angle, 0);
|
||||||
}
|
}
|
||||||
explicit MotorStateBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit MotorStateBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<MotorState> Finish() {
|
::flatbuffers::Offset<MotorState> Finish() {
|
||||||
@@ -141,8 +165,8 @@ struct MotorStateBuilder {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<MotorState> CreateMotorState(::flatbuffers::FlatBufferBuilder &_fbb,
|
inline ::flatbuffers::Offset<MotorState>
|
||||||
int32_t angle = 0) {
|
CreateMotorState(::flatbuffers::FlatBufferBuilder &_fbb, int32_t angle = 0) {
|
||||||
MotorStateBuilder builder_(_fbb);
|
MotorStateBuilder builder_(_fbb);
|
||||||
builder_.add_angle(angle);
|
builder_.add_angle(angle);
|
||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
@@ -156,14 +180,13 @@ struct RobotModule FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VT_CONFIGURATION_TYPE = 8,
|
VT_CONFIGURATION_TYPE = 8,
|
||||||
VT_CONFIGURATION = 10
|
VT_CONFIGURATION = 10
|
||||||
};
|
};
|
||||||
uint8_t id() const {
|
uint8_t id() const { return GetField<uint8_t>(VT_ID, 0); }
|
||||||
return GetField<uint8_t>(VT_ID, 0);
|
|
||||||
}
|
|
||||||
ModuleType module_type() const {
|
ModuleType module_type() const {
|
||||||
return static_cast<ModuleType>(GetField<int8_t>(VT_MODULE_TYPE, 0));
|
return static_cast<ModuleType>(GetField<int8_t>(VT_MODULE_TYPE, 0));
|
||||||
}
|
}
|
||||||
ModuleState configuration_type() const {
|
ModuleState configuration_type() const {
|
||||||
return static_cast<ModuleState>(GetField<uint8_t>(VT_CONFIGURATION_TYPE, 0));
|
return static_cast<ModuleState>(
|
||||||
|
GetField<uint8_t>(VT_CONFIGURATION_TYPE, 0));
|
||||||
}
|
}
|
||||||
const void *configuration() const {
|
const void *configuration() const {
|
||||||
return GetPointer<const void *>(VT_CONFIGURATION);
|
return GetPointer<const void *>(VT_CONFIGURATION);
|
||||||
@@ -175,7 +198,8 @@ struct RobotModule FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_ID, 1) &&
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<uint8_t>(verifier, VT_ID, 1) &&
|
||||||
VerifyField<int8_t>(verifier, VT_MODULE_TYPE, 1) &&
|
VerifyField<int8_t>(verifier, VT_MODULE_TYPE, 1) &&
|
||||||
VerifyField<uint8_t>(verifier, VT_CONFIGURATION_TYPE, 1) &&
|
VerifyField<uint8_t>(verifier, VT_CONFIGURATION_TYPE, 1) &&
|
||||||
VerifyOffset(verifier, VT_CONFIGURATION) &&
|
VerifyOffset(verifier, VT_CONFIGURATION) &&
|
||||||
@@ -184,7 +208,8 @@ struct RobotModule FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> inline const MotorState *RobotModule::configuration_as<MotorState>() const {
|
template <>
|
||||||
|
inline const MotorState *RobotModule::configuration_as<MotorState>() const {
|
||||||
return configuration_as_MotorState();
|
return configuration_as_MotorState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +221,8 @@ struct RobotModuleBuilder {
|
|||||||
fbb_.AddElement<uint8_t>(RobotModule::VT_ID, id, 0);
|
fbb_.AddElement<uint8_t>(RobotModule::VT_ID, id, 0);
|
||||||
}
|
}
|
||||||
void add_module_type(ModuleType module_type) {
|
void add_module_type(ModuleType module_type) {
|
||||||
fbb_.AddElement<int8_t>(RobotModule::VT_MODULE_TYPE, static_cast<int8_t>(module_type), 0);
|
fbb_.AddElement<int8_t>(RobotModule::VT_MODULE_TYPE,
|
||||||
|
static_cast<int8_t>(module_type), 0);
|
||||||
}
|
}
|
||||||
void add_configuration_type(ModuleState configuration_type) {
|
void add_configuration_type(ModuleState configuration_type) {
|
||||||
fbb_.AddElement<uint8_t>(RobotModule::VT_CONFIGURATION_TYPE,
|
fbb_.AddElement<uint8_t>(RobotModule::VT_CONFIGURATION_TYPE,
|
||||||
@@ -205,7 +231,8 @@ struct RobotModuleBuilder {
|
|||||||
void add_configuration(::flatbuffers::Offset<void> configuration) {
|
void add_configuration(::flatbuffers::Offset<void> configuration) {
|
||||||
fbb_.AddOffset(RobotModule::VT_CONFIGURATION, configuration);
|
fbb_.AddOffset(RobotModule::VT_CONFIGURATION, configuration);
|
||||||
}
|
}
|
||||||
explicit RobotModuleBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit RobotModuleBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<RobotModule> Finish() {
|
::flatbuffers::Offset<RobotModule> Finish() {
|
||||||
@@ -228,8 +255,8 @@ CreateRobotModule(::flatbuffers::FlatBufferBuilder &_fbb, uint8_t id = 0,
|
|||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifyModuleState(::flatbuffers::Verifier &verifier, const void *obj,
|
inline bool VerifyModuleState(::flatbuffers::Verifier &verifier,
|
||||||
ModuleState type) {
|
const void *obj, ModuleState type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ModuleState_NONE: {
|
case ModuleState_NONE: {
|
||||||
return true;
|
return true;
|
||||||
@@ -243,8 +270,8 @@ inline bool VerifyModuleState(::flatbuffers::Verifier &verifier, const void *obj
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool VerifyModuleStateVector(
|
||||||
VerifyModuleStateVector(::flatbuffers::Verifier &verifier,
|
::flatbuffers::Verifier &verifier,
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values,
|
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values,
|
||||||
const ::flatbuffers::Vector<uint8_t> *types) {
|
const ::flatbuffers::Vector<uint8_t> *types) {
|
||||||
if (!values || !types)
|
if (!values || !types)
|
||||||
@@ -252,7 +279,8 @@ VerifyModuleStateVector(::flatbuffers::Verifier &verifier,
|
|||||||
if (values->size() != types->size())
|
if (values->size() != types->size())
|
||||||
return false;
|
return false;
|
||||||
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
||||||
if (!VerifyModuleState(verifier, values->Get(i), types->GetEnum<ModuleState>(i))) {
|
if (!VerifyModuleState(verifier, values->Get(i),
|
||||||
|
types->GetEnum<ModuleState>(i))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,7 +299,8 @@ inline bool VerifyRobotModuleBuffer(::flatbuffers::Verifier &verifier) {
|
|||||||
return verifier.VerifyBuffer<RobotModule>(nullptr);
|
return verifier.VerifyBuffer<RobotModule>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifySizePrefixedRobotModuleBuffer(::flatbuffers::Verifier &verifier) {
|
inline bool
|
||||||
|
VerifySizePrefixedRobotModuleBuffer(::flatbuffers::Verifier &verifier) {
|
||||||
return verifier.VerifySizePrefixedBuffer<RobotModule>(nullptr);
|
return verifier.VerifySizePrefixedBuffer<RobotModule>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +309,8 @@ inline void FinishRobotModuleBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
|||||||
fbb.Finish(root);
|
fbb.Finish(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FinishSizePrefixedRobotModuleBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
inline void
|
||||||
|
FinishSizePrefixedRobotModuleBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
::flatbuffers::Offset<RobotModule> root) {
|
::flatbuffers::Offset<RobotModule> root) {
|
||||||
fbb.FinishSizePrefixed(root);
|
fbb.FinishSizePrefixed(root);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ namespace Messaging {
|
|||||||
struct TargetAngle;
|
struct TargetAngle;
|
||||||
struct TargetAngleBuilder;
|
struct TargetAngleBuilder;
|
||||||
|
|
||||||
|
struct CurrentText;
|
||||||
|
struct CurrentTextBuilder;
|
||||||
|
|
||||||
struct CurrentAngle;
|
struct CurrentAngle;
|
||||||
struct CurrentAngleBuilder;
|
struct CurrentAngleBuilder;
|
||||||
|
|
||||||
@@ -27,23 +30,26 @@ enum SensorValue : uint8_t {
|
|||||||
SensorValue_NONE = 0,
|
SensorValue_NONE = 0,
|
||||||
SensorValue_TargetAngle = 1,
|
SensorValue_TargetAngle = 1,
|
||||||
SensorValue_CurrentAngle = 2,
|
SensorValue_CurrentAngle = 2,
|
||||||
|
SensorValue_CurrentText = 3,
|
||||||
SensorValue_MIN = SensorValue_NONE,
|
SensorValue_MIN = SensorValue_NONE,
|
||||||
SensorValue_MAX = SensorValue_CurrentAngle
|
SensorValue_MAX = SensorValue_CurrentText
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const SensorValue (&EnumValuesSensorValue())[3] {
|
inline const SensorValue (&EnumValuesSensorValue())[4] {
|
||||||
static const SensorValue values[] = {SensorValue_NONE, SensorValue_TargetAngle,
|
static const SensorValue values[] = {
|
||||||
SensorValue_CurrentAngle};
|
SensorValue_NONE, SensorValue_TargetAngle, SensorValue_CurrentAngle,
|
||||||
|
SensorValue_CurrentText};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *const *EnumNamesSensorValue() {
|
inline const char *const *EnumNamesSensorValue() {
|
||||||
static const char *const names[4] = {"NONE", "TargetAngle", "CurrentAngle", nullptr};
|
static const char *const names[5] = {"NONE", "TargetAngle", "CurrentAngle",
|
||||||
|
"CurrentText", nullptr};
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *EnumNameSensorValue(SensorValue e) {
|
inline const char *EnumNameSensorValue(SensorValue e) {
|
||||||
if (::flatbuffers::IsOutRange(e, SensorValue_NONE, SensorValue_CurrentAngle))
|
if (::flatbuffers::IsOutRange(e, SensorValue_NONE, SensorValue_CurrentText))
|
||||||
return "";
|
return "";
|
||||||
const size_t index = static_cast<size_t>(e);
|
const size_t index = static_cast<size_t>(e);
|
||||||
return EnumNamesSensorValue()[index];
|
return EnumNamesSensorValue()[index];
|
||||||
@@ -61,20 +67,26 @@ template <> struct SensorValueTraits<Messaging::CurrentAngle> {
|
|||||||
static const SensorValue enum_value = SensorValue_CurrentAngle;
|
static const SensorValue enum_value = SensorValue_CurrentAngle;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool VerifySensorValue(::flatbuffers::Verifier &verifier, const void *obj, SensorValue type);
|
template <> struct SensorValueTraits<Messaging::CurrentText> {
|
||||||
bool VerifySensorValueVector(::flatbuffers::Verifier &verifier,
|
static const SensorValue enum_value = SensorValue_CurrentText;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool VerifySensorValue(::flatbuffers::Verifier &verifier, const void *obj,
|
||||||
|
SensorValue type);
|
||||||
|
bool VerifySensorValueVector(
|
||||||
|
::flatbuffers::Verifier &verifier,
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values,
|
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values,
|
||||||
const ::flatbuffers::Vector<uint8_t> *types);
|
const ::flatbuffers::Vector<uint8_t> *types);
|
||||||
|
|
||||||
struct TargetAngle FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct TargetAngle FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
typedef TargetAngleBuilder Builder;
|
typedef TargetAngleBuilder Builder;
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUE = 4 };
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
int16_t value() const {
|
VT_VALUE = 4
|
||||||
return GetField<int16_t>(VT_VALUE, 0);
|
};
|
||||||
}
|
int16_t value() const { return GetField<int16_t>(VT_VALUE, 0); }
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyField<int16_t>(verifier, VT_VALUE, 2) &&
|
return VerifyTableStart(verifier) &&
|
||||||
verifier.EndTable();
|
VerifyField<int16_t>(verifier, VT_VALUE, 2) && verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -85,7 +97,8 @@ struct TargetAngleBuilder {
|
|||||||
void add_value(int16_t value) {
|
void add_value(int16_t value) {
|
||||||
fbb_.AddElement<int16_t>(TargetAngle::VT_VALUE, value, 0);
|
fbb_.AddElement<int16_t>(TargetAngle::VT_VALUE, value, 0);
|
||||||
}
|
}
|
||||||
explicit TargetAngleBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit TargetAngleBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<TargetAngle> Finish() {
|
::flatbuffers::Offset<TargetAngle> Finish() {
|
||||||
@@ -95,22 +108,69 @@ struct TargetAngleBuilder {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<TargetAngle> CreateTargetAngle(::flatbuffers::FlatBufferBuilder &_fbb,
|
inline ::flatbuffers::Offset<TargetAngle>
|
||||||
int16_t value = 0) {
|
CreateTargetAngle(::flatbuffers::FlatBufferBuilder &_fbb, int16_t value = 0) {
|
||||||
TargetAngleBuilder builder_(_fbb);
|
TargetAngleBuilder builder_(_fbb);
|
||||||
builder_.add_value(value);
|
builder_.add_value(value);
|
||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CurrentAngle FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct CurrentText FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
typedef CurrentAngleBuilder Builder;
|
typedef CurrentTextBuilder Builder;
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUE = 4 };
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
int16_t value() const {
|
VT_VALUE = 4
|
||||||
return GetField<int16_t>(VT_VALUE, 0);
|
};
|
||||||
|
const ::flatbuffers::String *value() const {
|
||||||
|
return GetPointer<const ::flatbuffers::String *>(VT_VALUE);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyField<int16_t>(verifier, VT_VALUE, 2) &&
|
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VALUE) &&
|
||||||
verifier.EndTable();
|
verifier.VerifyString(value()) && verifier.EndTable();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CurrentTextBuilder {
|
||||||
|
typedef CurrentText Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_value(::flatbuffers::Offset<::flatbuffers::String> value) {
|
||||||
|
fbb_.AddOffset(CurrentText::VT_VALUE, value);
|
||||||
|
}
|
||||||
|
explicit CurrentTextBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<CurrentText> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<CurrentText>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<CurrentText>
|
||||||
|
CreateCurrentText(::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::String> value = 0) {
|
||||||
|
CurrentTextBuilder builder_(_fbb);
|
||||||
|
builder_.add_value(value);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<CurrentText>
|
||||||
|
CreateCurrentTextDirect(::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
const char *value = nullptr) {
|
||||||
|
auto value__ = value ? _fbb.CreateString(value) : 0;
|
||||||
|
return Messaging::CreateCurrentText(_fbb, value__);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CurrentAngle FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef CurrentAngleBuilder Builder;
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_VALUE = 4
|
||||||
|
};
|
||||||
|
int16_t value() const { return GetField<int16_t>(VT_VALUE, 0); }
|
||||||
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<int16_t>(verifier, VT_VALUE, 2) && verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -121,7 +181,8 @@ struct CurrentAngleBuilder {
|
|||||||
void add_value(int16_t value) {
|
void add_value(int16_t value) {
|
||||||
fbb_.AddElement<int16_t>(CurrentAngle::VT_VALUE, value, 0);
|
fbb_.AddElement<int16_t>(CurrentAngle::VT_VALUE, value, 0);
|
||||||
}
|
}
|
||||||
explicit CurrentAngleBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit CurrentAngleBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<CurrentAngle> Finish() {
|
::flatbuffers::Offset<CurrentAngle> Finish() {
|
||||||
@@ -148,13 +209,17 @@ struct SensorMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_VALUES_TYPE);
|
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_VALUES_TYPE);
|
||||||
}
|
}
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *>(VT_VALUES);
|
return GetPointer<
|
||||||
|
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *>(VT_VALUES);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VALUES_TYPE) &&
|
return VerifyTableStart(verifier) &&
|
||||||
verifier.VerifyVector(values_type()) && VerifyOffset(verifier, VT_VALUES) &&
|
VerifyOffset(verifier, VT_VALUES_TYPE) &&
|
||||||
|
verifier.VerifyVector(values_type()) &&
|
||||||
|
VerifyOffset(verifier, VT_VALUES) &&
|
||||||
verifier.VerifyVector(values()) &&
|
verifier.VerifyVector(values()) &&
|
||||||
VerifySensorValueVector(verifier, values(), values_type()) && verifier.EndTable();
|
VerifySensorValueVector(verifier, values(), values_type()) &&
|
||||||
|
verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -162,14 +227,17 @@ struct SensorMessageBuilder {
|
|||||||
typedef SensorMessage Table;
|
typedef SensorMessage Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
::flatbuffers::uoffset_t start_;
|
::flatbuffers::uoffset_t start_;
|
||||||
void add_values_type(::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> values_type) {
|
void add_values_type(
|
||||||
|
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> values_type) {
|
||||||
fbb_.AddOffset(SensorMessage::VT_VALUES_TYPE, values_type);
|
fbb_.AddOffset(SensorMessage::VT_VALUES_TYPE, values_type);
|
||||||
}
|
}
|
||||||
void
|
void add_values(
|
||||||
add_values(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<void>>> values) {
|
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<void>>>
|
||||||
|
values) {
|
||||||
fbb_.AddOffset(SensorMessage::VT_VALUES, values);
|
fbb_.AddOffset(SensorMessage::VT_VALUES, values);
|
||||||
}
|
}
|
||||||
explicit SensorMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit SensorMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<SensorMessage> Finish() {
|
::flatbuffers::Offset<SensorMessage> Finish() {
|
||||||
@@ -182,24 +250,27 @@ struct SensorMessageBuilder {
|
|||||||
inline ::flatbuffers::Offset<SensorMessage> CreateSensorMessage(
|
inline ::flatbuffers::Offset<SensorMessage> CreateSensorMessage(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> values_type = 0,
|
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> values_type = 0,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<void>>> values = 0) {
|
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<void>>>
|
||||||
|
values = 0) {
|
||||||
SensorMessageBuilder builder_(_fbb);
|
SensorMessageBuilder builder_(_fbb);
|
||||||
builder_.add_values(values);
|
builder_.add_values(values);
|
||||||
builder_.add_values_type(values_type);
|
builder_.add_values_type(values_type);
|
||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<SensorMessage>
|
inline ::flatbuffers::Offset<SensorMessage> CreateSensorMessageDirect(
|
||||||
CreateSensorMessageDirect(::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
const std::vector<uint8_t> *values_type = nullptr,
|
const std::vector<uint8_t> *values_type = nullptr,
|
||||||
const std::vector<::flatbuffers::Offset<void>> *values = nullptr) {
|
const std::vector<::flatbuffers::Offset<void>> *values = nullptr) {
|
||||||
auto values_type__ = values_type ? _fbb.CreateVector<uint8_t>(*values_type) : 0;
|
auto values_type__ =
|
||||||
auto values__ = values ? _fbb.CreateVector<::flatbuffers::Offset<void>>(*values) : 0;
|
values_type ? _fbb.CreateVector<uint8_t>(*values_type) : 0;
|
||||||
|
auto values__ =
|
||||||
|
values ? _fbb.CreateVector<::flatbuffers::Offset<void>>(*values) : 0;
|
||||||
return Messaging::CreateSensorMessage(_fbb, values_type__, values__);
|
return Messaging::CreateSensorMessage(_fbb, values_type__, values__);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifySensorValue(::flatbuffers::Verifier &verifier, const void *obj,
|
inline bool VerifySensorValue(::flatbuffers::Verifier &verifier,
|
||||||
SensorValue type) {
|
const void *obj, SensorValue type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SensorValue_NONE: {
|
case SensorValue_NONE: {
|
||||||
return true;
|
return true;
|
||||||
@@ -212,13 +283,17 @@ inline bool VerifySensorValue(::flatbuffers::Verifier &verifier, const void *obj
|
|||||||
auto ptr = reinterpret_cast<const Messaging::CurrentAngle *>(obj);
|
auto ptr = reinterpret_cast<const Messaging::CurrentAngle *>(obj);
|
||||||
return verifier.VerifyTable(ptr);
|
return verifier.VerifyTable(ptr);
|
||||||
}
|
}
|
||||||
|
case SensorValue_CurrentText: {
|
||||||
|
auto ptr = reinterpret_cast<const Messaging::CurrentText *>(obj);
|
||||||
|
return verifier.VerifyTable(ptr);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool VerifySensorValueVector(
|
||||||
VerifySensorValueVector(::flatbuffers::Verifier &verifier,
|
::flatbuffers::Verifier &verifier,
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values,
|
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values,
|
||||||
const ::flatbuffers::Vector<uint8_t> *types) {
|
const ::flatbuffers::Vector<uint8_t> *types) {
|
||||||
if (!values || !types)
|
if (!values || !types)
|
||||||
@@ -226,7 +301,8 @@ VerifySensorValueVector(::flatbuffers::Verifier &verifier,
|
|||||||
if (values->size() != types->size())
|
if (values->size() != types->size())
|
||||||
return false;
|
return false;
|
||||||
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
||||||
if (!VerifySensorValue(verifier, values->Get(i), types->GetEnum<SensorValue>(i))) {
|
if (!VerifySensorValue(verifier, values->Get(i),
|
||||||
|
types->GetEnum<SensorValue>(i))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,7 +313,8 @@ inline const Messaging::SensorMessage *GetSensorMessage(const void *buf) {
|
|||||||
return ::flatbuffers::GetRoot<Messaging::SensorMessage>(buf);
|
return ::flatbuffers::GetRoot<Messaging::SensorMessage>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Messaging::SensorMessage *GetSizePrefixedSensorMessage(const void *buf) {
|
inline const Messaging::SensorMessage *
|
||||||
|
GetSizePrefixedSensorMessage(const void *buf) {
|
||||||
return ::flatbuffers::GetSizePrefixedRoot<Messaging::SensorMessage>(buf);
|
return ::flatbuffers::GetSizePrefixedRoot<Messaging::SensorMessage>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,17 +322,19 @@ inline bool VerifySensorMessageBuffer(::flatbuffers::Verifier &verifier) {
|
|||||||
return verifier.VerifyBuffer<Messaging::SensorMessage>(nullptr);
|
return verifier.VerifyBuffer<Messaging::SensorMessage>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifySizePrefixedSensorMessageBuffer(::flatbuffers::Verifier &verifier) {
|
inline bool
|
||||||
|
VerifySizePrefixedSensorMessageBuffer(::flatbuffers::Verifier &verifier) {
|
||||||
return verifier.VerifySizePrefixedBuffer<Messaging::SensorMessage>(nullptr);
|
return verifier.VerifySizePrefixedBuffer<Messaging::SensorMessage>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FinishSensorMessageBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
inline void FinishSensorMessageBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
::flatbuffers::Offset<Messaging::SensorMessage> root) {
|
::flatbuffers::Offset<Messaging::SensorMessage> root) {
|
||||||
fbb.Finish(root);
|
fbb.Finish(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void FinishSizePrefixedSensorMessageBuffer(
|
||||||
FinishSizePrefixedSensorMessageBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
::flatbuffers::Offset<Messaging::SensorMessage> root) {
|
::flatbuffers::Offset<Messaging::SensorMessage> root) {
|
||||||
fbb.FinishSizePrefixed(root);
|
fbb.FinishSizePrefixed(root);
|
||||||
}
|
}
|
||||||
|
|||||||
102
include/flatbuffers_generated/TextControlMessage_generated.h
Normal file
102
include/flatbuffers_generated/TextControlMessage_generated.h
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_TEXTCONTROLMESSAGE_MESSAGING_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_TEXTCONTROLMESSAGE_MESSAGING_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");
|
||||||
|
|
||||||
|
namespace Messaging {
|
||||||
|
|
||||||
|
struct TextControlMessage;
|
||||||
|
struct TextControlMessageBuilder;
|
||||||
|
|
||||||
|
struct TextControlMessage FLATBUFFERS_FINAL_CLASS
|
||||||
|
: private ::flatbuffers::Table {
|
||||||
|
typedef TextControlMessageBuilder Builder;
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_MESSAGE = 4
|
||||||
|
};
|
||||||
|
const ::flatbuffers::String *message() const {
|
||||||
|
return GetPointer<const ::flatbuffers::String *>(VT_MESSAGE);
|
||||||
|
}
|
||||||
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_MESSAGE) &&
|
||||||
|
verifier.VerifyString(message()) && verifier.EndTable();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TextControlMessageBuilder {
|
||||||
|
typedef TextControlMessage Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_message(::flatbuffers::Offset<::flatbuffers::String> message) {
|
||||||
|
fbb_.AddOffset(TextControlMessage::VT_MESSAGE, message);
|
||||||
|
}
|
||||||
|
explicit TextControlMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<TextControlMessage> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<TextControlMessage>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<TextControlMessage> CreateTextControlMessage(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::String> message = 0) {
|
||||||
|
TextControlMessageBuilder builder_(_fbb);
|
||||||
|
builder_.add_message(message);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<TextControlMessage>
|
||||||
|
CreateTextControlMessageDirect(::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
const char *message = nullptr) {
|
||||||
|
auto message__ = message ? _fbb.CreateString(message) : 0;
|
||||||
|
return Messaging::CreateTextControlMessage(_fbb, message__);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Messaging::TextControlMessage *
|
||||||
|
GetTextControlMessage(const void *buf) {
|
||||||
|
return ::flatbuffers::GetRoot<Messaging::TextControlMessage>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Messaging::TextControlMessage *
|
||||||
|
GetSizePrefixedTextControlMessage(const void *buf) {
|
||||||
|
return ::flatbuffers::GetSizePrefixedRoot<Messaging::TextControlMessage>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool VerifyTextControlMessageBuffer(::flatbuffers::Verifier &verifier) {
|
||||||
|
return verifier.VerifyBuffer<Messaging::TextControlMessage>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
VerifySizePrefixedTextControlMessageBuffer(::flatbuffers::Verifier &verifier) {
|
||||||
|
return verifier.VerifySizePrefixedBuffer<Messaging::TextControlMessage>(
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishTextControlMessageBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Messaging::TextControlMessage> root) {
|
||||||
|
fbb.Finish(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishSizePrefixedTextControlMessageBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Messaging::TextControlMessage> root) {
|
||||||
|
fbb.FinishSizePrefixed(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Messaging
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_TEXTCONTROLMESSAGE_MESSAGING_H_
|
||||||
@@ -27,7 +27,8 @@ enum ConnectionType : int8_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline const ConnectionType (&EnumValuesConnectionType())[2] {
|
inline const ConnectionType (&EnumValuesConnectionType())[2] {
|
||||||
static const ConnectionType values[] = {ConnectionType_DIRECT, ConnectionType_HOP};
|
static const ConnectionType values[] = {ConnectionType_DIRECT,
|
||||||
|
ConnectionType_HOP};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,32 +56,30 @@ struct TopologyMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VT_LEADER = 16,
|
VT_LEADER = 16,
|
||||||
VT_FIRMWARE = 18
|
VT_FIRMWARE = 18
|
||||||
};
|
};
|
||||||
uint8_t module_id() const {
|
uint8_t module_id() const { return GetField<uint8_t>(VT_MODULE_ID, 0); }
|
||||||
return GetField<uint8_t>(VT_MODULE_ID, 0);
|
|
||||||
}
|
|
||||||
ModuleType module_type() const {
|
ModuleType module_type() const {
|
||||||
return static_cast<ModuleType>(GetField<int8_t>(VT_MODULE_TYPE, 0));
|
return static_cast<ModuleType>(GetField<int8_t>(VT_MODULE_TYPE, 0));
|
||||||
}
|
}
|
||||||
uint8_t num_channels() const {
|
uint8_t num_channels() const { return GetField<uint8_t>(VT_NUM_CHANNELS, 0); }
|
||||||
return GetField<uint8_t>(VT_NUM_CHANNELS, 0);
|
|
||||||
}
|
|
||||||
const ::flatbuffers::Vector<uint8_t> *channel_to_module() const {
|
const ::flatbuffers::Vector<uint8_t> *channel_to_module() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_CHANNEL_TO_MODULE);
|
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(
|
||||||
|
VT_CHANNEL_TO_MODULE);
|
||||||
}
|
}
|
||||||
const ::flatbuffers::Vector<int8_t> *channel_to_orientation() const {
|
const ::flatbuffers::Vector<int8_t> *channel_to_orientation() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<int8_t> *>(VT_CHANNEL_TO_ORIENTATION);
|
return GetPointer<const ::flatbuffers::Vector<int8_t> *>(
|
||||||
|
VT_CHANNEL_TO_ORIENTATION);
|
||||||
}
|
}
|
||||||
Messaging::ConnectionType connection() const {
|
Messaging::ConnectionType connection() const {
|
||||||
return static_cast<Messaging::ConnectionType>(GetField<int8_t>(VT_CONNECTION, 0));
|
return static_cast<Messaging::ConnectionType>(
|
||||||
}
|
GetField<int8_t>(VT_CONNECTION, 0));
|
||||||
uint8_t leader() const {
|
|
||||||
return GetField<uint8_t>(VT_LEADER, 0);
|
|
||||||
}
|
}
|
||||||
|
uint8_t leader() const { return GetField<uint8_t>(VT_LEADER, 0); }
|
||||||
const ::flatbuffers::String *firmware() const {
|
const ::flatbuffers::String *firmware() const {
|
||||||
return GetPointer<const ::flatbuffers::String *>(VT_FIRMWARE);
|
return GetPointer<const ::flatbuffers::String *>(VT_FIRMWARE);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_MODULE_ID, 1) &&
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<uint8_t>(verifier, VT_MODULE_ID, 1) &&
|
||||||
VerifyField<int8_t>(verifier, VT_MODULE_TYPE, 1) &&
|
VerifyField<int8_t>(verifier, VT_MODULE_TYPE, 1) &&
|
||||||
VerifyField<uint8_t>(verifier, VT_NUM_CHANNELS, 1) &&
|
VerifyField<uint8_t>(verifier, VT_NUM_CHANNELS, 1) &&
|
||||||
VerifyOffset(verifier, VT_CHANNEL_TO_MODULE) &&
|
VerifyOffset(verifier, VT_CHANNEL_TO_MODULE) &&
|
||||||
@@ -89,8 +88,8 @@ struct TopologyMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
verifier.VerifyVector(channel_to_orientation()) &&
|
verifier.VerifyVector(channel_to_orientation()) &&
|
||||||
VerifyField<int8_t>(verifier, VT_CONNECTION, 1) &&
|
VerifyField<int8_t>(verifier, VT_CONNECTION, 1) &&
|
||||||
VerifyField<uint8_t>(verifier, VT_LEADER, 1) &&
|
VerifyField<uint8_t>(verifier, VT_LEADER, 1) &&
|
||||||
VerifyOffset(verifier, VT_FIRMWARE) && verifier.VerifyString(firmware()) &&
|
VerifyOffset(verifier, VT_FIRMWARE) &&
|
||||||
verifier.EndTable();
|
verifier.VerifyString(firmware()) && verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -102,22 +101,25 @@ struct TopologyMessageBuilder {
|
|||||||
fbb_.AddElement<uint8_t>(TopologyMessage::VT_MODULE_ID, module_id, 0);
|
fbb_.AddElement<uint8_t>(TopologyMessage::VT_MODULE_ID, module_id, 0);
|
||||||
}
|
}
|
||||||
void add_module_type(ModuleType module_type) {
|
void add_module_type(ModuleType module_type) {
|
||||||
fbb_.AddElement<int8_t>(TopologyMessage::VT_MODULE_TYPE, static_cast<int8_t>(module_type),
|
fbb_.AddElement<int8_t>(TopologyMessage::VT_MODULE_TYPE,
|
||||||
0);
|
static_cast<int8_t>(module_type), 0);
|
||||||
}
|
}
|
||||||
void add_num_channels(uint8_t num_channels) {
|
void add_num_channels(uint8_t num_channels) {
|
||||||
fbb_.AddElement<uint8_t>(TopologyMessage::VT_NUM_CHANNELS, num_channels, 0);
|
fbb_.AddElement<uint8_t>(TopologyMessage::VT_NUM_CHANNELS, num_channels, 0);
|
||||||
}
|
}
|
||||||
void
|
void add_channel_to_module(
|
||||||
add_channel_to_module(::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> channel_to_module) {
|
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> channel_to_module) {
|
||||||
fbb_.AddOffset(TopologyMessage::VT_CHANNEL_TO_MODULE, channel_to_module);
|
fbb_.AddOffset(TopologyMessage::VT_CHANNEL_TO_MODULE, channel_to_module);
|
||||||
}
|
}
|
||||||
void add_channel_to_orientation(
|
void add_channel_to_orientation(
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<int8_t>> channel_to_orientation) {
|
::flatbuffers::Offset<::flatbuffers::Vector<int8_t>>
|
||||||
fbb_.AddOffset(TopologyMessage::VT_CHANNEL_TO_ORIENTATION, channel_to_orientation);
|
channel_to_orientation) {
|
||||||
|
fbb_.AddOffset(TopologyMessage::VT_CHANNEL_TO_ORIENTATION,
|
||||||
|
channel_to_orientation);
|
||||||
}
|
}
|
||||||
void add_connection(Messaging::ConnectionType connection) {
|
void add_connection(Messaging::ConnectionType connection) {
|
||||||
fbb_.AddElement<int8_t>(TopologyMessage::VT_CONNECTION, static_cast<int8_t>(connection), 0);
|
fbb_.AddElement<int8_t>(TopologyMessage::VT_CONNECTION,
|
||||||
|
static_cast<int8_t>(connection), 0);
|
||||||
}
|
}
|
||||||
void add_leader(uint8_t leader) {
|
void add_leader(uint8_t leader) {
|
||||||
fbb_.AddElement<uint8_t>(TopologyMessage::VT_LEADER, leader, 0);
|
fbb_.AddElement<uint8_t>(TopologyMessage::VT_LEADER, leader, 0);
|
||||||
@@ -125,7 +127,8 @@ struct TopologyMessageBuilder {
|
|||||||
void add_firmware(::flatbuffers::Offset<::flatbuffers::String> firmware) {
|
void add_firmware(::flatbuffers::Offset<::flatbuffers::String> firmware) {
|
||||||
fbb_.AddOffset(TopologyMessage::VT_FIRMWARE, firmware);
|
fbb_.AddOffset(TopologyMessage::VT_FIRMWARE, firmware);
|
||||||
}
|
}
|
||||||
explicit TopologyMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
|
explicit TopologyMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
::flatbuffers::Offset<TopologyMessage> Finish() {
|
::flatbuffers::Offset<TopologyMessage> Finish() {
|
||||||
@@ -139,8 +142,10 @@ inline ::flatbuffers::Offset<TopologyMessage> CreateTopologyMessage(
|
|||||||
::flatbuffers::FlatBufferBuilder &_fbb, uint8_t module_id = 0,
|
::flatbuffers::FlatBufferBuilder &_fbb, uint8_t module_id = 0,
|
||||||
ModuleType module_type = ModuleType_SPLITTER, uint8_t num_channels = 0,
|
ModuleType module_type = ModuleType_SPLITTER, uint8_t num_channels = 0,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> channel_to_module = 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>>
|
||||||
Messaging::ConnectionType connection = Messaging::ConnectionType_DIRECT, uint8_t leader = 0,
|
channel_to_orientation = 0,
|
||||||
|
Messaging::ConnectionType connection = Messaging::ConnectionType_DIRECT,
|
||||||
|
uint8_t leader = 0,
|
||||||
::flatbuffers::Offset<::flatbuffers::String> firmware = 0) {
|
::flatbuffers::Offset<::flatbuffers::String> firmware = 0) {
|
||||||
TopologyMessageBuilder builder_(_fbb);
|
TopologyMessageBuilder builder_(_fbb);
|
||||||
builder_.add_firmware(firmware);
|
builder_.add_firmware(firmware);
|
||||||
@@ -154,8 +159,8 @@ inline ::flatbuffers::Offset<TopologyMessage> CreateTopologyMessage(
|
|||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<TopologyMessage>
|
inline ::flatbuffers::Offset<TopologyMessage> CreateTopologyMessageDirect(
|
||||||
CreateTopologyMessageDirect(::flatbuffers::FlatBufferBuilder &_fbb, uint8_t module_id = 0,
|
::flatbuffers::FlatBufferBuilder &_fbb, uint8_t module_id = 0,
|
||||||
ModuleType module_type = ModuleType_SPLITTER, uint8_t num_channels = 0,
|
ModuleType module_type = ModuleType_SPLITTER, uint8_t num_channels = 0,
|
||||||
const std::vector<uint8_t> *channel_to_module = nullptr,
|
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,
|
||||||
@@ -164,18 +169,21 @@ CreateTopologyMessageDirect(::flatbuffers::FlatBufferBuilder &_fbb, uint8_t modu
|
|||||||
auto channel_to_module__ =
|
auto channel_to_module__ =
|
||||||
channel_to_module ? _fbb.CreateVector<uint8_t>(*channel_to_module) : 0;
|
channel_to_module ? _fbb.CreateVector<uint8_t>(*channel_to_module) : 0;
|
||||||
auto channel_to_orientation__ =
|
auto channel_to_orientation__ =
|
||||||
channel_to_orientation ? _fbb.CreateVector<int8_t>(*channel_to_orientation) : 0;
|
channel_to_orientation
|
||||||
|
? _fbb.CreateVector<int8_t>(*channel_to_orientation)
|
||||||
|
: 0;
|
||||||
auto firmware__ = firmware ? _fbb.CreateString(firmware) : 0;
|
auto firmware__ = firmware ? _fbb.CreateString(firmware) : 0;
|
||||||
return Messaging::CreateTopologyMessage(_fbb, module_id, module_type, num_channels,
|
return Messaging::CreateTopologyMessage(
|
||||||
channel_to_module__, channel_to_orientation__,
|
_fbb, module_id, module_type, num_channels, channel_to_module__,
|
||||||
connection, leader, firmware__);
|
channel_to_orientation__, connection, leader, firmware__);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Messaging::TopologyMessage *GetTopologyMessage(const void *buf) {
|
inline const Messaging::TopologyMessage *GetTopologyMessage(const void *buf) {
|
||||||
return ::flatbuffers::GetRoot<Messaging::TopologyMessage>(buf);
|
return ::flatbuffers::GetRoot<Messaging::TopologyMessage>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Messaging::TopologyMessage *GetSizePrefixedTopologyMessage(const void *buf) {
|
inline const Messaging::TopologyMessage *
|
||||||
|
GetSizePrefixedTopologyMessage(const void *buf) {
|
||||||
return ::flatbuffers::GetSizePrefixedRoot<Messaging::TopologyMessage>(buf);
|
return ::flatbuffers::GetSizePrefixedRoot<Messaging::TopologyMessage>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,17 +191,19 @@ inline bool VerifyTopologyMessageBuffer(::flatbuffers::Verifier &verifier) {
|
|||||||
return verifier.VerifyBuffer<Messaging::TopologyMessage>(nullptr);
|
return verifier.VerifyBuffer<Messaging::TopologyMessage>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifySizePrefixedTopologyMessageBuffer(::flatbuffers::Verifier &verifier) {
|
inline bool
|
||||||
|
VerifySizePrefixedTopologyMessageBuffer(::flatbuffers::Verifier &verifier) {
|
||||||
return verifier.VerifySizePrefixedBuffer<Messaging::TopologyMessage>(nullptr);
|
return verifier.VerifySizePrefixedBuffer<Messaging::TopologyMessage>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FinishTopologyMessageBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
inline void FinishTopologyMessageBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
::flatbuffers::Offset<Messaging::TopologyMessage> root) {
|
::flatbuffers::Offset<Messaging::TopologyMessage> root) {
|
||||||
fbb.Finish(root);
|
fbb.Finish(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void FinishSizePrefixedTopologyMessageBuffer(
|
||||||
FinishSizePrefixedTopologyMessageBuffer(::flatbuffers::FlatBufferBuilder &fbb,
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
::flatbuffers::Offset<Messaging::TopologyMessage> root) {
|
::flatbuffers::Offset<Messaging::TopologyMessage> root) {
|
||||||
fbb.FinishSizePrefixed(root);
|
fbb.FinishSizePrefixed(root);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ LIB_API void cleanup();
|
|||||||
LIB_API int send_angle_control(int module_id, int angle);
|
LIB_API int send_angle_control(int module_id, int angle);
|
||||||
LIB_API char *get_configuration(int *size_out);
|
LIB_API char *get_configuration(int *size_out);
|
||||||
|
|
||||||
LIB_API bool control_sentry_init(const char *dsn, const char *environment, const char *release);
|
LIB_API bool control_sentry_init(const char *dsn, const char *environment,
|
||||||
LIB_API void control_sentry_set_app_info(const char *app_name, const char *app_version,
|
const char *release);
|
||||||
|
LIB_API void control_sentry_set_app_info(const char *app_name,
|
||||||
|
const char *app_version,
|
||||||
const char *build_number);
|
const char *build_number);
|
||||||
LIB_API void control_sentry_shutdown(void);
|
LIB_API void control_sentry_shutdown(void);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ class RobotController {
|
|||||||
: m_messaging_interface(std::make_unique<MessagingInterface>()),
|
: m_messaging_interface(std::make_unique<MessagingInterface>()),
|
||||||
m_metadata_loop(std::thread(&RobotController::metadata_loop, this)),
|
m_metadata_loop(std::thread(&RobotController::metadata_loop, this)),
|
||||||
m_transmit_loop(std::thread(&RobotController::transmit_loop, this)),
|
m_transmit_loop(std::thread(&RobotController::transmit_loop, this)),
|
||||||
m_configuration_loop(std::thread(&RobotController::configuration_loop, this)),
|
m_configuration_loop(
|
||||||
|
std::thread(&RobotController::configuration_loop, this)),
|
||||||
m_sensor_loop(std::thread(&RobotController::sensor_loop, this)),
|
m_sensor_loop(std::thread(&RobotController::sensor_loop, this)),
|
||||||
m_expiry_looop(std::thread(&RobotController::expiry_loop, this)) {
|
m_expiry_looop(std::thread(&RobotController::expiry_loop, this)) {
|
||||||
m_logger = spdlog::basic_logger_mt("default_logger", "libcontrol.log");
|
m_logger = spdlog::basic_logger_mt("default_logger", "libcontrol.log");
|
||||||
@@ -103,7 +104,8 @@ class RobotController {
|
|||||||
private:
|
private:
|
||||||
std::shared_ptr<spdlog::logger> m_logger;
|
std::shared_ptr<spdlog::logger> m_logger;
|
||||||
std::unordered_map<uint8_t, std::shared_ptr<Module>> m_id_to_module{};
|
std::unordered_map<uint8_t, std::shared_ptr<Module>> m_id_to_module{};
|
||||||
std::unordered_map<uint8_t, std::vector<Flatbuffers::ModuleConnectionInstance>>
|
std::unordered_map<uint8_t,
|
||||||
|
std::vector<Flatbuffers::ModuleConnectionInstance>>
|
||||||
m_connection_map{};
|
m_connection_map{};
|
||||||
std::shared_mutex m_module_lock{};
|
std::shared_mutex m_module_lock{};
|
||||||
std::shared_mutex m_connection_lock{};
|
std::shared_mutex m_connection_lock{};
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ class Event;
|
|||||||
|
|
||||||
class CallbackHandle {
|
class CallbackHandle {
|
||||||
public:
|
public:
|
||||||
CallbackHandle(Event *evt, int id) : evt(evt), id(id) {
|
CallbackHandle(Event *evt, int id) : evt(evt), id(id) {}
|
||||||
}
|
|
||||||
~CallbackHandle();
|
~CallbackHandle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -27,9 +26,7 @@ class Event {
|
|||||||
return CallbackHandle(this, id);
|
return CallbackHandle(this, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(int id) {
|
void remove(int id) { callbacks.erase(id); }
|
||||||
callbacks.erase(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void fire() {
|
void fire() {
|
||||||
for (auto &kv : callbacks)
|
for (auto &kv : callbacks)
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ double Hub::get_position() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Hub::get_text() {
|
||||||
|
// no-op
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
void Hub::actuate(double /* position */) {
|
void Hub::actuate(double /* position */) {
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
@@ -14,6 +19,10 @@ void Hub::actuate(double /* x */, double /* y */) {
|
|||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hub::actuate(const std::string &text) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> Hub::get_actuation_message() {
|
std::vector<uint8_t> Hub::get_actuation_message() {
|
||||||
// no-op
|
// no-op
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -4,27 +4,20 @@
|
|||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
|
||||||
std::vector<neighbour> Module::get_neighbours() {
|
std::vector<neighbour> Module::get_neighbours() { return m_neighbours; }
|
||||||
return m_neighbours;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t Module::get_device_id() {
|
uint8_t Module::get_device_id() { return m_device_id; }
|
||||||
return m_device_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
ModuleType Module::get_type() {
|
ModuleType Module::get_type() { return m_module_type; }
|
||||||
return m_module_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
Messaging::ConnectionType Module::get_connection_type() {
|
Messaging::ConnectionType Module::get_connection_type() {
|
||||||
return m_connection_type;
|
return m_connection_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Module::get_leader() {
|
uint8_t Module::get_leader() { return m_leader; }
|
||||||
return m_leader;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::system_clock> Module::get_last_updated_time() {
|
std::chrono::time_point<std::chrono::system_clock>
|
||||||
|
Module::get_last_updated_time() {
|
||||||
return m_last_updated;
|
return m_last_updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,8 +29,8 @@ void Module::update_module_metadata(const Messaging::TopologyMessage &message) {
|
|||||||
m_last_updated = std::chrono::system_clock::now();
|
m_last_updated = std::chrono::system_clock::now();
|
||||||
|
|
||||||
m_neighbours.clear();
|
m_neighbours.clear();
|
||||||
for (auto [id, ori] :
|
for (auto [id, ori] : std::views::zip(*message.channel_to_module(),
|
||||||
std::views::zip(*message.channel_to_module(), *message.channel_to_orientation())) {
|
*message.channel_to_orientation())) {
|
||||||
m_neighbours.emplace_back(neighbour{id, static_cast<Orientation>(ori)});
|
m_neighbours.emplace_back(neighbour{id, static_cast<Orientation>(ori)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "ModuleFactory.h"
|
#include "ModuleFactory.h"
|
||||||
#include "Hub.h"
|
#include "Hub.h"
|
||||||
#include "actuators/BoundedPositionalActuator1D.h"
|
#include "actuators/BoundedPositionalActuator1D.h"
|
||||||
|
#include "actuators/OledActuator.h"
|
||||||
#include "actuators/PositionalActuator1D.h"
|
#include "actuators/PositionalActuator1D.h"
|
||||||
#include "flatbuffers_generated/RobotModule_generated.h"
|
#include "flatbuffers_generated/RobotModule_generated.h"
|
||||||
|
|
||||||
@@ -9,8 +10,8 @@
|
|||||||
#define SERVO1_MIN_ANGLE 0
|
#define SERVO1_MIN_ANGLE 0
|
||||||
#define SERVO1_DEFAULT_ANGLE 90
|
#define SERVO1_DEFAULT_ANGLE 90
|
||||||
|
|
||||||
std::shared_ptr<Module>
|
std::shared_ptr<Module> ModuleFactory::createModule(
|
||||||
ModuleFactory::createModule(uint8_t device_id, ModuleType type,
|
uint8_t device_id, ModuleType type,
|
||||||
std::shared_ptr<MessagingInterface> &messaging_interface) {
|
std::shared_ptr<MessagingInterface> &messaging_interface) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ModuleType_SPLITTER:
|
case ModuleType_SPLITTER:
|
||||||
@@ -20,9 +21,14 @@ ModuleFactory::createModule(uint8_t device_id, ModuleType type,
|
|||||||
case ModuleType_SERVO_1:
|
case ModuleType_SERVO_1:
|
||||||
case ModuleType_SERVO_2:
|
case ModuleType_SERVO_2:
|
||||||
return std::make_shared<BoundedPositionalActuator1D>(
|
return std::make_shared<BoundedPositionalActuator1D>(
|
||||||
device_id, type, SERVO1_MAX_ANGLE, SERVO1_MIN_ANGLE, SERVO1_DEFAULT_ANGLE);
|
device_id, type, SERVO1_MAX_ANGLE, SERVO1_MIN_ANGLE,
|
||||||
|
SERVO1_DEFAULT_ANGLE);
|
||||||
case ModuleType_DC_MOTOR:
|
case ModuleType_DC_MOTOR:
|
||||||
return std::make_shared<PositionalActuator1D>(device_id, type);
|
return std::make_shared<PositionalActuator1D>(device_id, type);
|
||||||
|
case ModuleType_DISPLAY:
|
||||||
|
return std::make_shared<OledActuator>(device_id, type);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ double BoundedPositionalActuator1D::get_position() {
|
|||||||
return m_current_position;
|
return m_current_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string BoundedPositionalActuator1D::get_text() { return ""; }
|
||||||
|
|
||||||
void BoundedPositionalActuator1D::actuate(double position) {
|
void BoundedPositionalActuator1D::actuate(double position) {
|
||||||
if (position < m_min_value || position > m_max_value) {
|
if (position < m_min_value || position > m_max_value) {
|
||||||
return;
|
return;
|
||||||
@@ -18,8 +20,9 @@ void BoundedPositionalActuator1D::actuate(double position) {
|
|||||||
m_target_position = position;
|
m_target_position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundedPositionalActuator1D::actuate(double x, double y) {
|
void BoundedPositionalActuator1D::actuate(double x, double y) {}
|
||||||
}
|
|
||||||
|
void BoundedPositionalActuator1D::actuate(const std::string &text) {}
|
||||||
|
|
||||||
std::vector<uint8_t> BoundedPositionalActuator1D::get_actuation_message() {
|
std::vector<uint8_t> BoundedPositionalActuator1D::get_actuation_message() {
|
||||||
std::vector<uint8_t> message{};
|
std::vector<uint8_t> message{};
|
||||||
@@ -28,16 +31,22 @@ std::vector<uint8_t> BoundedPositionalActuator1D::get_actuation_message() {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto [data, size] = acm_builder->build_angle_control_message(m_target_position);
|
auto [data, size] =
|
||||||
|
acm_builder->build_angle_control_message(m_target_position);
|
||||||
message.resize(size);
|
message.resize(size);
|
||||||
memcpy(message.data(), data, size);
|
memcpy(message.data(), data, size);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundedPositionalActuator1D::update_sensor_data(const Flatbuffers::sensor_value &value) {
|
void BoundedPositionalActuator1D::update_sensor_data(
|
||||||
std::visit(overloaded{
|
const Flatbuffers::sensor_value &value) {
|
||||||
|
std::visit(
|
||||||
|
overloaded{
|
||||||
[this](Flatbuffers::target_angle a) { m_current_position = a.angle; },
|
[this](Flatbuffers::target_angle a) { m_current_position = a.angle; },
|
||||||
[this](Flatbuffers::current_angle a) { m_current_position = a.angle; },
|
[this](Flatbuffers::current_angle a) {
|
||||||
|
m_current_position = a.angle;
|
||||||
|
},
|
||||||
|
[this](Flatbuffers::current_text /*t*/) {},
|
||||||
},
|
},
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|||||||
38
src/actuators/OledActuator.cpp
Normal file
38
src/actuators/OledActuator.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include "actuators/OledActuator.h"
|
||||||
|
#include "flatbuffers/SensorMessageBuilder.h"
|
||||||
|
#include "util/Variant.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
double OledActuator::get_position() { return 0.0; }
|
||||||
|
|
||||||
|
std::string OledActuator::get_text() { return m_current_text; }
|
||||||
|
|
||||||
|
void OledActuator::actuate(double /* position */) {}
|
||||||
|
|
||||||
|
void OledActuator::actuate(double /* x */, double /* y */) {}
|
||||||
|
|
||||||
|
void OledActuator::actuate(const std::string &text) { m_target_text = text; }
|
||||||
|
|
||||||
|
std::vector<uint8_t> OledActuator::get_actuation_message() {
|
||||||
|
std::vector<uint8_t> message{};
|
||||||
|
|
||||||
|
if (m_target_text == m_current_text) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto [data, size] =
|
||||||
|
m_text_message_builder->build_text_control_message(m_target_text);
|
||||||
|
message.resize(size);
|
||||||
|
memcpy(message.data(), data, size);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OledActuator::update_sensor_data(const Flatbuffers::sensor_value &value) {
|
||||||
|
std::visit(
|
||||||
|
overloaded{
|
||||||
|
[this](Flatbuffers::target_angle /* a */) {},
|
||||||
|
[this](Flatbuffers::current_angle /* a */) {},
|
||||||
|
[this](Flatbuffers::current_text t) { m_current_text = t.text; },
|
||||||
|
},
|
||||||
|
value);
|
||||||
|
}
|
||||||
@@ -3,16 +3,17 @@
|
|||||||
#include "util/Variant.h"
|
#include "util/Variant.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
double PositionalActuator1D::get_position() {
|
double PositionalActuator1D::get_position() { return m_current_position; }
|
||||||
return m_current_position;
|
|
||||||
}
|
std::string PositionalActuator1D::get_text() { return ""; }
|
||||||
|
|
||||||
void PositionalActuator1D::actuate(double position) {
|
void PositionalActuator1D::actuate(double position) {
|
||||||
m_target_position = position;
|
m_target_position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PositionalActuator1D::actuate(double /* x */, double /* y */) {
|
void PositionalActuator1D::actuate(double /* x */, double /* y */) {}
|
||||||
}
|
|
||||||
|
void PositionalActuator1D::actuate(const std::string &text) {}
|
||||||
|
|
||||||
std::vector<uint8_t> PositionalActuator1D::get_actuation_message() {
|
std::vector<uint8_t> PositionalActuator1D::get_actuation_message() {
|
||||||
std::vector<uint8_t> message{};
|
std::vector<uint8_t> message{};
|
||||||
@@ -21,16 +22,23 @@ std::vector<uint8_t> PositionalActuator1D::get_actuation_message() {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto [data, size] = m_acm_builder->build_angle_control_message(m_target_position);
|
auto [data, size] =
|
||||||
|
m_acm_builder->build_angle_control_message(m_target_position);
|
||||||
message.resize(size);
|
message.resize(size);
|
||||||
memcpy(message.data(), data, size);
|
memcpy(message.data(), data, size);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PositionalActuator1D::update_sensor_data(const Flatbuffers::sensor_value &value) {
|
void PositionalActuator1D::update_sensor_data(
|
||||||
|
const Flatbuffers::sensor_value &value) {
|
||||||
std::visit(overloaded{
|
std::visit(overloaded{
|
||||||
[this](Flatbuffers::target_angle a) { m_board_target_position = a.angle; },
|
[this](Flatbuffers::target_angle a) {
|
||||||
[this](Flatbuffers::current_angle a) { m_current_position = a.angle; },
|
m_board_target_position = a.angle;
|
||||||
|
},
|
||||||
|
[this](Flatbuffers::current_angle a) {
|
||||||
|
m_current_position = a.angle;
|
||||||
|
},
|
||||||
|
[this](Flatbuffers::current_text /*t*/) {},
|
||||||
},
|
},
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ AngleControlMessageBuilder::parse_angle_control_message(const uint8_t *buffer) {
|
|||||||
return flatbuffers::GetRoot<Messaging::AngleControlMessage>(buffer);
|
return flatbuffers::GetRoot<Messaging::AngleControlMessage>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializedMessage AngleControlMessageBuilder::build_angle_control_message(const int16_t angle) {
|
SerializedMessage
|
||||||
|
AngleControlMessageBuilder::build_angle_control_message(const int16_t angle) {
|
||||||
builder_.Clear();
|
builder_.Clear();
|
||||||
|
|
||||||
const auto message = Messaging::CreateAngleControlMessage(builder_, angle);
|
const auto message = Messaging::CreateAngleControlMessage(builder_, angle);
|
||||||
|
|||||||
@@ -15,12 +15,13 @@ SerializedMessage RobotConfigurationBuilder::build_robot_configuration(
|
|||||||
builder_.Clear();
|
builder_.Clear();
|
||||||
|
|
||||||
std::vector<flatbuffers::Offset<RobotModule>> module_vector;
|
std::vector<flatbuffers::Offset<RobotModule>> module_vector;
|
||||||
std::vector<flatbuffers::Offset<Frontend::ModuleConnection>> connection_vector;
|
std::vector<flatbuffers::Offset<Frontend::ModuleConnection>>
|
||||||
|
connection_vector;
|
||||||
|
|
||||||
for (const auto &connection : connections) {
|
for (const auto &connection : connections) {
|
||||||
connection_vector.push_back(Frontend::CreateModuleConnection(
|
connection_vector.push_back(Frontend::CreateModuleConnection(
|
||||||
builder_, connection.from_module_id, connection.to_module_id, connection.from_socket,
|
builder_, connection.from_module_id, connection.to_module_id,
|
||||||
connection.to_socket, connection.orientation));
|
connection.from_socket, connection.to_socket, connection.orientation));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &module : modules) {
|
for (const auto &module : modules) {
|
||||||
@@ -28,14 +29,15 @@ SerializedMessage RobotConfigurationBuilder::build_robot_configuration(
|
|||||||
auto motor_state = CreateMotorState(builder_, module.angle);
|
auto motor_state = CreateMotorState(builder_, module.angle);
|
||||||
const flatbuffers::Offset<void> config_union = motor_state.Union();
|
const flatbuffers::Offset<void> config_union = motor_state.Union();
|
||||||
module_vector.push_back(CreateRobotModule(builder_, module.id, module.type,
|
module_vector.push_back(CreateRobotModule(builder_, module.id, module.type,
|
||||||
ModuleState_MotorState, config_union));
|
ModuleState_MotorState,
|
||||||
|
config_union));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto connection_vector_fb = builder_.CreateVector(connection_vector);
|
const auto connection_vector_fb = builder_.CreateVector(connection_vector);
|
||||||
const auto module_vector_fb = builder_.CreateVector(module_vector);
|
const auto module_vector_fb = builder_.CreateVector(module_vector);
|
||||||
|
|
||||||
const auto message =
|
const auto message = Frontend::CreateRobotConfiguration(
|
||||||
Frontend::CreateRobotConfiguration(builder_, module_vector_fb, connection_vector_fb);
|
builder_, module_vector_fb, connection_vector_fb);
|
||||||
|
|
||||||
builder_.Finish(message);
|
builder_.Finish(message);
|
||||||
|
|
||||||
@@ -43,7 +45,8 @@ SerializedMessage RobotConfigurationBuilder::build_robot_configuration(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Frontend::RobotConfiguration *
|
const Frontend::RobotConfiguration *
|
||||||
RobotConfigurationBuilder::parse_robot_configuration(const std::uint8_t *buffer) {
|
RobotConfigurationBuilder::parse_robot_configuration(
|
||||||
|
const std::uint8_t *buffer) {
|
||||||
return flatbuffers::GetRoot<Frontend::RobotConfiguration>(buffer);
|
return flatbuffers::GetRoot<Frontend::RobotConfiguration>(buffer);
|
||||||
}
|
}
|
||||||
} // namespace Flatbuffers
|
} // namespace Flatbuffers
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
namespace Flatbuffers {
|
namespace Flatbuffers {
|
||||||
|
|
||||||
const Messaging::SensorMessage *SensorMessageBuilder::parse_sensor_message(const uint8_t *buffer) {
|
const Messaging::SensorMessage *
|
||||||
|
SensorMessageBuilder::parse_sensor_message(const uint8_t *buffer) {
|
||||||
return flatbuffers::GetRoot<Messaging::SensorMessage>(buffer);
|
return flatbuffers::GetRoot<Messaging::SensorMessage>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
21
src/flatbuffers/TextControlMessageBuilder.cpp
Normal file
21
src/flatbuffers/TextControlMessageBuilder.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Created by Johnathon Slightham on 2025-06-30.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "flatbuffers/TextControlMessageBuilder.h"
|
||||||
|
|
||||||
|
namespace Flatbuffers {
|
||||||
|
|
||||||
|
SerializedMessage
|
||||||
|
TextControlMessageBuilder::build_text_control_message(std::string &t) {
|
||||||
|
builder_.Clear();
|
||||||
|
|
||||||
|
auto text_offset = builder_.CreateString(t);
|
||||||
|
const auto message =
|
||||||
|
Messaging::CreateTextControlMessage(builder_, text_offset);
|
||||||
|
|
||||||
|
builder_.Finish(message);
|
||||||
|
|
||||||
|
return {builder_.GetBufferPointer(), builder_.GetSize()};
|
||||||
|
}
|
||||||
|
} // namespace Flatbuffers
|
||||||
@@ -7,18 +7,19 @@
|
|||||||
#include "flatbuffers/SerializedMessage.h"
|
#include "flatbuffers/SerializedMessage.h"
|
||||||
|
|
||||||
namespace Flatbuffers {
|
namespace Flatbuffers {
|
||||||
SerializedMessage
|
SerializedMessage TopologyMessageBuilder::build_topology_message(
|
||||||
TopologyMessageBuilder::build_topology_message(const uint8_t module_id,
|
const uint8_t module_id, const ModuleType module_type,
|
||||||
const ModuleType module_type,
|
|
||||||
const std::vector<uint8_t> &channel_to_module,
|
const std::vector<uint8_t> &channel_to_module,
|
||||||
const std::vector<int8_t> &orientation_to_module) {
|
const std::vector<int8_t> &orientation_to_module) {
|
||||||
builder_.Clear();
|
builder_.Clear();
|
||||||
|
|
||||||
const auto orientation_to_module_vector = builder_.CreateVector(orientation_to_module);
|
const auto orientation_to_module_vector =
|
||||||
const auto channel_to_module_vector = builder_.CreateVector(channel_to_module);
|
builder_.CreateVector(orientation_to_module);
|
||||||
|
const auto channel_to_module_vector =
|
||||||
|
builder_.CreateVector(channel_to_module);
|
||||||
|
|
||||||
const auto message =
|
const auto message = Messaging::CreateTopologyMessage(
|
||||||
Messaging::CreateTopologyMessage(builder_, module_id, module_type, channel_to_module.size(),
|
builder_, module_id, module_type, channel_to_module.size(),
|
||||||
channel_to_module_vector, orientation_to_module_vector);
|
channel_to_module_vector, orientation_to_module_vector);
|
||||||
|
|
||||||
builder_.Finish(message);
|
builder_.Finish(message);
|
||||||
@@ -31,7 +32,8 @@ TopologyMessageBuilder::parse_topology_message(const uint8_t *buffer) {
|
|||||||
return flatbuffers::GetRoot<Messaging::TopologyMessage>(buffer);
|
return flatbuffers::GetRoot<Messaging::TopologyMessage>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TopologyMessageBuilder::is_valid_topology_message(const uint8_t *buffer, size_t size) {
|
bool TopologyMessageBuilder::is_valid_topology_message(const uint8_t *buffer,
|
||||||
|
size_t size) {
|
||||||
flatbuffers::Verifier verifier(buffer, size);
|
flatbuffers::Verifier verifier(buffer, size);
|
||||||
return Messaging::VerifyTopologyMessageBuffer(verifier);
|
return Messaging::VerifyTopologyMessageBuffer(verifier);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,18 +14,18 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
const auto robot_controller = std::make_unique<RobotController>();
|
const auto robot_controller = std::make_unique<RobotController>();
|
||||||
|
|
||||||
const auto acm_builder = std::make_unique<Flatbuffers::AngleControlMessageBuilder>();
|
const auto acm_builder =
|
||||||
|
std::make_unique<Flatbuffers::AngleControlMessageBuilder>();
|
||||||
|
|
||||||
const auto robot_configuration_builder = std::make_unique<Flatbuffers::RobotConfigurationBuilder>();
|
const auto robot_configuration_builder =
|
||||||
|
std::make_unique<Flatbuffers::RobotConfigurationBuilder>();
|
||||||
|
|
||||||
LIB_API void init() {
|
LIB_API void init() {
|
||||||
spdlog::info("[c_control] Initializing");
|
spdlog::info("[c_control] Initializing");
|
||||||
robot_controller->fetchDirectlyConnectedModules(false);
|
robot_controller->fetchDirectlyConnectedModules(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIB_API void cleanup() {
|
LIB_API void cleanup() { spdlog::info("[c_control] Cleanup"); }
|
||||||
spdlog::info("[c_control] Cleanup");
|
|
||||||
}
|
|
||||||
|
|
||||||
LIB_API int send_angle_control(int module_id, int angle) {
|
LIB_API int send_angle_control(int module_id, int angle) {
|
||||||
if (const auto maybe_module = robot_controller->getModule(module_id)) {
|
if (const auto maybe_module = robot_controller->getModule(module_id)) {
|
||||||
@@ -48,12 +48,14 @@ LIB_API char *get_configuration(int *size_out) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto [data, size] =
|
const auto [data, size] =
|
||||||
robot_configuration_builder->build_robot_configuration(modules_vec, connections_vec);
|
robot_configuration_builder->build_robot_configuration(modules_vec,
|
||||||
|
connections_vec);
|
||||||
*size_out = size;
|
*size_out = size;
|
||||||
return reinterpret_cast<char *>(data);
|
return reinterpret_cast<char *>(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIB_API bool control_sentry_init(const char *dsn, const char *environment, const char *release) {
|
LIB_API bool control_sentry_init(const char *dsn, const char *environment,
|
||||||
|
const char *release) {
|
||||||
sentry_options_t *options = sentry_options_new();
|
sentry_options_t *options = sentry_options_new();
|
||||||
sentry_options_set_dsn(options, dsn);
|
sentry_options_set_dsn(options, dsn);
|
||||||
sentry_options_set_environment(options, environment);
|
sentry_options_set_environment(options, environment);
|
||||||
@@ -64,11 +66,10 @@ LIB_API bool control_sentry_init(const char *dsn, const char *environment, const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LIB_API void control_sentry_shutdown(void) {
|
LIB_API void control_sentry_shutdown(void) { sentry_close(); }
|
||||||
sentry_close();
|
|
||||||
}
|
|
||||||
|
|
||||||
LIB_API void control_sentry_set_app_info(const char *app_name, const char *app_version,
|
LIB_API void control_sentry_set_app_info(const char *app_name,
|
||||||
|
const char *app_version,
|
||||||
const char *build_number) {
|
const char *build_number) {
|
||||||
sentry_value_t app = sentry_value_new_object();
|
sentry_value_t app = sentry_value_new_object();
|
||||||
|
|
||||||
@@ -77,11 +78,13 @@ LIB_API void control_sentry_set_app_info(const char *app_name, const char *app_v
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (app_version && *app_version) {
|
if (app_version && *app_version) {
|
||||||
sentry_value_set_by_key(app, "version", sentry_value_new_string(app_version));
|
sentry_value_set_by_key(app, "version",
|
||||||
|
sentry_value_new_string(app_version));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (build_number && *build_number) {
|
if (build_number && *build_number) {
|
||||||
sentry_value_set_by_key(app, "build", sentry_value_new_string(build_number));
|
sentry_value_set_by_key(app, "build",
|
||||||
|
sentry_value_new_string(build_number));
|
||||||
}
|
}
|
||||||
|
|
||||||
sentry_set_context("app", app);
|
sentry_set_context("app", app);
|
||||||
@@ -89,13 +92,14 @@ LIB_API void control_sentry_set_app_info(const char *app_name, const char *app_v
|
|||||||
if (app_version && *app_version) {
|
if (app_version && *app_version) {
|
||||||
if (build_number && *build_number) {
|
if (build_number && *build_number) {
|
||||||
char release[256];
|
char release[256];
|
||||||
snprintf(release, sizeof(release), "%s@%s+%s", app_name && *app_name ? app_name : "app",
|
snprintf(release, sizeof(release), "%s@%s+%s",
|
||||||
app_version, build_number);
|
app_name && *app_name ? app_name : "app", app_version,
|
||||||
|
build_number);
|
||||||
} else {
|
} else {
|
||||||
// Example: mygame@1.2.3
|
// Example: mygame@1.2.3
|
||||||
char release[256];
|
char release[256];
|
||||||
snprintf(release, sizeof(release), "%s@%s", app_name && *app_name ? app_name : "app",
|
snprintf(release, sizeof(release), "%s@%s",
|
||||||
app_version);
|
app_name && *app_name ? app_name : "app", app_version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#define SENSOR_BUFFER_SIZE 1024
|
#define SENSOR_BUFFER_SIZE 1024
|
||||||
#define NETWORK_CONFIG_FETCH_RATE 3s
|
#define NETWORK_CONFIG_FETCH_RATE 3s
|
||||||
#define MODULE_EXPIRE_TIME 3s
|
#define MODULE_EXPIRE_TIME 3s
|
||||||
#define CONTROL_MESSAGE_FREQUENCY 33ms
|
#define CONTROL_MESSAGE_FREQUENCY 50ms
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@@ -52,7 +52,8 @@ std::vector<std::weak_ptr<Module>> RobotController::getModules() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Flatbuffers::ModuleConnectionInstance> RobotController::getConnections() {
|
std::vector<Flatbuffers::ModuleConnectionInstance>
|
||||||
|
RobotController::getConnections() {
|
||||||
std::vector<Flatbuffers::ModuleConnectionInstance> out;
|
std::vector<Flatbuffers::ModuleConnectionInstance> out;
|
||||||
std::shared_lock lock(m_connection_lock);
|
std::shared_lock lock(m_connection_lock);
|
||||||
|
|
||||||
@@ -73,7 +74,8 @@ std::vector<Flatbuffers::ModuleInstance> RobotController::getModuleList() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::weak_ptr<Module>> RobotController::getModule(uint8_t device_id) {
|
std::optional<std::weak_ptr<Module>>
|
||||||
|
RobotController::getModule(uint8_t device_id) {
|
||||||
std::shared_lock lock(m_module_lock);
|
std::shared_lock lock(m_module_lock);
|
||||||
if (m_id_to_module.contains(device_id)) {
|
if (m_id_to_module.contains(device_id)) {
|
||||||
return m_id_to_module[device_id];
|
return m_id_to_module[device_id];
|
||||||
@@ -108,8 +110,8 @@ void RobotController::metadata_loop() {
|
|||||||
unsigned char buf[TOPOLOGY_BUFFER_SIZE];
|
unsigned char buf[TOPOLOGY_BUFFER_SIZE];
|
||||||
const auto builder = std::make_unique<Flatbuffers::TopologyMessageBuilder>();
|
const auto builder = std::make_unique<Flatbuffers::TopologyMessageBuilder>();
|
||||||
while (!m_stop_thread) {
|
while (!m_stop_thread) {
|
||||||
if (auto result =
|
if (auto result = m_messaging_interface->recv(buf, TOPOLOGY_BUFFER_SIZE,
|
||||||
m_messaging_interface->recv(buf, TOPOLOGY_BUFFER_SIZE, TOPOLOGY_CMD_TAG)) {
|
TOPOLOGY_CMD_TAG)) {
|
||||||
const auto &[rx_size, from] = *result;
|
const auto &[rx_size, from] = *result;
|
||||||
|
|
||||||
flatbuffers::Verifier verifier(buf, rx_size);
|
flatbuffers::Verifier verifier(buf, rx_size);
|
||||||
@@ -117,13 +119,16 @@ void RobotController::metadata_loop() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto metadata = builder->parse_topology_message(reinterpret_cast<uint8_t *>(buf));
|
const auto metadata =
|
||||||
|
builder->parse_topology_message(reinterpret_cast<uint8_t *>(buf));
|
||||||
std::unique_lock lock(m_module_lock);
|
std::unique_lock lock(m_module_lock);
|
||||||
if (!m_id_to_module.contains(metadata->module_id())) {
|
if (!m_id_to_module.contains(metadata->module_id())) {
|
||||||
spdlog::info("[Control] Creating module entry for {}", metadata->module_id());
|
spdlog::info("[Control] Creating module entry for {}",
|
||||||
|
metadata->module_id());
|
||||||
m_id_to_module.insert(
|
m_id_to_module.insert(
|
||||||
{metadata->module_id(),
|
{metadata->module_id(),
|
||||||
ModuleFactory::createModule(metadata->module_id(), metadata->module_type(),
|
ModuleFactory::createModule(metadata->module_id(),
|
||||||
|
metadata->module_type(),
|
||||||
m_messaging_interface)});
|
m_messaging_interface)});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,8 +143,8 @@ void RobotController::metadata_loop() {
|
|||||||
.to_module_id = metadata->channel_to_module()->Get(i),
|
.to_module_id = metadata->channel_to_module()->Get(i),
|
||||||
.from_socket = i,
|
.from_socket = i,
|
||||||
.to_socket = 0,
|
.to_socket = 0,
|
||||||
.orientation =
|
.orientation = static_cast<Orientation>(
|
||||||
static_cast<Orientation>(metadata->channel_to_orientation()->Get(i))});
|
metadata->channel_to_orientation()->Get(i))});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +162,8 @@ void RobotController::transmit_loop() {
|
|||||||
auto out = module->get_actuation_message();
|
auto out = module->get_actuation_message();
|
||||||
|
|
||||||
if (out.size() > 0) {
|
if (out.size() > 0) {
|
||||||
m_messaging_interface->send(out.data(), out.size(), id, ACTUATOR_CMD_TAG, false);
|
m_messaging_interface->send(out.data(), out.size(), id,
|
||||||
|
ACTUATOR_CMD_TAG, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,7 +221,8 @@ void RobotController::sensor_loop() {
|
|||||||
unsigned char buf[SENSOR_BUFFER_SIZE];
|
unsigned char buf[SENSOR_BUFFER_SIZE];
|
||||||
const auto builder = std::make_unique<Flatbuffers::SensorMessageBuilder>();
|
const auto builder = std::make_unique<Flatbuffers::SensorMessageBuilder>();
|
||||||
while (!m_stop_thread) {
|
while (!m_stop_thread) {
|
||||||
if (auto result = m_messaging_interface->recv(buf, SENSOR_BUFFER_SIZE, SENSOR_CMD_TAG)) {
|
if (auto result = m_messaging_interface->recv(buf, SENSOR_BUFFER_SIZE,
|
||||||
|
SENSOR_CMD_TAG)) {
|
||||||
const auto &[rx_size, from] = *result;
|
const auto &[rx_size, from] = *result;
|
||||||
|
|
||||||
flatbuffers::Verifier verifier(buf, rx_size);
|
flatbuffers::Verifier verifier(buf, rx_size);
|
||||||
@@ -225,10 +232,12 @@ void RobotController::sensor_loop() {
|
|||||||
|
|
||||||
const auto sensor_message =
|
const auto sensor_message =
|
||||||
builder->parse_sensor_message(reinterpret_cast<uint8_t *>(buf));
|
builder->parse_sensor_message(reinterpret_cast<uint8_t *>(buf));
|
||||||
if (sensor_message->values()->size() != sensor_message->values_type()->size()) {
|
if (sensor_message->values()->size() !=
|
||||||
spdlog::error(
|
sensor_message->values_type()->size()) {
|
||||||
"[Control] Got a sensor message with different value ({}) and type ({}) sizes",
|
spdlog::error("[Control] Got a sensor message with different value "
|
||||||
sensor_message->values()->size(), sensor_message->values_type()->size());
|
"({}) and type ({}) sizes",
|
||||||
|
sensor_message->values()->size(),
|
||||||
|
sensor_message->values_type()->size());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,8 +247,10 @@ void RobotController::sensor_loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < sensor_message->values()->size(); i++) {
|
for (int i = 0; i < sensor_message->values()->size(); i++) {
|
||||||
if (auto maybe_value = Flatbuffers::SensorMessageBuilder::build_sensor_value(
|
if (auto maybe_value =
|
||||||
static_cast<Messaging::SensorValue>(sensor_message->values_type()->Get(i)),
|
Flatbuffers::SensorMessageBuilder::build_sensor_value(
|
||||||
|
static_cast<Messaging::SensorValue>(
|
||||||
|
sensor_message->values_type()->Get(i)),
|
||||||
sensor_message->values()->Get(i))) {
|
sensor_message->values()->Get(i))) {
|
||||||
m_id_to_module[from]->update_sensor_data(*maybe_value);
|
m_id_to_module[from]->update_sensor_data(*maybe_value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user