⚡ Moves rest of events to event bus
This commit is contained in:
@@ -14,13 +14,18 @@
|
||||
#include <motion_states/stand_state.h>
|
||||
#include <motion_states/rest_state.h>
|
||||
#include <message_types.h>
|
||||
#include <event_bus/event_bus.h>
|
||||
|
||||
enum class MOTION_STATE { DEACTIVATED, IDLE, CALIBRATION, REST, STAND, WALK };
|
||||
|
||||
class MotionService {
|
||||
public:
|
||||
using ModeChangeCallback = std::function<void(bool active)>;
|
||||
|
||||
void begin();
|
||||
|
||||
void setModeChangeCallback(ModeChangeCallback callback) { modeChangeCallback_ = callback; }
|
||||
|
||||
void handleAngles(const socket_message_AnglesData& data);
|
||||
|
||||
void handleInput(const socket_message_ControllerData& data);
|
||||
@@ -42,6 +47,8 @@ class MotionService {
|
||||
inline bool isActive() { return state != nullptr; }
|
||||
|
||||
private:
|
||||
void subscribeToEvents();
|
||||
|
||||
Kinematics kinematics;
|
||||
|
||||
CommandMsg command = {0, 0, 0, 0, 0, 0, 0};
|
||||
@@ -62,6 +69,13 @@ class MotionService {
|
||||
float dir[12] = {1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1};
|
||||
|
||||
int64_t lastUpdate = esp_timer_get_time();
|
||||
|
||||
ModeChangeCallback modeChangeCallback_;
|
||||
|
||||
EventBus::Handle<socket_message_ControllerData> controllerHandle_;
|
||||
EventBus::Handle<socket_message_ModeData> modeHandle_;
|
||||
EventBus::Handle<socket_message_AnglesData> anglesHandle_;
|
||||
EventBus::Handle<socket_message_WalkGaitData> walkGaitHandle_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user