gpt4 book ai didi

iphone - 计算加速度(驾驶汽车)

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:17:58 24 4
gpt4 key购买 nike

我正在尝试像应用程序“Dynolicious”一样复制加速度计算,但我不确定去哪里计算这个。我是使用 Core Motion 还是使用其他数字进行计算?

我已经尝试使用 Core MotionuserAcceleraion 值,但结果完全不像我正在寻找的那样。

coreMotion = [[CMMotionManager alloc]init];
[coreMotion startDeviceMotionUpdates];

//then every second it updates my label...

NSString *accel = [NSString stringWithFormat:@"%f", [[coreMotion accelerometerData]acceleration].x];
accelerationLabel.text = accel;

即我希望我的值显示为 0.4、-0.4 等。

最佳答案

您可能需要考虑低通过滤(如 this SO post 所示),这实际上是 Apple 指南(请参阅事件处理编程指南的 Isolating the Gravity Component from Acceleration Data)

If you are using the accelerometer data to detect the current orientation of a device, you need to be able to filter out the portion of the acceleration data caused by gravity from the portion of the data that is caused by motion of the device. To do this, you can use a low-pass filter to reduce the influence of sudden changes on the accelerometer data. The resulting filtered values then reflect the more constant effects of gravity.

您还可以查看“从加速度数据中分离瞬时运动”部分

If you are using accelerometer data to detect just the instant motion of a device, you need to be able to isolate sudden changes in movement from the constant effect of gravity. You can do that with a high-pass filter.

它继续给出一个简单的实现来实现这一点。

关于iphone - 计算加速度(驾驶汽车),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8157731/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com