Correction de l'erreur d'angle initialisé.

This commit is contained in:
Ulysse Cura 2025-01-31 19:28:45 +01:00
parent ed0147a2e9
commit 237c9be64c
1 changed files with 13 additions and 3 deletions

16
IO.hpp
View File

@ -152,19 +152,29 @@ class IO {
float getAngle(Axes axis) float getAngle(Axes axis)
{ {
float x, y, z; float x, y, z;
float angle;
m_code_cell->Motion_RotationRead(x, y, z); m_code_cell->Motion_RotationRead(x, y, z);
switch(axis) switch(axis)
{ {
case Axes::X: case Axes::X:
return x - m_init_x; angle = x - m_init_x;
if(angle < -180) angle += 360;
if(angle > 180) angle -= 360;
return angle;
case Axes::Y: case Axes::Y:
return y - m_init_y; angle = y - m_init_y;
if(angle < -180) angle += 360;
if(angle > 180) angle -= 360;
return angle;
default: default:
return z - m_init_z; angle = z - m_init_z;
if(angle < -180) angle += 360;
if(angle > 180) angle -= 360;
return angle;
} }
} }