0

I use the library https://www.google.com/url?sa=t&source=web&rct=j&url=https://github.com/arduino-libraries/MadgwickAHRS&ved=2ahUKEwiGrpOakcvjAhWOlIsKHXsQD_EQFjAAegQIBRAB&usg=AOvVaw3198y6BzSifkJqTH8BGy8M I get the data from mpu9250, the Raspberry Pi platform. But one quaternion is almost equal to just 1, is this normal? I use updateIMU (where only the accelerometer and the gyroscope are used), then I call the function to translate the quaternions into the corners of the Eiler. But m_pitch, m_roll, m_yaw are very small, I also tried to multiply these values ​​by 180 / 3.14, but the values ​​were still very small. How to fix this problem and get a normal angle from 0 to 360?

gyro in degrees per seconds, and accelerometer in range 2G

madgwick_init();
//begin(50);

while(1){

    gyro_get_raw(calibrate_raw, &gx, &gy, &gz);
    accel_get_axis(calibrate_range, &ax, &ay, &az);

    updateIMU((float)gx, (float)gy, (float)gz, (float)ax, (float)ay, (float)az);

    printf("accel: x = %d\n", ax);
    printf("accel: y = %d\n", ay);
    printf("accel: z = %d\n\n", az);

    printf("gyro: x = %d\n", gx);
    printf("gyro: y = %d\n", gy);
    printf("gyro: z = %d\n\n", gz);

    printf("q0 = %f\n", q0);
    printf("q1 = %f\n", q1);
    printf("q2 = %f\n", q2);
    printf("q3 = %f\n", q3);

    // get_euler_angles(&q0, &q1, &q2, &q3);
    computeAngles();

    printf("roll: %f\n", m_roll);
    printf("pitch: %f\n", m_pitch);
    printf("yaw: %f\n", m_yaw);

    // printf("deg: x = %f\n", gyro_trapezoid_integration(GYRO_INTEGRATION_X, 1));
    // printf("deg: y = %f\n", gyro_trapezoid_integration(GYRO_INTEGRATION_Y, 1));
    // printf("deg: z = %f\n\n", gyro_trapezoid_integration(GYRO_INTEGRATION_Z, 1));



    //printf("x = %d\n", gyro_get_x_raw());
    //printf("(double)x = %f\n", gyro_get_x_calib_raw(0.00875));
    //printf("rpm: %d\n", 1500);
    //set_speed_motor(4, 1500);

    delay(250);
    system("clear");
}
goose
  • 109
  • 1
  • 10
  • You don't seem to actually calculate the quaternion values anywhere. – Thomas Jager Jul 23 '19 at 13:35
  • Why? updateIMU() calculate my quaternions, it's update global variables: q0, q1, q2, q3. m_roll, m_picth and m_yaw also global variables, which update computeAngles() – goose Jul 23 '19 at 13:49
  • You don't show enough code to do anything useful, please provide a [mcve]. Also, using global variables like this is generally considered to be bad practice. – Thomas Jager Jul 23 '19 at 13:51
  • I pointed out above what I use library. Header file is huge, i can't paste here. You can see them following the link: https://github.com/arduino-libraries/MadgwickAHRS&ved=2ahUKEwiGrpOakcvjAhWOlIsKHXsQD_EQFjAAegQIBRAB&usg=AOvVaw3198y6BzSifkJqTH8BGy8M – goose Jul 23 '19 at 14:03
  • updateIMU() and computeAngles () taking from MadgwickAHRS library, i didn't change this functions – goose Jul 23 '19 at 14:05

0 Answers0