修复MPU9250输出角度

main
詹力 2022-09-18 23:28:21 +08:00
parent 7b2dd27b8d
commit e4a16262e2
4 changed files with 11 additions and 4 deletions

View File

@ -41,7 +41,14 @@ void IMU_Update()
imu.steps = Pedometer_Update(imu.ax, imu.ay, imu.az); imu.steps = Pedometer_Update(imu.ax, imu.ay, imu.az);
printf("%.2f, %.2f, %.2f\n", imu.acc[0], imu.acc[1], imu.acc[2]); /* Sensor Debug. */
float yaw = 0.0f, pitch = 0.0f, roll = 0.0f;
MPU9250_GetEulerAngles(&yaw, &roll, &pitch);
printf("%.2f, %.2f, %.2f\n", yaw, roll, pitch);
//printf("%.2f, %.2f, %.2f\n", imu.acc[0], imu.acc[1], imu.acc[2]);
//printf("%.2f, %.2f, %.2f\n", imu.gyr[0], imu.gyr[1], imu.gyr[2]);
if (CommitFunc) if (CommitFunc)
{ {
CommitFunc(&imu, UserData); CommitFunc(&imu, UserData);

View File

@ -107,9 +107,9 @@ void MPU9250_GetEulerAngles(float* yaw,float* roll, float* pitch)
mpu9250.yaw = atan2(q2*q1 + q0*q3,0.5f - q2*q2 - q3*q3); // * (180.0f /3.141592f); mpu9250.yaw = atan2(q2*q1 + q0*q3,0.5f - q2*q2 - q3*q3); // * (180.0f /3.141592f);
mpu9250.roll = atan2(q2*q3 + q0*q1,0.5f - q2*q2 - q1*q1); //* (180.0f /3.141592f); mpu9250.roll = atan2(q2*q3 + q0*q1,0.5f - q2*q2 - q1*q1); //* (180.0f /3.141592f);
mpu9250.yaw = (180.0f / 3.141592f); mpu9250.yaw *= (180.0f / 3.141592f);
mpu9250.roll = (180.0f / 3.141592f); mpu9250.roll *= (180.0f / 3.141592f);
mpu9250.pitch = (180.0f / 3.141592f); mpu9250.pitch *= (180.0f / 3.141592f);
*yaw = mpu9250.yaw; *yaw = mpu9250.yaw;
*roll = mpu9250.roll; *roll = mpu9250.roll;

BIN
3.Docs/GeekTrackv2.xmind Normal file

Binary file not shown.