Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • F firmware
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare
  • Issues 74
    • Issues 74
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 29
    • Merge requests 29
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • External wiki
    • External wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • card10card10
  • firmware
  • Issues
  • #133
Closed
Open
Issue created 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
Time tracking