Skip to content

Commit

Permalink
mpu9250: Swap the first two components of mag readings (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitlith authored Jan 21, 2023
1 parent 65df578 commit 3e65a0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sensors/mpu9250sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void MPU9250Sensor::motionLoop() {
Quat quat(-rawQuat.y,rawQuat.x,rawQuat.z,rawQuat.w);

int16_t temp[3];
imu.getMagnetometer(temp + 0, temp + 1, temp + 2);
imu.getMagnetometer(&temp[0], &temp[1], &temp[2]);
parseMagData(temp);

if (Mxyz[0] == 0.0f && Mxyz[1] == 0.0f && Mxyz[2] == 0.0f) {
Expand Down Expand Up @@ -402,9 +402,9 @@ void MPU9250Sensor::startCalibration(int calibrationType) {

void MPU9250Sensor::parseMagData(int16_t data[3]) {
// reading *little* endian int16
Mxyz[0] = (float)data[0];
Mxyz[1] = (float)data[1];
Mxyz[2] = -(float)data[2];
Mxyz[0] = (float)data[1]; // my
Mxyz[1] = (float)data[0]; // mx
Mxyz[2] = -(float)data[2]; // mz

float temp[3];

Expand Down

0 comments on commit 3e65a0d

Please sign in to comment.