diff --git a/examples/debug_d3/src/debug.c b/examples/debug_d3/src/debug.c index 3308af7..a622a54 100644 --- a/examples/debug_d3/src/debug.c +++ b/examples/debug_d3/src/debug.c @@ -30,7 +30,7 @@ void test3(uint64_t timestamp, device3_event_type event, const device3_ahrs_type* ahrs) { device3_quat_type orientation; - device3_vec3_type euler; + device3_euler_type euler; switch (event) { case DEVICE3_EVENT_INIT: @@ -39,7 +39,7 @@ void test3(uint64_t timestamp, case DEVICE3_EVENT_UPDATE: orientation = device3_get_orientation(ahrs); euler = device3_get_euler(orientation); - printf("Pitch: %.2f; Roll: %.2f; Yaw: %.2f\n", euler.x, euler.y, euler.z); + printf("Roll: %.2f; Pitch: %.2f; Yaw: %.2f\n", euler.roll, euler.pitch, euler.yaw); break; default: break; diff --git a/interface_lib/include/device3.h b/interface_lib/include/device3.h index e660783..79f5662 100644 --- a/interface_lib/include/device3.h +++ b/interface_lib/include/device3.h @@ -110,6 +110,12 @@ struct device3_quat_t { float w; }; +struct device3_euler_t { + float roll; + float pitch; + float yaw; +}; + typedef enum device3_error_t device3_error_type; typedef struct device3_packet_t device3_packet_type; typedef enum device3_event_t device3_event_type; @@ -119,6 +125,7 @@ typedef struct device3_calibration_t device3_calibration_type; typedef struct device3_vec3_t device3_vec3_type; typedef struct device3_quat_t device3_quat_type; +typedef struct device3_euler_t device3_euler_type; typedef void (*device3_event_callback)( uint64_t timestamp, @@ -166,7 +173,7 @@ device3_vec3_type device3_get_linear_acceleration(const device3_ahrs_type* ahrs) device3_quat_type device3_get_orientation(const device3_ahrs_type* ahrs); -device3_vec3_type device3_get_euler(device3_quat_type quat); +device3_euler_type device3_get_euler(device3_quat_type quat); device3_error_type device3_close(device3_type* device); diff --git a/interface_lib/src/device3.c b/interface_lib/src/device3.c index 6541674..6febbea 100644 --- a/interface_lib/src/device3.c +++ b/interface_lib/src/device3.c @@ -912,17 +912,17 @@ device3_quat_type device3_get_orientation(const device3_ahrs_type* ahrs) { return q; } -device3_vec3_type device3_get_euler(device3_quat_type quat) { +device3_euler_type device3_get_euler(device3_quat_type quat) { FusionQuaternion quaternion; quaternion.element.x = quat.x; quaternion.element.y = quat.y; quaternion.element.z = quat.z; quaternion.element.w = quat.w; FusionEuler euler = FusionQuaternionToEuler(quaternion); - device3_vec3_type e; - e.x = euler.angle.pitch; - e.y = euler.angle.roll; - e.z = euler.angle.yaw; + device3_euler_type e; + e.roll = euler.angle.roll; + e.pitch = euler.angle.pitch; + e.yaw = euler.angle.yaw; return e; } diff --git a/src/driver.c b/src/driver.c index a50e131..c0a1e40 100644 --- a/src/driver.c +++ b/src/driver.c @@ -56,19 +56,19 @@ void test3(uint64_t timestamp, dmax = (d > dmax? d : dmax); } - device3_vec3_type e = device3_get_euler(q); + device3_euler_type e = device3_get_euler(q); if (d >= 0.00005f) { - device3_vec3_type e0 = device3_get_euler(old); + device3_euler_type e0 = device3_get_euler(old); - printf("Pitch: %f; Roll: %f; Yaw: %f\n", e0.x, e0.y, e0.z); - printf("Pitch: %f; Roll: %f; Yaw: %f\n", e.x, e.y, e.z); + printf("Roll: %f; Pitch: %f; Yaw: %f\n", e0.roll, e0.pitch, e0.yaw); + printf("Roll: %f; Pitch: %f; Yaw: %f\n", e.roll, e.pitch, e.yaw); printf("D = %f; ( %f )\n", d, dmax); printf("X: %f; Y: %f; Z: %f; W: %f;\n", old.x, old.y, old.z, old.w); printf("X: %f; Y: %f; Z: %f; W: %f;\n", q.x, q.y, q.z, q.w); } else { - printf("Pitch: %.2f; Roll: %.2f; Yaw: %.2f\n", e.x, e.y, e.z); + printf("Roll: %.2f; Pitch: %.2f; Yaw: %.2f\n", e.roll, e.pitch, e.yaw); } old = q;