reading angle from mpu6050

32 vues (au cours des 30 derniers jours)
gil joseph
gil joseph le 23 Mai 2022
Réponse apportée : Hadi le 30 Sep 2023
Hey;
I have hard time in order to get the roll, pitch, yaw from the mpu6050 sensor and I hope someone can help me:
port='COM5';
board = 'Mega2560';
a = arduino(port,board,'Libraries','I2C');
fprintf("connected")
imu= mpu6050(a);
i=0;
while(1)
V = readAngularVelocity(imu);
x=V(1);
y=V(2);
z=V(3);
pitch = atan(x/sqrt((y*y) + (z*z)));
roll = atan(y/sqrt((x*x) + (z*z)));
yaw = atan(sqrt((x*x) + (y*y))/z);
pitch = pitch * (180/pi);
roll = roll * (180/pi);
yaw = yaw * (180/pi);
end

Réponses (1)

Hadi
Hadi le 30 Sep 2023
Hi You should use readAcceleration instead of readAngularVelocity.

Catégories

En savoir plus sur Arduino Hardware dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by