Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for unused variables warning #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,30 @@ void getIMUdata() {
* the readings. The filter parameters B_gyro and B_accel are set to be good for a 2kHz loop rate. Finally,
* the constant errors found in calculate_IMU_error() on startup are subtracted from the accelerometer and gyro readings.
*/
int16_t AcX,AcY,AcZ,GyX,GyY,GyZ,MgX,MgY,MgZ;
int16_t AcX,AcY,AcZ,GyX,GyY,GyZ;

#if defined USE_MPU6050_I2C
mpu6050.getMotion6(&AcX, &AcY, &AcZ, &GyX, &GyY, &GyZ);
#elif defined USE_MPU9250_SPI
int16_t MgX,MgY,MgZ;

mpu9250.getMotion9(&AcX, &AcY, &AcZ, &GyX, &GyY, &GyZ, &MgX, &MgY, &MgZ);

//Magnetometer
MagX = MgX/6.0; //uT
MagY = MgY/6.0;
MagZ = MgZ/6.0;
//Correct the outputs with the calculated error values
MagX = (MagX - MagErrorX)*MagScaleX;
MagY = (MagY - MagErrorY)*MagScaleY;
MagZ = (MagZ - MagErrorZ)*MagScaleZ;
//LP filter magnetometer data
MagX = (1.0 - B_mag)*MagX_prev + B_mag*MagX;
MagY = (1.0 - B_mag)*MagY_prev + B_mag*MagY;
MagZ = (1.0 - B_mag)*MagZ_prev + B_mag*MagZ;
MagX_prev = MagX;
MagY_prev = MagY;
MagZ_prev = MagZ;
#endif

//Accelerometer
Expand Down Expand Up @@ -593,21 +611,7 @@ void getIMUdata() {
GyroY_prev = GyroY;
GyroZ_prev = GyroZ;

//Magnetometer
MagX = MgX/6.0; //uT
MagY = MgY/6.0;
MagZ = MgZ/6.0;
//Correct the outputs with the calculated error values
MagX = (MagX - MagErrorX)*MagScaleX;
MagY = (MagY - MagErrorY)*MagScaleY;
MagZ = (MagZ - MagErrorZ)*MagScaleZ;
//LP filter magnetometer data
MagX = (1.0 - B_mag)*MagX_prev + B_mag*MagX;
MagY = (1.0 - B_mag)*MagY_prev + B_mag*MagY;
MagZ = (1.0 - B_mag)*MagZ_prev + B_mag*MagZ;
MagX_prev = MagX;
MagY_prev = MagY;
MagZ_prev = MagZ;

}

void calculate_IMU_error() {
Expand All @@ -617,7 +621,7 @@ void calculate_IMU_error() {
* accelerometer values AccX, AccY, AccZ, GyroX, GyroY, GyroZ in getIMUdata(). This eliminates drift in the
* measurement.
*/
int16_t AcX,AcY,AcZ,GyX,GyY,GyZ,MgX,MgY,MgZ;
int16_t AcX,AcY,AcZ,GyX,GyY,GyZ;
AccErrorX = 0.0;
AccErrorY = 0.0;
AccErrorZ = 0.0;
Expand All @@ -631,6 +635,7 @@ void calculate_IMU_error() {
#if defined USE_MPU6050_I2C
mpu6050.getMotion6(&AcX, &AcY, &AcZ, &GyX, &GyY, &GyZ);
#elif defined USE_MPU9250_SPI
int16_t MgX,MgY,MgZ;
mpu9250.getMotion9(&AcX, &AcY, &AcZ, &GyX, &GyY, &GyZ, &MgX, &MgY, &MgZ);
#endif

Expand Down