Do someone know, for each property of CMMotionmanager.deviceMotion and their subproperties, on what kind of hardware they are based on (magnetometer, accelerometer, gyroscope, ...) ?
My question is about HARDWARE, not software.
I need to know from which piece of hardware the CMMotionManager get its values to know on which kind of iPhone my CMMotionManager calls will work. And to write consequent text on my web site.
So what piece of hardware is use to build :
deviceMotion.attitude.roll
deviceMotion.attitude.pitch
deviceMotion.attitude.yaw
deviceMotion.rotationRate (sole gyroscope ? Iphone 4 / 4S with iOS4)
deviceMotion.gravity (sole accelerometer ? So it should work on all iPhones with iOS4)
deviceMotion.userAcceleration (sole accelerometer ? So it should work on all iPhones with iOS4)
deviceMotion.magneticFied (sole magnetometer ? Iphone 3GS / 4 / 4S with iOS4)
Update (hardware):
The deviceMotion property is only available on devices having both an accelerometer and a gyroscope. This is because its sub-properties are the result of a sensor fusion algorithm i.e. both signals are evaluated together in order to decrease the estimation errors. Especially gravity estimation on fast moved devices is still hard work when high precision is demanded (car navigation, satellite positioning,... face the same problems). Popular fusion algorithms are for instance the Kalman filter and derivatives but I guess the CMMotionManager's internal implementation is based on simpler and thus faster algorithms.
Given that, you have only the raw sensor data properties of CMMotionManger accelerometerData and gyroData that are related 1:1 to a sensor - and in case of iOS 5 magnetometerData. deviceMotion and all its sup-properties are the calculated result of the internal implementation of fusion algorithms.
Old answer:
iOS 4.x:
CMMotionManager supports gyroscope and accelerometer. It provides for isXxxAvailable and isXxxActive to query hardware capabilities and determine the status, e.g. accelerometerAvailable and accelerometerActive. Furtheron there is a simple but quite efficient sensor fusion algorithm called DeviceMotion if the device has an accelerometer and a gyroscope on board - compass is not needed and thus not used. Analog to the sensors you use deviceMotionAvailable and deviceMotionActive for getting information.
Magnetometer is only available via CLLocationManager.
I experienced sometimes trouble with deviceMotionActive when the app is getting to foreground again after suspending (got true although DeviceMotion was definitely stopped before).
iOS 5.x:
Magnetometer support is added to CMMotionManager and handled like the two other sensors.
General:
You can use CMMotionManager even on iPhone 3g (with iOS4). You don't have access to CMDeviceMotion but can query accelerometer updates. Thus you have to use low pass filtering to get a gravity estimation and it's far more worse than DeviceMotion.
You should not use the pre-iOS 4 interface UIAccelerometerDelegate.
See the reference
A CMMotionManager object is the gateway to the motion services
provided by iOS. These services provide an application with
accelerometer data, rotation-rate data, magnetometer data, and other
device-motion data such as attitude. These types of data originate
with a device’s accelerometers and (on some models) its magnetometer
and gyroscope.
Related
From what I know iPhone 5/5C do not have the motion processor like 5S and newer phones have, but when I request the motion permission the default alert with Allow and Don't allow still appears, even if I check before if the motion is available for device with MotionManager.isDeviceMotionAvailable. I would expect the alert not to appear for 5 and 5C.
What am I doing wrong here? Does 5 and 5C actually support motion?
No, you are getting this wrong; isDeviceMotionAvailable detects the presence of a gyroscope and an accelerometer. It's actually available since iOS 4, which came out way before the M7 motion coprocessor inside the iPhone 5s.
From Apple Documentation:
The device-motion service is available if a device has both an accelerometer and a gyroscope.
As #the4kman said the device motion is available through accelerometer and a gyroscope.
But what I actually meant and needed in this case is the user's activity, which is available through the M7 processor that is installed on 5S and newer and to check if that is available on a device I did CMMotionActivityManager.isActivityAvailable()
I have been building on top of the iphone augmented reality framework found here
but sadly, on mobiles without gyro (namely the 3GS) it doesn't work (as it states.)
Does anyone know of a fix to make it work with the motion sensors and compass heading instead ? Or would anyone be so bounty-hungry to provide the codes to a such framework ?
I will need a way to either make the vectors work, and if it is not possible, I will need to push through and just use heading only.
CoreMotion do work in devices like 3GS. However, this Framework pARk is for devices with gyroscopes (Runtime Requirements: iPad 2 or iPhone 4 running iOS 5.0 or later)
Gyroscope is a fundamental piece of inertial navigation systems (INS) and thus without it you'll have a severe loss in precision.
Check the paper: "Usability of apple iPhones for inertial navigation systems" for a comparison of the performance of iPhone 3GS and iPhone 4. The author's conclusion is:
However, the tests show that even with the use of filters
it is challenging to build a precise INS using sensors from
common devices because of their inaccuracies and high
error rate. The results show that the iPhone 4 can provide
tolerable results for a short time, but then the deviation
becomes too high because of the error rate. Currently we are
implementing a multi-dimensional Kalman filter to examine
possible enhancements. Furthermore we try to improve the
system by using more sensors from the iPhone 4, e.g. light
sensors and camera.
I believe you should think your app to support only iPhone4 or newer.
Can anyone help me to find some full specifications for the accelerometer of the iPhone 4S?
I tried to search something over or inside apple.com, however, I wasn't successful.
I would like some full specifications regarding the measurements of the accelerometer: measure scale, how often do the readings refresh, mainly everything about it.
The iPhone 4S uses the STMicro STM33DH 3-axis accelerometer and the STIMicro AGDI 3-axis gyroscope. I was unable to find a specifications sheet or product page.
Sources:
http://www.bigigloo.de/wordpress/wp-content/uploads/2011/04/CoreMotion.pdf
http://www.ifixit.com/Teardown/iPhone-4-Teardown/3130/2
The real accelerometer model is LIS331DLH, see this (emphasis mine)
Of the major design wins, Infineon found itself with the transceiver (marked with 'Apple 338S0626') and the X-GOLD 61x (marked '3833') baseband processor. [However], the most notable of parts though was from ST Micro, who provided not only the LIS331DLH 3-axis accelerometer (incorrectly identified as the STM33DH) [along with] the 3-axis digital gyroscope...
The Chipworks webpage also identified it as the LIS331DLH
The specifications for accelerometer are here.
I am trying to build an application wherein I need only the device rotation values. I want the application support to be as low as possible, so my preference would be to read the values from Gyroscope first if the device has its hardware (iPhone 4) or get the values from Accelerometer (iPhone 3G & 3GS).
I would like to write a RotationManager class which would handle interacting with either Gyroscope or Accelerometer, its internal operation will be abstract for the rest of the application. How do I design the RotationManager class? What are the things that should be considered in order to build a good reusable RotationManager instance?
Thanks,
Raj
Apple's Core Motion framework already does that job for you. Using the CMMotionManager, you can opt to receive accelerometer and gyroscope events separately or register for combined device motion events that automatically uses all the hardware that is available on the user's device.
I have an external device (some kind of sensor) that can do a measurement. This sensor can be connected to a PC via Bluetooth or USB cable, and it also comes with it's own software.
I want to develop an App for iPhone that will analyze the data that this sensor is measuring (for example creating a graph, calculating some equations etc.).
How can I make my iPhone to "recognize" this sensor, so the app will get the data that has been measured from the sensor?
Is there any manual which explains how to code this? Our preferred way of transferring the data is via Bluetooth, so there will be no need of using cables.
Thanks a lot!
You can't use Bluetooth to transfer data unless the device is custom designed in compliance with Apple's MFi program. Only those specially manufactured devices can be recognized by an iOS app.
You can use wifi for high bandwidth data, and perhaps audio for encoding low bandwidth data.
Not sure what kind of sensor you have but PASCO scientific has a Made For iPhone Bluetooth device called AirLink2 that works with their sensors. I don't think that could easily co-opt the device for your purposes ... but it might be possible. I mention this because there's an off chance that this would useful information. I am not trying to peddle hardware here ;-)