Really accurate speedometer on iPhone - ios

I would like to develop a mobile app for iPhones, that calculates time needed to reach a given velocity. For example: I'm in my car, open the app, choose 100km/h and when I accelerate the app should start to count time and it stops counting just in the moment when I reach 100km/h. It should be very accurate.
I heard about two solutions. First is to use the accelerometer/gyroscope, but some people told me it's bad idea, because I won't be able to calculate time on longer distances. The second option is to use GPS, but on the other hand it can be not as accurate as I want it to be.
So I need suggestions, which option is better and why.
My targets are iPhones 4s and newer.

If you want to be more precise than the GPS you will need to have some sort of sensor. Most similar apps and concepts will create a receiver that plugs into the car that the iPhone can connect to. This has the benefit of making all of the sensors in the car available to you. This is an example: https://www.automatic.com/how-automatic-works/

Related

Is it possible to work with an connection range BLE?

For one of our projects i'm looking for a way to only let centrals (native iOS or Android app) connect with the perhiperal when they are inside a defined connection range (distance around the perhiperal).
I know that BLE is not designed for distance measuring but i hoped there is a reliable way to make a difference between centrals in a range <2m from the perhiperal and centrals >3,5 meter from the perhiperal.This means i do not need to measure the exact distance.
An important thing to mentoin is that our perhiperal can be located in an "open field" situation but also in situations where it is surounded with walls or concrete for example in a entry floor of a building or a carpark.
Another possible issue is that the central can be inside a car but if this is the case, all centrals for the concerning perhiperal are inside a car. Ofcourse it can be different cars.
Note that there is max 1 perhiperal at the time inside the connection range.
In our current version we developed an formulla what uses the received RSSI strength to estimate the distance. Unfortunately we cannot get this working reliable enough. Maybe we need to use another formulla or calibration method or whatever, we really tried many things during the last 6 months.
The concrete question is:
Is it technically possible to achieve the target as described above and when yes, what is the way to achieve the target above? We are open for specific BLE antenna's or specific designed casings for the BLE antenna or whatever is needed. It is also okay when we need to build an calibration application or specific hardware to calibrate our perhiperals, for each perhiperal, so we are realy open minded for any solution as long as it works reliable!
When more info is required to give an answere, please let me know what is missing and i will complete the info.
Unfortunately, it is like you said, you cannot use Bluetooth or Bluetooth Low Energy for short distance/range measurements. Bluetooth was just not designed that way. You want to get accurate reliable measurement for something between 2-3.5, this is way too small for BLE to be capable of that. I know that this is not what you want to hear, but I have already tried this and wasted many months on this before.
The only thing I can recommend if you really really need to continue down this path is that in order to get a more reliable outcome, you will need many many devices that are measuring the RSSI simultaneously, and then those devices need to be talking to each other to get an average RSSI measurement. You may also want to look at configuring the Tx power based on the average readings that you get, i.e. the closer the device gets, you lower the Tx power of both the scanning and advertising devices. Finally, directional antennas can be used if you are planning to use non-Android non-iOS devices for scanning, but this will be tricky if the only antenna you can change is that of the peripheral.

HKHealthKit Watch OS - Calculate velocity or 'Pace'

This is a general question seeking advice on the pattern required to calculate a user's velocity / pace / speed, when running or swimming.
Specifically, I want to be able to calculate this from watch OS, disconnected from the companion phone.
With GPS capabilities of Watch 3 / Watch OS 10.0 would the best approach be to:
Start Location Manager
Calculate distance and time between location points...
Calculate average speed?
Or are there better alternatives?
There is a good article here https://www.bignerdranch.com/blog/watchkit-2-hardware-bits-the-accelerometer/ that recommends using CoreMotion for device speed. However, this in my view would rather represent the 'device-speed' and not necessarily the user's speed over distance.
Any advice or experiences would be much appreciated.
Thanks.
The article you linked to is for WatchOS 2, not Watch 2. The motion tracking is pretty good, but to get accurate device speed you will still need to use the GPS.
If you don't need to do any other location related calculations, and don't need real time data (EDIT you can get near real time data with an HKAnchoredObjectQuery. This is sufficient for most situations) then you don't need to start location manager, just an HKWorkoutSession. This will default to using the GPS or Motion Data (which ever is more accurate/available at the time) and manage everything for you. When the workout is over, you can query for the distance samples and calculate pace from that.
If you need live motion data then the steps you outlined are correct, however you should check that the user is outdoors first. If the user is indoors or has a weak GPS signal switch to using Motion Data (and be sure to set the HKMetadataKeyIndoorWorkout appropriately if using HealthKit).

Indoor positioning on iOS with Core Location - not accurate?

Using the sample code provided from WWDC, I've been trying to write a simple proof-of-concept app that performs indoor positioning in my office building. I have a floor plan image and replaced the standard image in the demo code. I've also done the requisite mapping of GPS coordinates to pixels for the two anchor points.
When I run the app in the simulator and specify static GPS coordinates, I see the position updated as expected in the simulator. When I run it on my phone, however, the experience isn't nearly as seamless as Apple advertised in the video. On my iPhone 5s, the positioning is all over the place, and rarely anywhere close to accurate. Even sitting next to a window with a clear line-of-sight to the sky I still get very inaccurate results.
I would assume that this might have something to do with our physical layout, WiFi topology, or other such parameters. However, I also noticed that Apple has a portal where you can register your facility for use with indoor positioning. Does this have something to do with the poor results in my app? I can't imagine how Apple would be able to help with such a scenario, but thought it might have something to do with it.
Are there other steps I should take to increase the accuracy of my app? Is there a way to leverage iBeacons for improved positioning indoors? I haven't found any documentation indicating so, but thought maybe someone here would know.
You're right, Apple has the portal available at https://mapsconnect.apple.com
At this portal you can add your venue and Apple will guide you on setting it up. However, your venue must have all of the following attributes:
Accessible to the general public
Annual visitors in excess of 1 million per year
Availability of complete, accurate, and scaled reference maps
Wi-Fi throughout the area
Associated app that's authorized by venue owner
If your venue has all the required attributes, then you also will need to answer these questions about your usage:
How are you planning to use indoor positioning? (Ads, Navigation, Delivering content)
How many venues would you like to enable with indoor positioning?
What type of venue do you have? (Airport, Hospital, Museum, Mall, Office)
What type of floor plans do you have? (CAD, BIM, GeoJSON, AI, PDF, PNG, etc)
Are the venues equipped with Wi-Fi and/or iBeacon?
Name of the largest venue
Address of the largest venue
Once you have completed the entire form and jumped through the last hoop, you will be brought to a page that confirms the details. Once done, it's all in their hands and they will contact you.
Indoor Positioning does not work well without addional devices like iBeacons.
There is no useable GPS receivement in buildings, the reflected signal is often far worse than 50m .
GPS might work indoors if it is a single floor building with a thin roof, but this is usually not the case in indoor buildings.
The only thing that works well, is to buy some iBeacons and mount them at various locations in the office.
You have to manage the location of that beacons: they only send you an id, and (maybe?) the distance to that iBeacon. (Please check wheter you get distance to beacon)
But ios LocationService will not use that iBeacons.
So either use iBeacons or forget your project. There is no well working solution for indoor positioning. Some use magnetic fields, there is even an App for that, but this needs measuring your whole office in detail.
Why don't you try with the indoor SDK which can be integrated in iOS applications. Also try to give the accuracy level appropriately when you use location framework API.

CMMotionActivityManager ignores cycling

I've been researching the new M7 chip's CMMotionActivityManager, for determining whether the user of the device is walking, running, in a car, etc (see Apple Documentation). This seemed like a great step forward over trying to determine this previous from using LocationManager and accelerometer data only.
I notice however that CMMotionActivityManager does not have a cycling activity, which is disappointing, and almost a deal-breaker for complete usage as a new activity manager. Has anyone else found a convenient way to use CMMotionActivityManager with cycling also without having to reincorporate CMLocationManager + accelerometer just to try to test for cycling too?
Note, this also does not include general transport options for things like a Train. For instance, I commute an hour a day on the train. Automotive could be made more generic at least, similar to how Moves uses Transport.
CMMotionActivity has these defined motion types only:
stationary
walking
running
automotive
unknown
Useful notes from Apple's code, that does not necessarily solve the issue, but is helpful:
CMMotionActivity
An estimate of the user's activity based on the motion of the device.
The activity is exposed as a set of properties, the properties are not
mutually exclusive.
For example, if you're in a car stopped at a stop sign the state might
look like:
stationary = YES, walking = NO, running = NO, automotive = YES
Or a moving vehicle, stationary = NO, walking = NO, running = NO,
automotive = YES
Or the device could be in motion but not walking or in a vehicle.
stationary = NO, walking = NO, running = NO, automotive = NO. Note in this case all of the properties are NO.
[Direct Source: Apple iOS Framework, CoreMotion/CMMotionActivity.h #interface CMMotionActivity, inline code comments]
First of all its your question or kind of informative details on M7?
Has anyone else found a convenient way to use CMMotionActivityManager
with cycling also without having to reincorporate LocationManager +
accelerometer just to try to test for cycling too?
See there is lots of confusion it will create if you want to check if activity is type of cycling ??because its just depend on accelerometer
accelerometer contain microscopic crystal structures that get stressed by accelerative forces, which causes a voltage to be generated.and from that voltage it can parse the result.. so what i know is its just classifies your speed and giving you result that its running walking or automotive so if you want to use cycling some time very fast very slow or medium so may be it will some time result in to walking or running or may be auotomotive so m7 can not clarify the thing if its automotive or cycling or running because there is not much of speed variance while you cycling.
Still while using for running and walking its some time gives wrong results in some cases.. so that will chances that your app will give wrong information too.
One more thing you asked is
Note, this also does not include general transport options for things
like a Train. For instance, I commute an hour a day on the train.
Automotive could be made more generic at least, similar to how Moves
uses Transport.
So Apple is also working on other mapping features. Apple is said to be planning notable updates to its Maps app in iOS 8, and the company is currently working on implementing both public transit directions and indoor mapping features (which Google already has on iOS).
http://www.macrumors.com/2013/09/12/apple-working-to-leverage-new-m7-motion-sensing-chip-for-mapping-improvements/ (Useful Link)
So, not sure if you still need an answer to that but here is the latest from iOs8 SDK
#property(readonly, nonatomic) BOOL cycling NS_AVAILABLE(NA, 8_0);
In session 612 at WWDC 2014, the two presenting Apple engineers provided some information: In the slides they stated:
Performance is very sensitive to location
Works best if device is worn on upper arm Best for retrospective use cases
Longest latency
Best for retrospective use cases
In the video they explain on the audio track (starting at about 11:00) that
Cycling is new, something we introduced in iOS 8.
Cycling is very challenging, and again you need the dynamics and so
it's going to be very sensitive to location.
If it was mounted on the upper arm the latency is going to be fairly
reasonable.
And if it's anywhere else, it's going to take a lot longer. So definitely I would not suggest using cycling activity classification as a hint for the context here and now. It's really something that you'll want to use in a retrospective manner for a journaling app, for example.
I made a simple test setup for iOS 8 and 9 and iPhone 5s and 6 and cycling was not detected - not a single time in over 1.5h cycling. If the new iPhone 6S makes good this major deficit in motion activity detection is unclear - Phil Schiller announced it in September 2015.
tl;tr
Currently, cycling detection in CoreMotion does not work as it works for stationary, walking, running, and car! It will be not detected and can be used retrospectively only.

Use similar technology as CMMotionActivity on older iPhones

I'm looking to use the CMMotionActivity for iPhone 5s's, but also want to be able to use similar functionality on older iPhone's, is this possible?
Could I create a less accurate alternative maybe, by tracking GPS and not using the M7 chip? Any advice/tutorials/sample code?
You can create your own algorithm which will utilize accelerometer data and estimate number of steps taken. Its not as accurate and its not a good idea to have 2 separate logic in the same app.
In case, you want to give it a try, check this answer..How to count steps using an Accelerometer?

Resources