当前位置: 首页>>代码示例>>C++>>正文


C++ MPU6050::init方法代码示例

本文整理汇总了C++中MPU6050::init方法的典型用法代码示例。如果您正苦于以下问题:C++ MPU6050::init方法的具体用法?C++ MPU6050::init怎么用?C++ MPU6050::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MPU6050的用法示例。


在下文中一共展示了MPU6050::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

int ImuTester::run()
{
	// Default is fail unless pass critera met
	m_pass = TEST_FAIL;

	// Register the driver
	int ret = m_sensor.init();

	// Open the IMU sensor
	DevHandle h;
	DevMgr::getHandle(IMU_DEVICE_PATH, h);

	if (!h.isValid()) {
		DF_LOG_INFO("Error: unable to obtain a valid handle for the receiver at: %s (%d)",
			    IMU_DEVICE_PATH, h.getError());
		m_done = true;

	} else {
		m_done = false;
	}

	while (!m_done) {
		++m_read_attempts;

		struct imu_sensor_data data;

		ret = ImuSensor::getSensorData(h, data, true);

		if (ret == 0) {
			uint32_t count = data.read_counter;
			DF_LOG_INFO("count: %d", count);

			if (m_read_counter != count) {
				m_read_counter = count;
				ImuSensor::printImuValues(h, data);
			}

		} else {
			DF_LOG_INFO("error: unable to read the IMU sensor device.");
		}

		if (m_read_counter >= num_read_attempts) {
			// Done test - PASSED
			m_pass = TEST_PASS;
			m_done = true;

		} else if (m_read_attempts > num_read_attempts) {
			DF_LOG_INFO("error: unable to read the IMU sensor device.");
			m_done = true;
		}
	}

	DevMgr::releaseHandle(h);

	DF_LOG_INFO("Closing IMU sensor");
	m_sensor.stop();
	return m_pass;
}
开发者ID:AD-Aleksandrov,项目名称:DriverFramework,代码行数:58,代码来源:test.cpp

示例2: main

int main() 
{
    pc.baud(9600);                              // baud rate: 9600
    mpu6050.whoAmI();                           // Communication test: WHO_AM_I register reading 
    wait(1);
    mpu6050.calibrate(accelBias,gyroBias);      // Calibrate MPU6050 and load biases into bias registers
    pc.printf("Calibration is completed. \r\n");
    wait(0.5);
    mpu6050.init();                             // Initialize the sensor
    wait(1);
    pc.printf("MPU6050 is initialized for operation.. \r\n\r\n");
    wait_ms(500);
    
    while(1) 
    {
     
     /* Uncomment below if you want to see accel and gyro data */
        
//        pc.printf(" _____________________________________________________________  \r\n");
//        pc.printf("| Accelerometer(g) | ax=%.3f | ay=%.3f | az=%.3f                \r\n",ax,ay,az);
//        pc.printf("| Gyroscope(deg/s) | gx=%.3f | gy=%.3f | gz=%.3f                \r\n",gx,gy,gz);
//        pc.printf("|_____________________________________________________________  \r\n\r\n");
//        
//        wait(2.5);
                
        filter.attach(&compFilter, 0.005);    // Call the complementaryFilter func. every 5 ms (200 Hz sampling period)
        
        pc.printf(" _______________\r\n");
        pc.printf("| Pitch: %.3f   \r\n",pitchAngle);
        pc.printf("| Roll:  %.3f   \r\n",rollAngle);
        pc.printf("|_______________\r\n\r\n");
        
        wait(1);
     
    }
}
开发者ID:baserkandehir,项目名称:mbed,代码行数:36,代码来源:main.cpp


注:本文中的MPU6050::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。