修复MPU9250输出角度
parent
7b2dd27b8d
commit
e4a16262e2
Binary file not shown.
|
@ -41,7 +41,14 @@ void IMU_Update()
|
|||
|
||||
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)
|
||||
{
|
||||
CommitFunc(&imu, UserData);
|
||||
|
|
|
@ -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.roll = atan2(q2*q3 + q0*q1,0.5f - q2*q2 - q1*q1); //* (180.0f /3.141592f);
|
||||
|
||||
mpu9250.yaw = (180.0f / 3.141592f);
|
||||
mpu9250.roll = (180.0f / 3.141592f);
|
||||
mpu9250.pitch = (180.0f / 3.141592f);
|
||||
mpu9250.yaw *= (180.0f / 3.141592f);
|
||||
mpu9250.roll *= (180.0f / 3.141592f);
|
||||
mpu9250.pitch *= (180.0f / 3.141592f);
|
||||
|
||||
*yaw = mpu9250.yaw;
|
||||
*roll = mpu9250.roll;
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue