lsm9ds1_mag: fix orientation (#13925)

- X is aligned with -X of lsm9ds1 accel/gyro
 - Z is up (RHC), flip z for publication
This commit is contained in:
Daniel Agar 2020-01-12 20:35:21 -05:00 committed by GitHub
parent f758a9f29d
commit 65c0882f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -194,10 +194,11 @@ void LSM9DS1_MAG::Run()
if (mreport.STATUS_REG_M & STATUS_REG_M_BIT::ZYXDA) {
// X, Y and Z-axis new data available.
// sensor X is left, Y is back, and Z is up
int16_t x = -combine(mreport.OUT_Y_L_M, mreport.OUT_Y_H_M); // X := -Y
int16_t y = -combine(mreport.OUT_X_L_M, mreport.OUT_X_H_M); // Y := -X
int16_t z = -combine(mreport.OUT_Z_L_M, mreport.OUT_Z_H_M); // Z := -Z
// sensor Z is up (RHC), flip z for publication
// sensor X is aligned with -X of lsm9ds1 accel/gyro
int16_t x = -combine(mreport.OUT_X_L_M, mreport.OUT_X_H_M);
int16_t y = combine(mreport.OUT_Y_L_M, mreport.OUT_Y_H_M);
int16_t z = -combine(mreport.OUT_Z_L_M, mreport.OUT_Z_H_M);
_px4_mag.update(timestamp_sample, x, y, z);
}