🧼 Only write angles once

This commit is contained in:
Rune Harlyk
2024-11-14 11:40:40 +01:00
parent 0b1c27819e
commit 0cce6075b9
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ class Spot {
// communicate
void emitTelemetry() {
if (updatedMotion) EXECUTE_EVERY_N_MS(100, { _motionService.syncAngles(); });
if (updatedMotion) EXECUTE_EVERY_N_MS(100, { _motionService.emitAngles(); });
// _peripherals.loop();
EXECUTE_EVERY_N_MS(1000, { _peripherals.emitIMU(); });
// _peripherals.emitSonar();
+5 -1
View File
@@ -90,12 +90,16 @@ class MotionService {
socket.emit(MODE_EVENT, output, String(originId).c_str());
}
void syncAngles(const String &originId = "", bool sync = false) {
void emitAngles(const String &originId = "", bool sync = false) {
char output[100];
snprintf(output, sizeof(output), "[%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f]", angles[0],
angles[1], angles[2], angles[3], angles[4], angles[5], angles[6], angles[7], angles[8], angles[9],
angles[10], angles[11]);
socket.emit(ANGLES_EVENT, output, originId.c_str());
}
void syncAngles(const String &originId = "", bool sync = false) {
emitAngles(originId, sync);
_servoController->setAngles(angles);
}