Skip to content

Commit 25d4252

Browse files
committed
Fix euler to quat
1 parent 9dbf3d2 commit 25d4252

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/micro-ros_tf_publisher/micro-ros_tf_publisher.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ extern "C" int clock_gettime(clockid_t unused, struct timespec *tp);
3131
cIMU IMU;
3232

3333
const void euler_to_quat(float x, float y, float z, double* q) {
34-
float c1 = cos(y/2);
35-
float c2 = cos(z/2);
36-
float c3 = cos(x/2);
34+
float c1 = cos((y*3.14/180.0)/2);
35+
float c2 = cos((z*3.14/180.0)/2);
36+
float c3 = cos((x*3.14/180.0)/2);
3737

38-
float s1 = sin(y/2);
39-
float s2 = sin(z/2);
40-
float s3 = sin(x/2);
38+
float s1 = sin((y*3.14/180.0)/2);
39+
float s2 = sin((z*3.14/180.0)/2);
40+
float s3 = sin((x*3.14/180.0)/2);
4141

4242
q[0] = c1 * c2 * c3 - s1 * s2 * s3;
4343
q[1] = s1 * s2 * c3 + c1 * c2 * s3;

0 commit comments

Comments
 (0)