本文整理汇总了C++中MPU6050::initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ MPU6050::initialize方法的具体用法?C++ MPU6050::initialize怎么用?C++ MPU6050::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MPU6050
的用法示例。
在下文中一共展示了MPU6050::initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* Updates function
*
*/
extern "C" void sf_MPU6050_2xDriver_GxAyz_Update_wrapper(const int16_T *x_vel,
const int16_T *y_acc,
const int16_T *z_acc,
const int16_T *x_vel_2,
const int16_T *y_acc_2,
const int16_T *z_acc_2,
real_T *xD)
{
/* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */
if(xD[0] != 1){
# ifndef MATLAB_MEX_FILE
Wire.begin();
accelgyro.initialize();
accelgyro.setDLPFMode(MPU6050_DLPF_BW_42);
accelgyro.setFullScaleGyroRange(MPU6050_GYRO_FS_1000);
accelgyro2.initialize();
accelgyro2.setDLPFMode(MPU6050_DLPF_BW_42);
accelgyro2.setFullScaleGyroRange(MPU6050_GYRO_FS_1000);
#endif
//done with initialization
xD[0] = 1;
}
/* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */
}
示例2: setup
void setup() {
Wire.begin();
if (debugSerial){
Serial.begin(115200);
Serial.println(F("=================== SETUP ================="));
}
// initialize device
if (debugSerial && debugMPU6050) Serial.println(F("Initializing I2C devices..."));
accelgyro.initialize();
// verify connection
if (debugSerial && debugMPU6050) {
Serial.println("Testing device connections...");
boolean OK = accelgyro.testConnection() ;
( OK )?
Serial.println(F("MPU6050 connection successful")):
Serial.println(F("MPU6050 connection failed"));
}
if (debugSerial){
Serial.println(F("=============== FIM SETUP ================="));
}
}
示例3: Gyro_init
bool Gyro_init(void)
{
Wire.begin();
mpu.initialize();
if (mpu.testConnection() == false) {
return false;
}
devStatus = mpu.dmpInitialize();
if (devStatus == 0) {
mpu.setXGyroOffset(X_GYRO_OFFSET);
mpu.setYGyroOffset(Y_GYRO_OFFSET);
mpu.setZGyroOffset(Z_GYRO_OFFSET);
mpu.setXAccelOffset(X_ACCEL_OFFSET);
mpu.setYAccelOffset(Y_ACCEL_OFFSET);
mpu.setZAccelOffset(Z_ACCEL_OFFSET);
mpu.setDMPEnabled(true);
dmpReady = true;
attachInterrupt(0, dmp_data_ready, RISING);
mpuIntStatus = mpu.getIntStatus();
packetSize = mpu.dmpGetFIFOPacketSize();
return true;
}
else {
return false;
}
}
示例4: i2cSetupGyro
bool i2cSetupGyro()
{
//wake up gyro
//return I2Cdev::writeBit( gyroAddr, 0x6b, 6, 0b0);
gyroscope.initialize();
return gyroscope.testConnection();
}
示例5: userSetup
// setup AVR I2C
void userSetup() {
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
Wire.setClock(400000);
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
mpu.initialize();
}
示例6: setup
void setup() {
// initialize device
printf("Initializing I2C devices...\n");
accelgyro.initialize();
gettimeofday(&tv0, NULL);
// verify connection
printf("Testing device connections...\n");
printf(accelgyro.testConnection() ? "MPU6050 connection successful\n" : "MPU6050 connection failed\n");
}
示例7: setup
void setup()
{
// join I2C bus (I2Cdev library doesn't do this automatically)
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
//Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
// initialize serial communication
Serial.begin(38400);
while (!Serial);
mpu.initialize();
pinMode(INTERRUPT_PIN, INPUT);
send_status(MPU_INITIALIZE, STATUS_OK);
// verify connection
send_status(MPU_CONNECTION, mpu.testConnection() ? STATUS_OK : STATUS_FAIL);
// load and configure the DMP
// 0 = DMP OK
// 1 = initial memory load failed
// 2 = DMP configuration updates failed
ua_dev_status = mpu.dmpInitialize();
send_status(DMP_INITIALIZE, ua_dev_status);
// supply your own gyro offsets here, scaled for min sensitivity
mpu.setXGyroOffset(120);
mpu.setYGyroOffset(76);
mpu.setZGyroOffset(-185);
mpu.setZAccelOffset(1688); // 1688 factory default for my test chip
// make sure it worked (returns 0 if so)
if (ua_dev_status == 0)
{
// turn on the DMP, now that it's ready
mpu.setDMPEnabled(true);
// enable Arduino interrupt detection
attachPinChangeInterrupt(INTERRUPT_PIN, dmpDataReady, RISING);
ua_mpu_interrupt_status = mpu.getIntStatus();
send_status(DMP_INTERRUPT, ua_mpu_interrupt_status);
b_dmp_ready = true;
// get expected DMP packet size for later comparison
uh_packet_size = mpu.dmpGetFIFOPacketSize();
}
// configure LED for output
pinMode(LED_PIN, OUTPUT);
}
示例8: IMUInit
/* Initialize the IMU and I2C communication */
void IMUInit(){
/* Intialize communication I2C */
Wire.begin();
/* Initialize IMU. Default resolution is set to minimum, no offsets */
IMU.initialize();
/* Get first values for accel and gyro */
IMU.getMotion6(&accel[0], &accel[1], &accel[2], &gyro[0], &gyro[1], &gyro[2]);
}
示例9: setup_IMU
void setup_IMU()
{
I2CInitialize();
mpu.initialize();
devStatus = mpu.dmpInitialize();
if (devStatus == 0)
{
mpu.setDMPEnabled(true);
mpuIntStatus = mpu.getIntStatus();
dmpReady = true;
packetSize = mpu.dmpGetFIFOPacketSize();
}
}
示例10: setup_IMU
void setup_IMU()
{
tmObjectInit(&lagedatalogsync_tmup);
I2CInitialize();
mpu.initialize();
devStatus = mpu.dmpInitialize();
if (devStatus == 0)
{
//chThdCreateStatic(LageSyncThreadWorkingArea, sizeof(LageSyncThreadWorkingArea), NORMALPRIO, LageSyncthread, NULL);
mpu.setDMPEnabled(true);
mpuIntStatus = mpu.getIntStatus();
dmpReady = true;
packetSize = mpu.dmpGetFIFOPacketSize();
}
}
示例11: setup
int setup() {
// initialize device
printf("Initializing MPU ...\n");
mpu.initialize();
// verify connection
printf("Testing connection ...\n");
if (!mpu.testConnection()) { printf("MPU6050 connection failed\n"); return 1; }
// load and configure the DMP
printf("Flashing DMP ...\n");
devStatus = mpu.dmpInitialize();
// make sure it worked (returns 0 if so)
if (devStatus == 0) {
// turn on the DMP, now that it's ready
mpu.setDMPEnabled(true);
// enable Arduino interrupt detection
//Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
//attachInterrupt(0, dmpDataReady, RISING);
mpuIntStatus = mpu.getIntStatus();
// set our DMP Ready flag so the main loop() function knows it's okay to use it
dmpReady = true;
// get expected DMP packet size for later comparison
packetSize = mpu.dmpGetFIFOPacketSize();
printf("DMP ready\n");
printf("MPU6050 initialized!\n");
return 0;
} else {
// ERROR!
// 1 = initial memory load failed
// 2 = DMP configuration updates failed
// (if it's going to break, usually the code will be 1)
printf("DMP Initialization failed (code %d)\n", devStatus);
return 1;
}
}
示例12: setup
void setup() {
mpu.initialize();
// trace_printf(mpu.testConnection() ? ("MPU6050 connection successful\n") : ("MPU6050 connection failed\n"));
// load and configure the DMP
// trace_printf("Initializing DMP...\n");
devStatus = mpu.dmpInitialize();
// supply your own gyro offsets here, scaled for min sensitivity
mpu.setXGyroOffset(220);
mpu.setYGyroOffset(76);
mpu.setZGyroOffset(-85);
mpu.setZAccelOffset(1788); // 1688 factory default for my test chip
// make sure it worked (returns 0 if so)
if (devStatus == 0) {
// turn on the DMP, now that it's ready
// trace_printf("Enabling DMP...\n");
mpu.setDMPEnabled(true);
mpuIntStatus = mpu.getIntStatus();
// set our DMP Ready flag so the main loop() function knows it's okay to use it
// trace_printf("DMP ready! Waiting for first interrupt...\n");
// trace_printf("System is running!\n");
dmpReady = true;
// get expected DMP packet size for later comparison
packetSize = mpu.dmpGetFIFOPacketSize();
} else {
// ERROR!
// 1 = initial memory load failed
// 2 = DMP configuration updates failed
// (if it's going to break, usually the code will be 1)
// trace_printf("DMP Initialization failed (code \n");
// trace_printf("%d\n", devStatus);
}
}
示例13: setup
void setup() {
// initialize device
accelgyro.initialize();
// printf(accelgyro.testConnection() ? "MPU6050 connection successful\n" : "MPU6050 connection failed\n");
}
示例14: imu_init
void imu_init()
{
uint8_t count = 10;
// initialize device
#ifdef __BOARD_YUN__
Console.println(F("Initializing I2C devices..."));
#else
Serial.println(F("Initializing I2C devices..."));
#endif
mpu.initialize();
// verify connection
#ifdef __BOARD_YUN__
Console.println(F("Testing device connections..."));
Console.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
#else
Serial.println(F("Testing device connections..."));
Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
#endif
/*
// wait for ready
Serial.println(F("\nSend any character to begin DMP programming and demo: "));
while (Serial.available() && Serial.read()); // empty buffer
while (!Serial.available()); // wait for data
while (Serial.available() && Serial.read()); // empty buffer again
*/
// load and configure the DMP
#ifdef __BOARD_YUN__
Console.println(F("Initializing DMP..."));
#else
Serial.println(F("Initializing DMP..."));
#endif
do {
devStatus = mpu.dmpInitialize();
// Set some offset to the MEMS
mpu.setXGyroOffset(220);
mpu.setYGyroOffset(76);
mpu.setZGyroOffset(-85);
mpu.setZAccelOffset(1788);
// make sure it worked (returns 0 if so)
if (devStatus == 0)
{
count = 10;
// turn on the DMP, now that it's ready
#ifdef __BOARD_YUN__
Console.println(F("Enabling DMP..."));
#else
Serial.println(F("Enabling DMP..."));
#endif
mpu.setDMPEnabled(true);
mpuIntStatus = mpu.getIntStatus();
// set our DMP Ready flag so the main loop() function knows it's okay to use it
#ifdef __BOARD_YUN__
Console.println(F("DMP ready! Waiting for first interrupt..."));
#else
Serial.println(F("DMP ready! Waiting for first interrupt..."));
#endif
dmpReady = true;
// get expected DMP packet size for later comparison
packetSize = mpu.dmpGetFIFOPacketSize();
return;
}
else {
// ERROR!
// 1 = initial memory load failed
// 2 = DMP configuration updates failed
// (if it's going to break, usually the code will be 1)
#ifdef __BOARD_YUN__
Console.print(F("DMP Initialization failed (code"));
Console.print(devStatus);
Console.println(F(")"));
// New attempt message
Console.println(F("Trying again"));
#else
Serial.print(F("DMP Initialization failed (code "));
Serial.print(devStatus);
Serial.println(F(")"));
// New attempt message
Serial.println(F("Trying again"));
#endif
}
}
while (--count);
// configure LED for output
pinMode(SOL_LED, OUTPUT);
// Check if the configuration has failed
// if (!count)
{
#ifdef __BOARD_YUN__
Console.println(F("DMP initializaion failed"));
#else
Serial.println(F("DMP initialization failed"));
//.........这里部分代码省略.........
示例15: main
int main(int argc, char **argv) {
printf("MPU6050 3-axis acceleromter example program\n");
I2Cdev::initialize();
MPU6050 accelgyro ;
int16_t ax, ay, az;
int16_t gx, gy, gz;
accelgyro.initialize();
if ( accelgyro.testConnection() )
printf("MPU6050 connection test successful\n") ;
else {
fprintf( stderr, "MPU6050 connection test failed! something maybe wrong, continuing anyway though ...\n");
//return 1;
}
// use the code below to change accel/gyro offset values
/*
printf("Updating internal sensor offsets...\n");
// -76 -2359 1688 0 0 0
printf("%i \t %i \t %i \t %i \t %i \t %i\n",
accelgyro.getXAccelOffset(),
accelgyro.getYAccelOffset(),
accelgyro.getZAccelOffset(),
accelgyro.getXGyroOffset(),
accelgyro.getYGyroOffset(),
accelgyro.getZGyroOffset());
accelgyro.setXGyroOffset(220);
accelgyro.setYGyroOffset(76);
accelgyro.setZGyroOffset(-85);
printf("%i \t %i \t %i \t %i \t %i \t %i\n",
accelgyro.getXAccelOffset(),
accelgyro.getYAccelOffset(),
accelgyro.getZAccelOffset(),
accelgyro.getXGyroOffset(),
accelgyro.getYGyroOffset(),
accelgyro.getZGyroOffset());
*/
printf("\n");
printf(" ax \t ay \t az \t gx \t gy \t gz:\n");
while (true) {
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
// printf(" %d \t %d \t %d \t %d \t %d \t %d\n", ax, ay, az, gx, gy, gz);
// accelgyro.getAcceleration(&ax, &ay, &az);
// printf(" %d \t %d \t %d \r", ax, ay, az);
float axs = ax/16384.0;
float ays = ay/16384.0;
float azs = az/16384.0;
float dxz = sqrt( axs*axs+azs*azs);
float dyz = sqrt( ays*ays+azs*azs);
float rotX = atan2(axs,dyz);
float rotY = atan2(ays,dxz);
printf(" %f \t %f \r", 180*rotX/3.14159, 180*rotY/3.14159);
fflush(stdout);
// fflush(stdout);
bcm2835_delay(100);
}
return 1;
}