Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
F
firmware
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 78
    • Issues 78
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 34
    • Merge Requests 34
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • External Wiki
    • External Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • card10
  • firmware
  • Issues
  • #133

Closed
Open
Opened Aug 25, 2019 by xiretza@xiretzaContributor

Accelerometer and Gyroscope axes don't match up

It seems like the translation matrices for the BHI160 aren't completely consistent. Using the "BHI160" app to read the sensor data, it looks like the accelerometer is a left-handed coordinate system. If the badge is lying flat on a table:

  • X points right
  • Y points forward
  • Z points down (into the table)

However the gyro axes aren't the same (if we assume positive values being clockwise rotation around the directional vector):

  • X points right
  • Y points forward
  • Z points up

As can be seen, the Z axis is inverted. This means that while downward acceleration (like gravity) causes positive accel values, clockwise rotation around the vertical axis causes negative gyro values.

To try to fix this, I changed the translation matrix in bhi.c to invert the Z axis:

-static int8_t bhi160_mapping_matrix[3 * 3] = { 0, -1, 0, 1, 0, 0, 0, 0, 1 };
+static int8_t bhi160_mapping_matrix[3 * 3] = { 0, -1, 0, 1, 0, 0, 0, 0, -1 };

This does indeed fix the gyro axis! Gyro Z now points down, with clockwise rotation causing positive values. This matrix is used for both the gyro and the accelerometer though, so the accelerometer should have been inverted too - which doesn't happen. In fact the accelerometer seems to be completely immune to this matrix, which may be a separate issue.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: card10/firmware#133