Prepare files for public release

This commit is contained in:
2026-01-24 10:45:51 -05:00
parent 9898e6c975
commit 048e39016a
41 changed files with 2641 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
//
// Created by Johnathon Slightham on 2025-06-30.
//
#ifndef ANGLECONTROLMESSAGEBUILDER_H_
#define ANGLECONTROLMESSAGEBUILDER_H_
#include <string>
#include <vector>
#include "SerializedMessage.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers_generated/AngleControlMessage_generated.h"
namespace Flatbuffers {
class AngleControlMessageBuilder {
public:
AngleControlMessageBuilder() : builder_(256) {
}
SerializedMessage build_angle_control_message(int16_t angle);
static const Messaging::AngleControlMessage *parse_angle_control_message(const uint8_t *buffer);
private:
flatbuffers::FlatBufferBuilder builder_;
};
} // namespace Flatbuffers
#endif

View File

@@ -0,0 +1,45 @@
//
// Created by Johnathon Slightham on 2025-07-25.
//
#ifndef ROBOTCONFIGURATIONBUILDER_H
#define ROBOTCONFIGURATIONBUILDER_H
#include "SerializedMessage.h"
#include <cstdint>
#include <flatbuffers_generated/RobotConfiguration_generated.h>
#include <flatbuffers_generated/RobotModule_generated.h>
#include <vector>
namespace Flatbuffers {
struct ModuleInstance {
uint8_t id;
ModuleType type;
int angle;
};
struct ModuleConnectionInstance {
uint8_t from_module_id;
uint8_t to_module_id;
uint8_t from_socket;
uint8_t to_socket;
Orientation orientation;
};
class RobotConfigurationBuilder {
public:
RobotConfigurationBuilder() : builder_(1024) {
}
SerializedMessage
build_robot_configuration(const std::vector<ModuleInstance> &modules,
const std::vector<ModuleConnectionInstance> &connections);
static const Frontend::RobotConfiguration *
parse_robot_configuration(const std::uint8_t *buffer);
private:
flatbuffers::FlatBufferBuilder builder_;
};
} // namespace Flatbuffers
#endif // ROBOTCONFIGURATIONBUILDER_H

View File

@@ -0,0 +1,54 @@
//
// Created by Johnathon Slightham on 2025-06-30.
//
#ifndef SENSORMESSAGEBUILDER_H
#define SENSORMESSAGEBUILDER_H
#include <variant>
#include "flatbuffers_generated/SensorMessage_generated.h"
namespace Flatbuffers {
struct target_angle {
int16_t angle;
};
struct current_angle {
int16_t angle;
};
typedef std::variant<target_angle, current_angle> sensor_value;
class SensorMessageBuilder {
public:
SensorMessageBuilder() : builder_(1024) {
}
static const Messaging::SensorMessage *parse_sensor_message(const std::uint8_t *buffer);
template <typename T>
static std::optional<sensor_value> build_sensor_value(Messaging::SensorValue type, T value) {
switch (type) {
case Messaging::SensorValue_TargetAngle: {
const Messaging::TargetAngle *target =
static_cast<const Messaging::TargetAngle *>(value);
return target_angle{target->value()};
}
case Messaging::SensorValue_CurrentAngle: {
const Messaging::CurrentAngle *current =
static_cast<const Messaging::CurrentAngle *>(value);
return current_angle{current->value()};
}
default:
return std::nullopt;
}
}
private:
flatbuffers::FlatBufferBuilder builder_;
};
} // namespace Flatbuffers
#endif // TOPOLOGYMESSAGEBUILDER_H

View File

@@ -0,0 +1,17 @@
//
// Created by Johnathon Slightham on 2025-07-05.
//
#ifndef SERIALIZEDMESSAGE_H
#define SERIALIZEDMESSAGE_H
#include <stddef.h>
namespace Flatbuffers {
struct SerializedMessage {
void *data;
size_t size;
};
} // namespace Flatbuffers
#endif // SERIALIZEDMESSAGE_H

View File

@@ -0,0 +1,32 @@
//
// Created by Johnathon Slightham on 2025-06-30.
//
#ifndef TOPOLOGYMESSAGEBUILDER_H
#define TOPOLOGYMESSAGEBUILDER_H
#include <vector>
#include "SerializedMessage.h"
#include "flatbuffers_generated/TopologyMessage_generated.h"
namespace Flatbuffers {
class TopologyMessageBuilder {
public:
TopologyMessageBuilder() : builder_(1024) {
}
SerializedMessage build_topology_message(uint8_t module_id, ModuleType module_type,
const std::vector<uint8_t> &channel_to_module,
const std::vector<int8_t> &orientation_to_module);
static const Messaging::TopologyMessage *parse_topology_message(const uint8_t *buffer);
static bool is_valid_topology_message(const uint8_t *buffer, size_t size);
private:
flatbuffers::FlatBufferBuilder builder_;
};
} // namespace Flatbuffers
#endif // TOPOLOGYMESSAGEBUILDER_H