本文整理汇总了C++中MPU6050::getYAccelOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ MPU6050::getYAccelOffset方法的具体用法?C++ MPU6050::getYAccelOffset怎么用?C++ MPU6050::getYAccelOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MPU6050
的用法示例。
在下文中一共展示了MPU6050::getYAccelOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calibrate_accel
void calibrate_accel(){
xoff = accelgyro.getXAccelOffset();
yoff = accelgyro.getYAccelOffset();
zoff = accelgyro.getZAccelOffset();
byte i=0;
while (i < ITERATIONS){ //hope that offsets converge in 6 iterations
accelgyro.getAcceleration(&ax, &ay, &az);
if (count == SAMPLE_COUNT){
xoff += int(axm/-6);
yoff += int(aym/-6);
zoff += int((azm+16384)/-6);
accelgyro.setXAccelOffset(xoff);
accelgyro.setYAccelOffset(yoff);
accelgyro.setZAccelOffset(zoff);
#ifdef CAL_DEBUG
Serial.print(axm); Serial.print(" ");
Serial.print(aym); Serial.print(" ");
Serial.println(azm);
Serial.print(xoff); Serial.print(" ");
Serial.print(yoff); Serial.print(" ");
Serial.println(zoff);
Serial.println("*********************");
#endif
count = 0;
i++; //iteration++
#ifdef CAL_DEBUG
Serial.print(".");
#endif
}
else{
axm = (axm*count + ax)/(count+1.0);
aym = (aym*count + ay)/(count+1.0);
azm = (azm*count + az)/(count+1.0);
count++;
}
}
#ifdef CAL_DEBUG
Serial.println(" Done.");
#endif
}
示例2: setup_mpu6050
//PROGRAM FUNCTIONS
void setup_mpu6050(){
clear_i2c();
Wire.begin();
SERIAL_OUT.println("Initializing gyro...");
accelgyro.initialize();
//accelgyro.reset();
accelgyro.setSleepEnabled(false); // thanks to Jack Elston for pointing this one out!
// verify connection
SERIAL_OUT.println("Testing device connections...");
SERIAL_OUT.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
SERIAL_OUT.println(F("Setting clock source to Z Gyro..."));
accelgyro.setClockSource(MPU6050_CLOCK_PLL_ZGYRO);
//SERIAL_OUT.println(accelgyro.getClockSource(MPU6050_CLOCK_PLL_ZGYRO);
SERIAL_OUT.println(F("Setting sample rate to 200Hz..."));
accelgyro.setRate(0); // 1khz / (1 + 4) = 200 Hz
// * | ACCELEROMETER | GYROSCOPE
// * DLPF_CFG | Bandwidth | Delay | Bandwidth | Delay | Sample Rate
// * ---------+-----------+--------+-----------+--------+-------------
// * 0 | 260Hz | 0ms | 256Hz | 0.98ms | 8kHz
// * 1 | 184Hz | 2.0ms | 188Hz | 1.9ms | 1kHz
// * 2 | 94Hz | 3.0ms | 98Hz | 2.8ms | 1kHz
// * 3 | 44Hz | 4.9ms | 42Hz | 4.8ms | 1kHz
// * 4 | 21Hz | 8.5ms | 20Hz | 8.3ms | 1kHz
// * 5 | 10Hz | 13.8ms | 10Hz | 13.4ms | 1kHz
// * 6 | 5Hz | 19.0ms | 5Hz | 18.6ms | 1kHz
// * 7 | -- Reserved -- | -- Reserved -- | Reserved
SERIAL_OUT.println(F("Setting DLPF bandwidth"));
accelgyro.setDLPFMode(MPU6050_DLPF_BW_42);
SERIAL_OUT.println(F("Setting gyro sensitivity to +/- 250 deg/sec..."));
accelgyro.setFullScaleGyroRange(0);
//accelgyro.setFullScaleGyroRange(MPU6050_GYRO_FS_250);
//accelgyro.setFullScaleGyroRange(0); // 0=250, 1=500, 2=1000, 3=2000 deg/sec
//SERIAL_OUT.println(F("Resetting FIFO..."));
//accelgyro.resetFIFO();
// use the code below to change accel/gyro offset values
accelgyro.setXGyroOffset(XGYROOFFSET);
accelgyro.setYGyroOffset(YGYROOFFSET);
accelgyro.setZGyroOffset(ZGYROOFFSET);
SERIAL_OUT.print(accelgyro.getXAccelOffset()); SERIAL_OUT.print("\t"); //
SERIAL_OUT.print(accelgyro.getYAccelOffset()); SERIAL_OUT.print("\t"); //
SERIAL_OUT.print(accelgyro.getZAccelOffset()); SERIAL_OUT.print("\t"); //
SERIAL_OUT.print(accelgyro.getXGyroOffset()); SERIAL_OUT.print("\t"); //
SERIAL_OUT.print(accelgyro.getYGyroOffset()); SERIAL_OUT.print("\t"); //
SERIAL_OUT.print(accelgyro.getZGyroOffset()); SERIAL_OUT.print("\t"); //
SERIAL_OUT.print("\n");
SERIAL_OUT.println(F("Enabling FIFO..."));
accelgyro.setFIFOEnabled(true);
accelgyro.setZGyroFIFOEnabled(true);
accelgyro.setXGyroFIFOEnabled(false);
accelgyro.setYGyroFIFOEnabled(false);
accelgyro.setAccelFIFOEnabled(false);
SERIAL_OUT.print("Z axis enabled?\t"); SERIAL_OUT.println(accelgyro.getZGyroFIFOEnabled());
SERIAL_OUT.print("x axis enabled?\t"); SERIAL_OUT.println(accelgyro.getXGyroFIFOEnabled());
SERIAL_OUT.print("y axis enabled?\t"); SERIAL_OUT.println(accelgyro.getYGyroFIFOEnabled());
SERIAL_OUT.print("accel enabled?\t"); SERIAL_OUT.println(accelgyro.getAccelFIFOEnabled());
accelgyro.resetFIFO();
return ;
}