Get Device Moving Direction without GPS

匆匆过客 提交于 2019-12-18 05:23:33

问题


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

I need accurate data,so i cannot use GPS.

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


回答1:


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:

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

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.

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.

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.

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.


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




回答2:


Since Android API level 24, there is a sensor called TYPE_POSE_6DOF. On phones that support this, it will use the sensors and camera tracking to provide both relative and absolute rotation and position in 3D space. https://developer.android.com/reference/android/hardware/Sensor#TYPE_POSE_6DOF https://developer.android.com/reference/android/hardware/SensorEvent#values

Another option might be to use ARCore, which will provide similar values for the camera pose. https://developers.google.com/ar/reference/java/arcore/reference/com/google/ar/core/Pose

Finally, this video gives a great overview of the Android sensors (pre-ARCore). Specifically, the section around 23:23 explains why doing a double-integral of the accelerometer force will not provide a useful representation of position. https://www.youtube.com/watch?v=C7JQ7Rpwn2k

(In case anyone was wondering, I just tried doing a double-integral of the accelerometers for a project I was working on, but I kept getting non-zero velocity when the device returned to rest, which caused significant drift in the position value, even over the course of 1 second.)



来源:https://stackoverflow.com/questions/27137239/get-device-moving-direction-without-gps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!