Skip to content

Commit

Permalink
Update mpu9250sensor.cpp
Browse files Browse the repository at this point in the history
Modify it to adapt to the case of axis alignment
  • Loading branch information
TheBug233 authored Mar 7, 2023
1 parent 05491df commit d6d4f2f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/sensors/mpu9250sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ void MPU9250Sensor::getMPUScaled()
// Orientations of axes are set in accordance with the datasheet
// See Section 9.1 Orientation of Axes
// https://invensense.tdk.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf
Mxyz[0] = (float)my;
Mxyz[1] = (float)mx;
Mxyz[2] = -(float)mz;
Mxyz[0] = (float)mx;
Mxyz[1] = (float)my;
Mxyz[2] = (float)mz;
//apply offsets and scale factors from Magneto
#if useFullCalibrationMatrix == true
for (i = 0; i < 3; i++)
Expand Down Expand Up @@ -309,9 +309,9 @@ void MPU9250Sensor::startCalibration(int calibrationType) {
ledManager.on();
int16_t mx,my,mz;
imu.getMagnetometer(&mx, &my, &mz);
calibrationDataMag[i * 3 + 0] = my;
calibrationDataMag[i * 3 + 1] = mx;
calibrationDataMag[i * 3 + 2] = -mz;
calibrationDataMag[i * 3 + 0] = mx;
calibrationDataMag[i * 3 + 1] = my;
calibrationDataMag[i * 3 + 2] = mz;
Network::sendRawCalibrationData(calibrationDataMag, CALIBRATION_TYPE_EXTERNAL_MAG, 0);
ledManager.off();
delay(250);
Expand Down Expand Up @@ -378,9 +378,9 @@ void MPU9250Sensor::startCalibration(int calibrationType) {
calibrationDataAcc[i * 3 + 0] = ax;
calibrationDataAcc[i * 3 + 1] = ay;
calibrationDataAcc[i * 3 + 2] = az;
calibrationDataMag[i * 3 + 0] = my;
calibrationDataMag[i * 3 + 1] = mx;
calibrationDataMag[i * 3 + 2] = -mz;
calibrationDataMag[i * 3 + 0] = mx;
calibrationDataMag[i * 3 + 1] = my;
calibrationDataMag[i * 3 + 2] = mz;
Network::sendRawCalibrationData(calibrationDataAcc, CALIBRATION_TYPE_EXTERNAL_ACCEL, 0);
Network::sendRawCalibrationData(calibrationDataMag, CALIBRATION_TYPE_EXTERNAL_MAG, 0);
ledManager.off();
Expand Down

0 comments on commit d6d4f2f

Please sign in to comment.