在没有 GPS 的情况下获取设备移动方向 [英] Get Device Moving Direction without GPS

查看:29
本文介绍了在没有 GPS 的情况下获取设备移动方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当设备向绝对坐标方向移动(例如移动到 +x 或 -x)时,我可以使用哪个传感器进行检测.

With Which Sensor I Can Detect when device is moving to a direction In Absolute Coordinate(for example moving to +x or -x).

我需要准确的数据,所以我不能使用GPS.

I need accurate data,so i cannot use GPS.

完整的任务是使用 android 设备传感器绘制(在计算机中)绘图,这部分任务对我来说是未知的.

the Complete Task is to plot in paint(in computer) with android device sensors and this part of task in unknown for me.

推荐答案

我对你的问题有点困惑.你想把一个设备放在你的口袋里四处走走,然后把你走过的任何地方都画出来吗?或者您想像 3-d 鼠标一样在手中挥动设备以进行绘画?

I'm a little confused about what you're asking. Do you want to put a device in your pocket and walk around, and make a plot of everywhere you walked? Or do you want to wave the device around in your hand like a 3-d mouse, for painting?

对于后者,请参见上面阿里的建议.如果你想做运动跟踪,我可以告诉你:

For the latter, see Ali's suggestion above. If you want to do motion tracking, here is what I can tell you:

您可以轻松地使用加速度计(或重力,如果可用)和磁力计结合 SensorManager.getRotationMatrix() 来了解设备面向的方向.

You can easily use accelerometer (or gravity if available) plus magnetometer combined with SensorManager.getRotationMatrix() to know which direction the device is facing.

事实上,ROTATION 传感器会为您完成这一切.您只需要足够的数学知识即可将四元数转换为变换矩阵;很简单.

In fact, the ROTATION sensor does all this for you. You just need enough math to convert a quaternion into a transformation matrix; it's pretty easy.

(如果您正在尝试实现陀螺仪鼠标,您可以停止阅读.)

(If you're trying to implement a gyro mouse, you can stop reading here.)

然后您可以使用线性加速度传感器来确定设备移动的方向.这将是一种穷人的惯性导航系统.但这假设您启动应用程序时设备处于静止状态,并且传感器确实足够精确,可以执行您想要的操作.

Then you can use the linear acceleration sensor to determine the direction the device is moving. This would be a sort of poor man's inertial navigation system. But that assumes the device is sitting still when you start the app, and that the sensors are really precise enough to do what you want.

加速度会给你一个设备坐标向量.将该向量乘以您从 ROTATION 传感器或 SensorManager.getRotationMatrix() 获得的矩阵,以获得世界坐标中的加速度向量.然后随着时间的推移整合该向量以获得速度向量,然后随着时间的推移整合那个向量以获得自您启动应用程序以来移动的距离和方向.

The acceleration will give you a vector in device coordinates. Multiply that vector by the matrix you got from the ROTATION sensor or SensorManager.getRotationMatrix() to get an acceleration vector in world coordinates. Then integrate that vector over time to get a velocity vector and then integrate that vector over time to get distance and direction moved since you started the app.

错误会迅速累积.在它开始返回完全废话之前,这个算法可能最多只适用几分钟.您可以调整应用程序以检测设备何时不再移动,并利用该机会将速度矢量重置为零.

Errors will accumulate rapidly. This algorithm is probably good for a few minutes at best before it starts returning complete nonsense. You could tune the application to detect when the device is no longer moving, and use that opportunity to reset the velocity vector to zero.

坦率地说,这是一个非常难解决的问题.如果你解决了它,可能会有一个博士或至少几篇论文给你.搜索术语室内导航"以获取更多参考.

Frankly, this is a very very hard problem to solve. There's probably a PhD or at least a couple of papers in it for you if you solve it. Search for the term "indoor navigation" for more references.

但请记住,如果没有某种定位服务(网络或 GPS),就无法确定设备移动的方向或位置.

But bear in mind that without some sort of location service (network or gps), there's really no way to be sure which direction the device is moving or where it is.

我的理解是,所有现有的室内导航算法都依赖于偶尔获得 GPS 定位,或者通过了解正在导航的室内空间的布局并将其用作线索,或者通过了解附近 WiFi 发射器的位置并使用它们的信号生成修复的优势.

My understanding is that all the existing indoor navigation algorithms depend on getting occasional GPS fixes, or by knowing the layout of the indoor space being navigated and using it for clues, or by knowing the locations of nearby WiFi transmitters and using their signal strengths to generate fixes.

说真的,除非您在这里谈论的距离非常短,否则 GPS 是您最好的选择.

Seriously, unless you're talking very small distances here, GPS is your best bet.

这篇关于在没有 GPS 的情况下获取设备移动方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆