🌹 Switches to an explicit sense plan act flow

This commit is contained in:
Rune Harlyk
2024-11-14 10:36:44 +01:00
committed by Rune Harlyk
parent e919b2aa41
commit f3d2fec0e9
5 changed files with 62 additions and 111 deletions
+2 -15
View File
@@ -2,7 +2,6 @@
#define MotionService_h
#include <event_socket.h>
#include <task_manager.h>
#include <Kinematics.h>
#include <ServoController.h>
#include <timing.h>
@@ -37,8 +36,6 @@ class MotionService {
std::bind(&MotionService::syncAngles, this, std::placeholders::_1, std::placeholders::_2));
body_state.updateFeet(default_feet_positions);
g_taskManager.createTask(this->_loopImpl, "MotionService", 4096, this, 3);
}
void anglesEvent(JsonObject &root, int originId) {
@@ -133,16 +130,7 @@ class MotionService {
return updated;
}
void _loop() {
TickType_t xLastWakeTime = xTaskGetTickCount();
for (;;) {
if (updateMotion()) syncAngles();
_servoController->loop();
vTaskDelayUntil(&xLastWakeTime, MotionInterval / portTICK_PERIOD_MS);
}
}
static void _loopImpl(void *_this) { static_cast<MotionService *>(_this)->_loop(); }
float *getAngles() { return angles; }
private:
ServoController *_servoController;
@@ -156,15 +144,14 @@ class MotionService {
MOTION_STATE motionState = MOTION_STATE::DEACTIVATED;
unsigned long _lastUpdate;
constexpr static int MotionInterval = 15;
body_state_t body_state = {0, 0, 0, 0, 0, 0};
float new_angles[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float angles[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float dir[12] = {1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1};
float default_feet_positions[4][4] = {{1, -1, 0.7, 1}, {1, -1, -0.7, 1}, {-1, -1, 0.7, 1}, {-1, -1, -0.7, 1}};
float angles[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float rest_angles[12] = {0, 90, -145, 0, 90, -145, 0, 90, -145, 0, 90, -145};
float calibration_angles[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
};