我已经为Android实现了GPS跟踪器。到目前为止,它的运行情况还不错,但是在计算轨道的右侧高度差时遇到了问题。我想总结设备“爬升”和“下降”的所有仪表。我在后台服务中将当前位置对象与上一个位置对象进行比较,然后将差异直接存储为数据库中的一列。如果我在赛道结束后总结这一点,我得到的值大约是使用气压计的自行车测速仪测得的2.5倍(1500m对650m)。
我知道GPS设备的测得高度不正确。有什么方法可以“标准化”测得的海拔高度?例如,我是否应该忽略所有2米以下的海拔变化?另一种可能性是使用额外的传感器,因为某些设备也具有气压计。但这只会对某些设备有所帮助。
感谢您对此问题的任何建议或提示!
编辑28.05.2013:
布莱斯的答案使我步入正轨。我开始在网上搜索,发现一个非常容易实现的非常简单的低通滤波器。
我在C++中做到了
代表一个航点的节点类:
class Node {
private:
double distance;
double altitude;
double altitudeup;
double altitudedown;
double latitude;
double longitude;
long timestamp;
public:
Node(double dist, double alti, double altiup, double altidown, double lat, double lon, long ts);
double getAltitude();
double getAltitudeup();
double getAltitudedown();
};
这是执行实际工作并计算总上升和下降值的函数:
void SimpleLowPass::applySLP()
{
double altiUp = 0;
double altiDown = 0;
double prevAlti = this->nodeList[0]->getAltitude();
double newAlti = prevAlti;
for (auto n : this->nodeList)
{
double cur = n->getAltitude();
// All the power of the filter is in the line
// newAlti += (cur - newAlti) / smoothing.
// This finds the difference between the new value and the current (smoothed)
// value, shrinks it based on the strength of the filter, and then adds it
// to the smoothed value. You can see that if smoothing is set to 1 then the
// smoothed value always becomes the next value. If the smoothing is set to
// 2 then the smoothed value moves halfway to each new point on each new
// frame. The larger the smoothing value, the less the smoothed line is
// perturbed by new changes.
newAlti += (cur - newAlti) / 20.0;
std::cout << "newAlti: " << newAlti << std::endl;
if (prevAlti > newAlti)
{
altiDown += prevAlti - newAlti;
}
if (newAlti > prevAlti)
{
altiUp += newAlti - prevAlti;
}
prevAlti = newAlti;
}
std::cout << "Alti UP total: " << altiUp << std::endl;
std::cout << "Alti DOWN total: " << altiDown << std::endl;
}
这是一个快速而肮脏的实现。但是,使用20进行平滑处理时,我会得到很好的结果。不过,我仍然需要录制更多曲目并比较结果。网站上也有独立于帧速率的实现,我在该网站上找到了该低通滤波器,我想使用移动平均实现。
simple low-pass filter
感谢您的所有回答!
最佳答案
如果设备有气压计,请使用气压计,但是无论哪种方式,您都必须应用某种平滑滤波器。在不查看您收集的数据的情况下,我只能推测原因,但这可能是由于与卫星失去同步时的尖峰引起的。