0

Basically, I need use micro:bit accelerometer to move straight forward avoiding curved movements. So far I have calculated roll and pitch using the code below

X = Sensors.acceleration(Sensors.X) / divider;
Z = Sensors.acceleration(Sensors.Y) / divider;
Y = Sensors.acceleration(Sensors.Z) / divider;
    
roll = atan(Y/sqrt(pow(X, 2)+pow(Z, 2))) * 180 / 3.14;
pitch = atan(-1*X/sqrt(pow(Y,2)+pow(Z,2))) * 180 / 3.14;

I have changed Z and Y on purpose, since if the microbit is on maqueen, the "new" Z axes is the initial Y.

The thing is that I need to calculate the Z rotation (yaw) in order to check if the maqueen moves in curved line. Any ideas?

  • See [this answer](https://engineering.stackexchange.com/a/3350) – Ouroborus Nov 26 '22 at 18:11
  • @Ouroborus thanks for the reply, already tried that one, no joy :/ – Giannis Tzagarakis Nov 26 '22 at 18:20
  • What was the issue? – Ouroborus Nov 27 '22 at 04:10
  • I'm having the same problem. That article references using magnetometer external values. I am using an MPU 6050 module which returns the angular acceleration. This is difficult to translate *accurately* into delta angle. What OP was asking is if there are any stand alone libraries/sensors that directly return an accurate angle so that for example a robot can turn 90 degree's within low degrees of error. – Joe Moore Jan 14 '23 at 15:31

0 Answers0