有陀螺仪的情况下指南针不准问题
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
有陀螺仪的情况下指南针不准,而没有陀螺仪的情况下却是准确的。 这个问题的原因一般是由于android的sensor
manager那边在有陀螺仪的情况下虚拟出了
一个orientation sensor,同时去掉mag sensor提供的orientation sensor,但android提供的这个sensor可能并不一
定准确,所以出现了上述的情况。
解决方法是可以尝试去掉android虚拟出来的orientation sensor,用mag sensor自带的orientation sensor。
参考修改代码:
SensorService.cpp:
void SensorService:nFirstRef()
{
if (hasGyro) {
```````
// these are optional
// registerVirtualSensor( new OrientationSensor() ); //去掉这里
registerVirtualSensor( new CorrectedGyroSensor(list, count) );
}
·
if (hasGyro &&
(virtualSensorsNeeds & (1<<SENSOR_TYPE_ROTATION_VECTOR))) {
// if we have the fancy sensor fusion, and it's not provided by the
// HAL, use our own (fused) orientation sensor by removing the
// HAL supplied one form the user list.
if (orientationIndex >= 0) {
// mUserSensorList.removeItEMSAt(orientationIndex); //去掉这里
}
}
}
有陀螺仪的情况下指南针不准,而没有陀螺仪的情况下却是准确的。 这个问题的原因一般是由于android的sensor
manager那边在有陀螺仪的情况下虚拟出了
一个orientation sensor,同时去掉mag sensor提供的orientation sensor,但android提供的这个sensor可能并不一
定准确,所以出现了上述的情况。
解决方法是可以尝试去掉android虚拟出来的orientation sensor,用mag sensor自带的orientation sensor。
参考修改代码:
SensorService.cpp:
void SensorService:nFirstRef()
{
if (hasGyro) {
```````
// these are optional
// registerVirtualSensor( new OrientationSensor() ); //去掉这里
registerVirtualSensor( new CorrectedGyroSensor(list, count) );
}
·
if (hasGyro &&
(virtualSensorsNeeds & (1<<SENSOR_TYPE_ROTATION_VECTOR))) {
// if we have the fancy sensor fusion, and it's not provided by the
// HAL, use our own (fused) orientation sensor by removing the
// HAL supplied one form the user list.
if (orientationIndex >= 0) {
// mUserSensorList.removeItEMSAt(orientationIndex); //去掉这里
}
}
}
顶顶顶
