mirror of
https://github.com/BotChain-Robots/control.git
synced 2026-03-10 00:32:26 +01:00
Prepare files for public release
This commit is contained in:
66
include/Module.h
Normal file
66
include/Module.h
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// Created by Johnathon Slightham on 2025-11-14.
|
||||
//
|
||||
|
||||
#ifndef CONTROL_MODULE_H
|
||||
#define CONTROL_MODULE_H
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
||||
#include "flatbuffers/SensorMessageBuilder.h"
|
||||
#include "flatbuffers_generated/RobotModule_generated.h"
|
||||
#include "flatbuffers_generated/TopologyMessage_generated.h"
|
||||
#include "librpc.h"
|
||||
|
||||
struct neighbour {
|
||||
uint8_t device_id;
|
||||
Orientation orientation;
|
||||
};
|
||||
|
||||
class Module {
|
||||
public:
|
||||
explicit Module(uint8_t device_id) : m_device_id(device_id) {};
|
||||
|
||||
Module(uint8_t device_id, ModuleType module_type)
|
||||
: m_device_id(device_id), m_module_type(module_type) {};
|
||||
|
||||
Module(uint8_t device_id, ModuleType module_type, Messaging::ConnectionType connection_type,
|
||||
uint8_t leader)
|
||||
: m_device_id(device_id), m_module_type(module_type), m_connection_type(connection_type),
|
||||
m_leader(leader) {};
|
||||
|
||||
std::vector<neighbour> get_neighbours();
|
||||
|
||||
uint8_t get_device_id();
|
||||
|
||||
ModuleType get_type();
|
||||
|
||||
Messaging::ConnectionType get_connection_type();
|
||||
|
||||
uint8_t get_leader();
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> get_last_updated_time();
|
||||
|
||||
virtual double get_position() = 0;
|
||||
virtual void actuate(double x) = 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;
|
||||
|
||||
void update_module_metadata(const Messaging::TopologyMessage &message);
|
||||
|
||||
virtual std::vector<uint8_t> get_actuation_message() = 0;
|
||||
virtual void update_sensor_data(const Flatbuffers::sensor_value &value) = 0;
|
||||
|
||||
private:
|
||||
uint8_t m_device_id;
|
||||
ModuleType m_module_type;
|
||||
Messaging::ConnectionType m_connection_type;
|
||||
uint8_t m_leader;
|
||||
std::chrono::time_point<std::chrono::system_clock> m_last_updated;
|
||||
std::vector<neighbour> m_neighbours;
|
||||
std::shared_ptr<MessagingInterface> m_messaging_interface;
|
||||
};
|
||||
|
||||
#endif // CONTROL_MODULE_H
|
||||
Reference in New Issue
Block a user