mirror of
https://github.com/okalachev/flix.git
synced 2025-07-27 17:49:33 +00:00
CALIBRATE_GYRO_ON_START constant
This commit is contained in:
parent
e039055c8e
commit
127cd58d16
20
flix/imu.ino
20
flix/imu.ino
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#define IMU_CS_PIN 4 // chip-select pin for IMU SPI connection
|
#define IMU_CS_PIN 4 // chip-select pin for IMU SPI connection
|
||||||
|
|
||||||
|
const bool CALIBRATE_GYRO_ON_START = false;
|
||||||
|
|
||||||
MPU9250 IMU(SPI, IMU_CS_PIN);
|
MPU9250 IMU(SPI, IMU_CS_PIN);
|
||||||
|
|
||||||
void setupIMU()
|
void setupIMU()
|
||||||
@ -19,16 +21,16 @@ void setupIMU()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calibrating = true;
|
if (CALIBRATE_GYRO_ON_START) {
|
||||||
calibrateGyro();
|
calibrateGyro();
|
||||||
// loadGyroCal();
|
} else {
|
||||||
// calibrateAccel();
|
loadGyroCal();
|
||||||
|
}
|
||||||
|
|
||||||
loadAccelCal();
|
loadAccelCal();
|
||||||
|
|
||||||
IMU.setSrd(0); // set sample rate to 1000 Hz
|
IMU.setSrd(0); // set sample rate to 1000 Hz
|
||||||
// NOTE: very important, without the above the rate would be terrible 50 Hz
|
// NOTE: very important, without the above the rate would be terrible 50 Hz
|
||||||
|
|
||||||
calibrating = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readIMU()
|
bool readIMU()
|
||||||
@ -52,6 +54,7 @@ bool readIMU()
|
|||||||
|
|
||||||
static void calibrateGyro()
|
static void calibrateGyro()
|
||||||
{
|
{
|
||||||
|
calibrating = true;
|
||||||
Serial.println("Calibrating gyro, stand still");
|
Serial.println("Calibrating gyro, stand still");
|
||||||
delay(500);
|
delay(500);
|
||||||
int status = IMU.calibrateGyro();
|
int status = IMU.calibrateGyro();
|
||||||
@ -61,6 +64,7 @@ static void calibrateGyro()
|
|||||||
Serial.print(IMU.getGyroBiasY_rads(), 10); Serial.print(" ");
|
Serial.print(IMU.getGyroBiasY_rads(), 10); Serial.print(" ");
|
||||||
Serial.println(IMU.getGyroBiasZ_rads(), 10);
|
Serial.println(IMU.getGyroBiasZ_rads(), 10);
|
||||||
IMU.setSrd(0);
|
IMU.setSrd(0);
|
||||||
|
calibrating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calibrateAccel()
|
static void calibrateAccel()
|
||||||
@ -96,9 +100,9 @@ static void loadAccelCal()
|
|||||||
|
|
||||||
static void loadGyroCal()
|
static void loadGyroCal()
|
||||||
{
|
{
|
||||||
IMU.setGyroBiasX_rads(-0.0175771303);
|
IMU.setGyroBiasX_rads(-0.0185128022);
|
||||||
IMU.setGyroBiasY_rads(-0.0298212003);
|
IMU.setGyroBiasY_rads(-0.0262369743);
|
||||||
IMU.setGyroBiasZ_rads(0.0148300380);
|
IMU.setGyroBiasZ_rads(0.0163032326);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accel bias: 0.0463809967 0.0463809967 0.1486964226
|
// Accel bias: 0.0463809967 0.0463809967 0.1486964226
|
||||||
|
Loading…
x
Reference in New Issue
Block a user