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

Gyro data question #81

Open
luhang-HPU opened this issue Jul 2, 2016 · 3 comments
Open

Gyro data question #81

luhang-HPU opened this issue Jul 2, 2016 · 3 comments

Comments

@luhang-HPU
Copy link

Dear experts,
I have a question regarding the gyro data manipulation in the main.c line 407:

    /* gyroscope coordinate transformation */
    float x_rate = y_rate_sensor; // change x and y rates
    float y_rate = - x_rate_sensor;
    float z_rate = z_rate_sensor; // z is correct

I do not understand why x and y data is assign in reverse. I thought that even if the gyro is in up down direction when using the board but y direction also points to the front, so why does y data is assigned to x_rate? please clarify me. Thanks!

@mike239x
Copy link
Collaborator

I should say in advance I probably don't understand what I'm saying, so be careful and think for yourself.

I think the reason is the following:

What is being computed here is offset to the flow based on gyro data.

Assuming the camera is stationary, if we rotate it along X axis, the image from camera would move along Y axis, as if the camera moved along Y axis horizontally. This is exactly why X-s and Y-s get swapped like that. Similar effect for rotating along Y axis - it results in the camera image looking as if it moves along the X axis. The minus sign appears because... well... it's hard to explain without a drawing...

Side note: rotation along Z axis would not move the image at all, and instead would rotate the image, so I think that one will be treated completely differently in the code.

@mike239x
Copy link
Collaborator

Also, according to szobov@7aa3516
the signs are wrong, I guess.

@tpetri
Copy link
Contributor

tpetri commented Feb 14, 2020

The cited code in main.c might just be a hardware transform (maybe the sensor is physically rotated against the printed coordinate axis on the px4flow pcb). So that snippet makes sure that x_rate and y_rate correspond with the printed axis.

If that is the case then the sign switch in the commit of szobov might not be correct. Because we need exactly the transform that mike239x explained to match the rates with the flow values. It might be confusing to see the same transformation twice.

To verify that we would need to know the actual coordinate axis of the gyro sensor. It could be that during the design of the pcb the sensor was mounted such that the rate readings of the sensor could be directly used for compensation.

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

3 participants