distanceFilter property of CLLocationManager is not working properly for 50 meter with kCLLocationAccuracyNearestTenMeters - cllocationmanager

distanceFilter property of CLLocationManager is not works for 50 meter with kCLLocationAccuracyNearestTenMeters, but its works for 10 meter with kCLLocationAccuracyNearestTenMeters and also works for 100 meter with kCLLocationAccuracyHundredMeters.
Do I have to use kCLLocationAccuracyBest here for 50 meter distanceFilter (but that I do not want to use as its drain more power) or is there any solution for it ?

Related

Finding user's bearing from current location in 2D plane iOS

I am trying to access user's bearing from current location in my iOS app.
I am using below code to access it
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
heading = newHeading.trueHeading > 0 ? newHeading.trueHeading : newHeading.magneticHeading
}
However, it's not useful if we look at in 2D plane, where degree ranges from 0 to 360 clockwise. I want to send the bearing data to a different subscriber user through socket where an annotation with heading indicator(just like current location indicator with heading) on map can be displayed on iOS and Android. I am using a custom image which has heading indicator pointing up(12 O'Clock) to show on it on my other app.
Android has bearing which is the kind value I am looking for.
How can I get that value?
Thanks
Heading is determined by the magnetometer and indeed can't be used. It's a static value.
Bearing is determined by comparing subsequent (GPS) locations. It's a dynamic value over time.
iOS supplies bearing but names it 'course' with: locationManager(_:didUpdateLocations:).
You must read CLLocation's course property.
Because course can only be determined if the mobile device is moving, the course accuracy depends on speed and GPS accuracy. You must therefore use courseAccuracy to determine how/if you'll show this on the UI.

erratic world origin/alignment for ARSessionConfiguration.WorldAlignment = .gravityAndHeading

[Note: this question was written against the beta version of ARKit during the iOS11/High Sierra prerelease period. Preserved for historical interest only]
I'm seeing erratic placement and orientation for the world origin when I set the ARWorldTrackingSessionConfiguration.worldAlignment to .gravityAndHeading.
The position of the origin is steady after the scene opens. But the axes are often rotated 180 degrees or 90 degrees around the Y axis.
Is there an additional setting I'm missing? I'm running a 2017 iPad (vanilla, not Pro) and Xcode 9 beta 2. I've tested a few compass apps on this iPad and they give me correct results, so I believe the hardware is working correctly.
override func viewDidLoad() {
super.viewDidLoad()
// Set the view's delegate
sceneView.delegate = self
// Show statistics such as fps and timing information
sceneView.showsStatistics = true
// Create a new scene
let scene = SCNScene()
// debug options
let debugOptions: SCNDebugOptions = [ARSCNDebugOptions.showFeaturePoints,ARSCNDebugOptions.showWorldOrigin]
sceneView.debugOptions = debugOptions
// Set the scene to the view
sceneView.scene = scene
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
let configuration = ARWorldTrackingSessionConfiguration()
configuration.worldAlignment = .gravityAndHeading
configuration.planeDetection = .horizontal
// Run the view's session
sceneView.session.run(configuration)
}
Here are some samples (in all of them I'm facing south).
Positive X and Z point west and north (incorrect, 180 degrees out of phase):
Positive X and Z point east southeast and south southwest (close to correct):
Positive X and Z point east and south (correct), but origin is displaced a couple of meters:
Positive X and Z point south and west (90 degrees out of phase):
From the .gravityAndHeading documentation:
The y-axis matches the direction of gravity as detected by the device's motion sensing hardware; that is, the vector (0,-1,0) points downward.
The x- and z-axes match the longitude and latitude directions as measured by Location Services. The vector (0,0,-1) points to true north and the vector (-1,0,0) points west. (That is, the positive x-, y-, and z-axes point east, up, and south, respectively.)
I realize this is an old thread, however even with ARKit 2 release and I am using iOS 12, Xcode 10.1 with iPhone 8, I am still getting inconsistent world origin. In some cases where the blue line should be pointing to South, it is actually pointing to East or West.
I did try Sander's suggestion by using the location manager heading, but it is still not 100% guarantee I am getting the right direction to begin with.
Anyone has any other suggestion?
I am getting occasional random world origin, where Y axis is NOT aligned with gravity, but is at maybe a 45 degree tilt. This is on Xcode 9.1 (beta) and iOS 11.0.3. If I reset the session, it redetects the Y axis correctly. (I am using gravityAndHeading).
As for heading, I am in a new downtown multi-story metal/brick/stucco building. Indoor Magnetic North detection is almost impossible. I have tested this extensively with many different devices. (I was doing drone navigation). The symptom was a floating north due to extremely low magnetic field. So sometimes it worked, but could change even +-90degrees in a few seconds.
It looks like you are testing indoors, with some brick walls...
I faced up with the same issue.
My suggestion as a workaround to use CLLocationManager's delegate method to get true north
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading)
In my experiments is shows more stable and correct results, although sometimes they are as wrong as .gravityAndHeading 's north.
No additional settings for this app are required. Your code is OK.
As you quoted from .gravityAndHeading documentation – longitude and latitude directions measured by Location Services. There is definitely a bug touching Location Services in Xcode 9 beta. I stumbled upon the same issue one year ago.
But now, when I'm using official release of Xcode 10, everything works fine. I tested it more than hundred times in different places (indoor and outdoor). A deviation from the true compass values is +2/-2 degrees.
Tested on iPhone X (MQA82LL) in iOS 12 (16A366).
macOS Mojave 10.14 (18A391), Xcode 10.0 (10A255).
Also, read this useful and informative article: Requesting Always Authorization. There are many tips.

CLLocationManager not giving same lat long coordinates for different iphones in same location

i am using LocationManager to get user location coordinates as below..
locationManager.requestAlwaysAuthorization()
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.delegate = self
locationManager.distanceFilter = 50
I noticed i get different coordinates when running on two devices iphone5s and iphone 6.and the distance between them is like about 70 -100 meters when i use distanceFromLocation method
Why is this happening?
How to get the best user location??
kCLLocationAccuracyBest is the best you can do regarding accurracy of a single position. It will take into account WIFI, GPS and radio signal and will usually only be a few meters off.
Nevertheless, if you are moving, set the distanceFilter to a lower value to make sure you are notified more often about the new position.
Distance filter 50 means that you are notified if the user moves 50 meters, which could explain your inaccuracy.
The main problem is the distanceFilter set to 50.
Just remove that.
Under normal GPS condition accuracy will be about 6m.
So you can expect about 2*6 = 12m distance between two users at the same position.
However if users are inisde a building the situation becomes worse, and the distance between them probably increases.

CoreLocation iOS Swift Region Boundary Radius Define

I am new to swift and iOS development and i am using CoreLocation Framework API
I define each region like this
CLCircularRegion(circularRegionWithCenter: CLLocationCoordinate2D(latitude: queryLat, longitude: queryLong), radius: 10.0, identifier: tuple[location]))
I want to monitor 10 regions of about 300 meters around each other but when I run app and enter region it enter all region that i put in CoreLocation for some reason
I monitor all region with this function call
locationManager.startMonitoringForRegion(region)
and also when enter region this function call happen to tell me i enter new place by playing sound clip
func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {
//determine which region and play respective music
NSLog("Entering region... " + region.identifier)
//When you enter a region, play some music. This is hard coded for Testing.
audioPlayer.playMusic(region.identifier)
but when enter longitude latitude of just one out of the 10 places but CoreLocation go to every ten place at once? I try to make radius smaller but didnt work
Could you friends help me? Thanks :)

userLocation so different to CLLocation

I am using CoreLocation to plot my lat/long. This is displayed as Homer in the attached picture (http://i.imgur.com/IRRwOS0.png). I have kCLLocationAccuracyBest set:
self.locMgr.distanceFilter = kCLDistanceFilterNone;
self.locMgr.desiredAccuracy = kCLLocationAccuracyBest;
When I enable userLocation on the map (blue dot) there appears to be a pretty big difference between the accuracies. The blue dot is alot more accurate to my actual location.
How can I improve CoreLocations accuracy to position my MKAnnotations closers to my actual location?
Why am I getting this inaccuracy? userLocation is wifi based while Homer is GPS?
Screenshot:
Implement mapView:didUpdateUserLocation and, within that, set your annotation location to equal the mapView's userLocation.
I'm not entirely sure, but I assume it's probably due to mapview using a private framework for location.
China offsets the GPS for annotations other then users current location. More information can be found here:
http://www.sinosplice.com/life/archives/2013/07/16/a-more-complete-ios-solution-to-the-china-gps-offset-problem

Resources