magnetometer

Android: Algorithms for SensorManager.getRotationMatrix and SensorManager.getOrientation()

独自空忆成欢 提交于 2020-01-01 03:42:05
问题 To get orientation as a from of euler angles (e.g., pitch, roll, azimuth) in Android, it is required to execute followings: SensorManager.getRotationMatrix(float[] R, float[] I, float[] gravity, float[] geomagnetic); SensorManager.getOrientation(float[] R, float[] orientation); In the first one, I realize that it uses a kind of TRIAD algorithms; Rotation matrix (R[]) is composed of gravity, geomagnetic X gravity, gravity X (geomagnetic X gravity) --- X is cross product. See codes below: float

Getting magnetic field values in global coordinates

这一生的挚爱 提交于 2019-12-30 11:56:06
问题 For an Android application, I need to get magnetic field measurements across the axis of global (world's) coordinate system. Here is how I'm going (guessing) to implement this. Please, correct me if necessary. Also, please, note that the question is about algorithmic part of the task, and not about Android APIs for sensors - I have an experience with the latter. First step is to obtain TYPE_MAGNETIC_FIELD sensor data ( M ) and TYPE_ACCELEROMETER sensor data ( G ). The second is supposed to be

CMCalibratedMagneticField doesn't update

我的梦境 提交于 2019-12-24 02:14:37
问题 CMCalibratedMagneticField returns 0 all the time. CMAcceleration returns values, CMMagnetometerData returns values too. Only CMCalibratedMagneticField doesn't, I need it because it is the magneticfield without bias. I'm testing on iPhone 4S. [MotionManager startDeviceMotionUpdatesToQueue:deviceQueue withHandler:^(CMDeviceMotion *motion, NSError *error) { CMCalibratedMagneticField f = motion.magneticField; //CMMagneticField t = motion.; //CMAcceleration s = motion.gravity; Works! //_xlabelnew

Magnet script for UNITY 3D

こ雲淡風輕ζ 提交于 2019-12-21 23:22:21
问题 I'm working on a Google Cardboard project, right now i have a demo for Android where u can look around in a special scene i build in UNITY 3D, everything is working fine & looking good, but what I really want is: I want to walk forward when I press the Google Cardboard magnet button. I found a few script's on the web, but I do not know exactly how to make these scripts work in my UNITY project. Can anybody help me further with this? 回答1: Assuming you are able to read the magnet input

How to build a compass with the iPhone?

为君一笑 提交于 2019-12-21 12:47:33
问题 After some searching on Google, I ask myself: Is it possible to build a compass (simple showing the heading/direction) with the iPhone 3G's GPS sensor? I have the suspicion, that this is only possible, if the device is moving. Any ideas are appreciated. 回答1: Yes, you are right, that's the only way. Although I think once you know the direction, you could track small movements of the phone from acceleration sensors and draw the direction accurately even if the original movement stops. Note:

Android device orientation without geomagnetic

江枫思渺然 提交于 2019-12-18 13:01:44
问题 I need to get device orientation. As I know usually used TYPE_ACCELEROMETER and TYPE_MAGNETIC_FIELD sensors. My problem is that SensorManager.getDefaultSensor returns me null for geomagnetic sensor. It returns null for TYPE_ORIENTATION sensor too. manager = (SensorManager) getSystemService(SENSOR_SERVICE); Sensor sensorAcc = manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), //normal object sensorMagn = manager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); //null orientationListener = new

Get orientation device in the iPhone for Opengl Es

≯℡__Kan透↙ 提交于 2019-12-13 12:20:36
问题 I'm trying to convert the geomagnetic and accelerometer to rotate the camera in opengl ES1, I found some code from android and changed this code for iPhone, actually it is working more or less, but there are some mistakes, I´m not able to find this mistake, I put the code, also the call to Opengl Es1: glLoadMatrixf((GLfloat*)matrix); - (void) GetAccelerometerMatrix:(GLfloat *) matrix headingX: (float)hx headingY:(float)hy headingZ:(float)hz; { _geomagnetic[0] = hx * (FILTERINGFACTOR-0.05) +

Magnetometer for Compass on iPod Touch 4G

久未见 提交于 2019-12-12 02:16:32
问题 I understand that it is not possible to get magnetic heading readings from the CoreLocation framework on an iPod Touch 4G, but it is possible to produce magnetometer readings using the CoreMotion framework. I also understand that I need to use CMMotionManager and set the deviceMotionUpdateInterval to achieve this. I can then start and stop the updates with - (void)startMagnetometerUpdates and - (void)stopMagnetometerUpdates respectivley. Now that I have my raw magnetometer data (x,y,z), how

iOS orientation estimation and heading error

落爺英雄遲暮 提交于 2019-12-11 22:02:53
问题 Instead of doing my own sensor fusion, I am using the Quaternions available from iOS and converting them to Euler angles. I walked around in a rectangle shape for few times and I observe that the shape is not as expected. I am plotting the shape by plotting the Yaw values. Please see below. It appears that the heading deviates significantly. I maintained the path while walking. How do I correct the Yaw values so I get correct rectangle shape. 来源: https://stackoverflow.com/questions/30941993