🧼 Only write angles once
This commit is contained in:
@@ -68,7 +68,7 @@ class Spot {
|
|||||||
|
|
||||||
// communicate
|
// communicate
|
||||||
void emitTelemetry() {
|
void emitTelemetry() {
|
||||||
if (updatedMotion) EXECUTE_EVERY_N_MS(100, { _motionService.syncAngles(); });
|
if (updatedMotion) EXECUTE_EVERY_N_MS(100, { _motionService.emitAngles(); });
|
||||||
// _peripherals.loop();
|
// _peripherals.loop();
|
||||||
EXECUTE_EVERY_N_MS(1000, { _peripherals.emitIMU(); });
|
EXECUTE_EVERY_N_MS(1000, { _peripherals.emitIMU(); });
|
||||||
// _peripherals.emitSonar();
|
// _peripherals.emitSonar();
|
||||||
|
|||||||
@@ -90,12 +90,16 @@ class MotionService {
|
|||||||
socket.emit(MODE_EVENT, output, String(originId).c_str());
|
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];
|
char output[100];
|
||||||
snprintf(output, sizeof(output), "[%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f]", angles[0],
|
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[1], angles[2], angles[3], angles[4], angles[5], angles[6], angles[7], angles[8], angles[9],
|
||||||
angles[10], angles[11]);
|
angles[10], angles[11]);
|
||||||
socket.emit(ANGLES_EVENT, output, originId.c_str());
|
socket.emit(ANGLES_EVENT, output, originId.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncAngles(const String &originId = "", bool sync = false) {
|
||||||
|
emitAngles(originId, sync);
|
||||||
_servoController->setAngles(angles);
|
_servoController->setAngles(angles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user