mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
Work on sensor
This commit is contained in:
@@ -8,19 +8,25 @@
|
||||
#include <memory>
|
||||
|
||||
#include "MessagingInterface.h"
|
||||
#include "control/ActuatorFactory.h"
|
||||
#include "control/IActuator.h"
|
||||
|
||||
class LoopManager {
|
||||
public:
|
||||
LoopManager() : m_config_manager(ConfigManager::get_instance()),
|
||||
m_messaging_interface(std::make_unique<MessagingInterface>()) {}
|
||||
m_messaging_interface(std::make_unique<MessagingInterface>()),
|
||||
m_actuator(ActuatorFactory::create_actuator(m_config_manager.get_module_type())) {}
|
||||
[[noreturn]] void control_loop() const; // gets control commands
|
||||
[[noreturn]] void sensor_loop() const; // sends sensor data commands continually
|
||||
[[noreturn]] static void sensor_loop(char * args); // sends sensor data commands continually
|
||||
[[noreturn]] static void metadata_tx_loop(char * args); // sends metadata continually (low duty cycle)
|
||||
[[noreturn]] static void metadata_rx_loop(char * args); // gets other commands from PC (ie. f/w updates, nvs updates)
|
||||
|
||||
private:
|
||||
ConfigManager& m_config_manager;
|
||||
std::unique_ptr<MessagingInterface> m_messaging_interface;
|
||||
std::unique_ptr<IActuator> m_actuator;
|
||||
|
||||
void send_sensor_reading(bool durable) const;
|
||||
};
|
||||
|
||||
#endif //LOOPMANAGER_H
|
||||
|
||||
@@ -12,10 +12,12 @@ public:
|
||||
DCMotorActuator();
|
||||
~DCMotorActuator() override;
|
||||
void actuate(uint8_t *cmd) override;
|
||||
std::vector<Flatbuffers::SensorValueInstance> get_sensor_data() override;
|
||||
private:
|
||||
void setup_encoder();
|
||||
static void pid_task(char* args);
|
||||
|
||||
double m_current_angle;
|
||||
int64_t m_target_angle;
|
||||
TaskHandle_t m_pid_task;
|
||||
|
||||
|
||||
@@ -5,10 +5,16 @@
|
||||
#ifndef IACTUATOR_H
|
||||
#define IACTUATOR_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "SensorMessageBuilder.h"
|
||||
|
||||
|
||||
class IActuator {
|
||||
public:
|
||||
virtual ~IActuator() {}
|
||||
virtual void actuate(uint8_t *cmd) = 0;
|
||||
virtual std::vector<Flatbuffers::SensorValueInstance> get_sensor_data() = 0;
|
||||
};
|
||||
|
||||
#endif //IACTUATOR_H
|
||||
|
||||
@@ -15,6 +15,9 @@ class Servo1Actuator final : public IActuator {
|
||||
public:
|
||||
Servo1Actuator();
|
||||
void actuate(std::uint8_t *cmd) override;
|
||||
std::vector<Flatbuffers::SensorValueInstance> get_sensor_data() override;
|
||||
private:
|
||||
uint16_t m_target = 90;
|
||||
};
|
||||
|
||||
#endif //SERVO1ACTUATOR_H
|
||||
|
||||
Reference in New Issue
Block a user