Gyroscope module output parameters are incorrect
clplaneguy opened this issue · 1 comments
Gyroscope module output parameters are incorrect
Before examining the “Ultrasonic module incompatible with gyro module #19” issue in too much detail, I want make sure I have a good foundation. I have loaded the mBot Obstacle Avoidance program from the website. It is written in Scratch for the mBot(MCore) /#include <MeMCore.h>/. I have the Ultimate 2.0 kit. So, I ported the program to the MegaPi by changing “MeMCore” to “MeMegaPi”. To mount the gyroscope module, I used the build of the “Self-Balancing Robot” in the Ultimate 2.0 kit.
The Graphic on the gyroscope module indicates that theoretically, the positive x-axis is forward, the positive y-axis is left and the positive z-axis is up. When I run a diagnostic program, I find that this is not true. In reality. the positive-y axis is forward; the positive x-axis is right and the positive z-axis is up. The x and y axises are switched. I can correct the problem here immediately by reorienting the gyroscope module. My question is, does this influence the “Ultrasonic module incompatible with gyro module #19” issue. I do not believe so. I think they are two independent Issues.
In MeGyro.cpp check lines 232 and 233 for a misprint.
gx = gx - gyrY * dt;
gy = gy + gyrX * dt;
also check lines 237 and 238
gx = gx + gyrY * dt;
gy = gy - gyrX * dt
I have also noticed that the angles for the z-axis are calculated differently . Should they all be calculated the same for a full circle. (-180 to 180) or (0 to 360)
I am finding reference to:
Makeblock Library 3.2.4
“Firmware_for_MegaPi.ino” Mark Yan 2016/08/24 v0e.01.012”
“MeMegaPi.h” Scott 2016/09/23 v1.0.4
“MeGyro.h” Mark Yan 2016/03/09 v1.0.3
Unfortunately, I cannot verify any of these versions on my machine. Also, they seem to call each other.
The roll is the rotation about the Y axis, the pitch is the rotation about the X axis, but I let roll return X axis and pitch return as Y axis, Because we only use the Euler angle, So this error has been retained for a long time.