Domanda

vedo che posso recuperare CMAttitude da un dispositivo e da esso ci riesco leggere 3 valori che ho bisogno (beccheggio, rollio e imbardata). A quanto ho capito, questo oggetto CMAttitude è gestito da CoreMotion che è un manager Sensor Fusion per il calcolo dei risultati corretti da bussola, giroscopio e accelerometro insieme (su Android è SensorManager Class).

Quindi le mie domande sono:

  1. Sono quei valori (beccheggio, rollio e imbardata) rispetto al nord magnetico e la gravità?

  2. Se in precedenza è corretto, come posso modificarlo per dare i risultati rispetto al nord geografico?

  3. Se un dispositivo (come iPhone 3GS) non dispone di un giroscopio, devo dirgli di manager o posso solo dire a me dare l'atteggiamento del dispositivo in base ai sensori che ha (< em> acc + Gyro + compas o acc + compas )

È stato utile?

Soluzione

  1. and 2:

iOS 5.0 simplifies this task. CMMotion manager has new method:


- (void)startDeviceMotionUpdatesUsingReferenceFrame:(CMAttitudeReferenceFrame)referenceFrame

As reference frame you can use this values:

  • CMAttitudeReferenceFrameXMagneticNorthZVertical for magnetic north,
  • CMAttitudeReferenceFrameXTrueNorthZVertical for true north.

If you want to do this with older iOS im afraid you have to calibrate this by yourself using current user location.

Try checkout this resources:

3. If device has no gyro, the deviceMotionAvailable property of CMMotionManger will be "NO" (it is equivalent to gyroAvailable property) and you cannot get attitude using device motion. The only thing you can do is to read accelerometer and magnetometer data directly.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top