Windows UWP 三轴加速器接口的使用

对于一个非组态行业开发人员来说,通过官方文档来明白如何使用接口中提供数据还是很困难的。通过查找一些资料终于明白如何使用该接口,整理如下。在明白接口如何使用之后,参考“Implementing Positioning Algorithms using Accelerometers” 这篇文章应该能通过接口提供的加速度值计算出速度和位移。

  1. 数据的单位和取值范围

从加速器接口中我们可以得到 AccelerationX,AccelerationY,AccelerationZ,三个方向的加速度以及数据采样的间隔ReportInterval。

Interval的单位为范围:

其中ReportInterval的单位为milliseconds,比如16 ms,则频率为60HZ. 间隔不能小于设备支持的最小间隔(间隔越小,采样频率越高,也就是频率不能超过机器支持的频率)

Use the accelerometer - UWP applications | Microsoft Docs

Reportinterval使用结束时得重新设置为0,这点很重要,否则会浪费系统资源

Accelerometer.ReportInterval Property (Windows.Devices.Sensors) - Windows UWP applications | Microsoft Docs

AccelerationX,AccelerationY,AccelerationZ的单位和范围:

从这个文档 加速度传感器的数据手册各参数意义 - 百度文库 (baidu.com),可以知道标准接口得到的单位应该为g, 表示 9.8m/s2,比如1,则代表 9.8m/s2。参考微软stone中的App sensorInfo, 可以判定单位确实为g.

坐标系统如下:

Measure linear acceleration along X, Y, and Z axes - Simulink (mathworks.com)

取值范围呢

使用 Windows 10 中的加速度计(Accelerometer,重力传感器) - walterlv

不知道sensorInfo为什么会超过-1,和1

有了加速度为时间后,根据加速度公式,理想状态下可以计算出速度

You need to integrate acceleration to get the velocity.

acceleration - Calculate speed from accelerometer - Physics Stack Exchange

kinematics - Do you use the magnitude equation to get speed from an accelerometer? - Physics Stack Exchange

但是实际的应用中应该需要对采样数据做一些处理:

一种通过加速度传感器计算步行速度的移动终端及方法.ashx (wanfangdata.com.cn)

UWP接口示例:

Working with Sensors in UWP–Part 4–Accelerometer – Bruno Sonnino (msmvps.com)

当三个方法加速度超过1.5时,UI做出响应。

加速器的模拟:

Instrumenting the Accelerometer - Red Peregrine

使用 Windows 10 中的加速度计(Accelerometer,重力传感器) - walterlv

各种传感器的接口使用总结:

Android Sensor 传感器总结_hjwang1的专栏-CSDN博客_android sensor传感器

加速器的一些应用

(1条消息) 三轴加速度传感器角度值转换原理_zhaoyuaiweide的博客-CSDN博客_三轴加速度传感器

(1条消息) 三轴加速度计的原理和方法_gtkknd的专栏-CSDN博客_三轴加速度计

Getting Raw Accelerometer Events | Apple Developer Documentation

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值