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


C++ KalmanFilter::getUMatrix方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
	    float accelZMean = accelZ - accelMeans[2];

	    float gyroX = gyroData[i][0] - gyroMeans[0];
	    float gyroY = gyroData[i][1] - gyroMeans[1];
	    float gyroZ = gyroData[i][2] - gyroMeans[2];

	    float magX = magData[i][0];
	    float magY = magData[i][1];
	    float magZ = magData[i][2];

	    float pX = 0.0f;
	    float pY = 0.0f;
	    float pZ = 0.0f;

	    float vX = lastMeasurement[3] + (accelXMean * dt);
	    float vY = lastMeasurement[4] + (accelYMean * dt);
	    float vZ = lastMeasurement[5] + (accelZMean * dt);

	    float accelAngleZ = accelZ + (1.0f - accelMeans[2]);

	    // Calculate attitude_x from y and z component of gravity vector
	    float aX = atan2(accelY, accelAngleZ) * (180.0f / 3.14f);
	    // Calculate attitude_y from x and z component of gravity vector
	    float aY = atan2(accelX, accelAngleZ) * (180.0f / 3.14f);
	    // Calculate attitude_z from x and z component of mag reading
	    // (probably will not be accurate)
	    float aZ = atan2(magX, magZ) * (180.0f / 3.14f);

	    accelAnglesFile << aX << ", " << aY << ", " << aZ << endl;

	    float measurement[12] =
	    {
	        aX,
            aY,
            aZ,
	        pX,
	        pY,
	        pZ,
	        vX,
	        vY,
	        vZ,
	        0.0f,
	        0.0f,
	        0.0f
	    };

	    float measurement6[6] =
        {
            aX,
            aY,
            aZ,
            pX,
            pY,
            pZ
        };

	    kalmanFilter.getUMatrix() << gyroX, gyroY, gyroZ;
	    kalmanFilter6.getUMatrix() << gyroX, gyroY, gyroZ;

	    // Predict
	    kalmanFilter.predict();
	    kalmanFilter6.predict();

	    kalmanFilter.update(measurement);
	    kalmanFilter6.update(measurement6);

	    filteredStatesFile <<
	        kalmanFilter.getXMatrix()(0, 0) << ", " <<
	        kalmanFilter.getXMatrix()(1, 0) << ", " <<
	        kalmanFilter.getXMatrix()(2, 0) << ", " <<
	        kalmanFilter.getXMatrix()(3, 0) << ", " <<
	        kalmanFilter.getXMatrix()(4, 0) << ", " <<
	        kalmanFilter.getXMatrix()(5, 0) << ", " <<
	        kalmanFilter.getXMatrix()(6, 0) << ", " <<
	        kalmanFilter.getXMatrix()(7, 0) << ", " <<
	        kalmanFilter.getXMatrix()(8, 0) << ", " <<
	        kalmanFilter.getXMatrix()(9, 0) << ", " <<
	        kalmanFilter.getXMatrix()(10, 0) << ", " <<
	        kalmanFilter.getXMatrix()(11, 0);
	    filteredStatesFile << endl;

	    filteredStatesFile6 <<
            kalmanFilter6.getXMatrix()(0, 0) << ", " <<
            kalmanFilter6.getXMatrix()(1, 0) << ", " <<
            kalmanFilter6.getXMatrix()(2, 0) << ", " <<
            kalmanFilter6.getXMatrix()(3, 0) << ", " <<
            kalmanFilter6.getXMatrix()(4, 0) << ", " <<
            kalmanFilter6.getXMatrix()(5, 0);
	    filteredStatesFile6 << endl;

	    memcpy(measurement, lastMeasurement, 12 * 4);
	    memcpy(measurement6, lastMeasurement6, 6 * 4);
	}

	filteredStatesFile.close();
	filteredStatesFile6.close();
	accelAnglesFile.close();

	return 0;
}
开发者ID:smhjn,项目名称:Kalman-3,代码行数:101,代码来源:Kalman.cpp


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