Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting starting values of MPU6050 DMP output quaternion state #701

Open
henriksod opened this issue Jul 25, 2022 · 1 comment
Open

Setting starting values of MPU6050 DMP output quaternion state #701

henriksod opened this issue Jul 25, 2022 · 1 comment

Comments

@henriksod
Copy link

henriksod commented Jul 25, 2022

Hi,

I have mounted the MPU6050 in a vertical orientation, where x is the pitch axis, instead of y:

MPU6050 Horizontal MPU6050 Vertical
x z
y x
z y

I am using MPU6050_6Axis_MotionApps612 and it is working fine getting the pitch angles, except that on startup, it takes around 3-5 seconds for the DMP output to stabilize. The value starts at pi / 2 and moves towards 0, which is the desired angle at the complete vertical orientation.

I am using the following dmpGetPitch function, which I based off of dmpGetYawPitchRoll:

float dmpGetPitch(Quaternion *q, VectorFloat *gravity) {
    float pitch = 0;
    // pitch: (nose up/down, about accel X axis (-Y axis in robot frame))
    pitch = atan2(gravity->z , sqrt(gravity->x * gravity->x + gravity->y * gravity->y));
    
    if (gravity -> y < 0) {
        if(pitch > 0) {
            pitch = PI - pitch; 
        } else { 
            pitch = -PI - pitch;
        }
    }
    return pitch;
}

I suspect that the DMP states initializes the output quaternion state at 0 degrees, from a horizontal orientation.

I want to initialize the DMP at a custom initial quaternion state. Is this possible? Is there some way I can modify the DMP code or send this data to the unit?

@henriksod
Copy link
Author

The reason why I want to set custom initial values is that my system might have a watchdog reset and I cannot spare 5 seconds of startup time. It needs to work instantaneously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant