andrewhartar / arkit-corelocation Goto Github PK
View Code? Open in Web Editor NEWCombines the high accuracy of AR with the scale of GPS data.
License: MIT License
Combines the high accuracy of AR with the scale of GPS data.
License: MIT License
This technique is detailed on the Current Location Accuracy wiki, under improvements.
Have you looked into making ARCL build for iOS9/10, so one could package it with an iOS9+ app, and conditionally reveal ARCL functionality only on iOS11?
I was going to see what's involved in this, and wonder if you had looked at all.
I am trying to create simple application in which i place LocationAnnotationNode at a geo coordinate and want to grow and shrink its size depending upon the distance from it.
The problem is that as i go closer to the geo coordinate the LocationAnnotationNode repositions/resizes itself.
Also the LocationAnnotationNode is not placed at the exact location( geo coordinate).
Link of the video demo and code is below.
Please help me to figure out what am i doing wrong.
Demo Video
`
import UIKit
import SceneKit
import MapKit
import ARCL
import CoreLocation
class ViewController: UIViewController {
let sceneLocationView = SceneLocationView()
@IBOutlet var distancelabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let pinCoordinate = CLLocationCoordinate2D(latitude: 19.057396, longitude: 73.004699)
let pinLocation = CLLocation(coordinate: pinCoordinate, altitude: 10 )
let pinImage = UIImage(named: "pin")!
let pinLocationNode = LocationAnnotationNode(location: pinLocation, image: pinImage)
pinLocationNode.accessibilityLabel = "garden corner"//loc["place"]
pinLocationNode.scaleRelativeToDistance = true
sceneLocationView.locationDelegate = self
sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: pinLocationNode)
self.view.addSubview(sceneLocationView)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
sceneLocationView.frame = CGRect(
x: 0,
y: 0,
width: self.view.frame.size.width,
height: self.view.frame.size.height)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
sceneLocationView.run()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.view.bringSubview(toFront: distancelabel)
}
}
`
extension ViewController:SceneLocationViewDelegate{
func sceneLocationViewDidAddSceneLocationEstimate(sceneLocationView: SceneLocationView, position: SCNVector3, location: CLLocation) {
}
func sceneLocationViewDidRemoveSceneLocationEstimate(sceneLocationView: SceneLocationView, position: SCNVector3, location: CLLocation) {
}
func sceneLocationViewDidConfirmLocationOfNode(sceneLocationView: SceneLocationView, node: LocationNode) {
}
func sceneLocationViewDidSetupSceneNode(sceneLocationView: SceneLocationView, sceneNode: SCNNode) {
}
func sceneLocationViewDidUpdateLocationAndScaleOfLocationNode(sceneLocationView: SceneLocationView, locationNode: LocationNode) {
guard let currentLocation = sceneLocationView.currentLocation() else{return}
guard let nodelocation = locationNode.location else{return}
let trimCurLoc = CLLocation(latitude: self.trimround(currentLocation.coordinate.latitude, toDecimalPlaces: 7), longitude: self.trimround(currentLocation.coordinate.longitude, toDecimalPlaces: 7))
let distance = trimCurLoc.distance(from: nodelocation)
var scale = locationNode.scale.y
switch distance {
case 0.0...20.0:
scale = scale * 1.0
distancelabel.text = "\(distance) \(scale)"
break
case 20.01...40.0:
scale = scale * 0.8
distancelabel.text = "\(distance) \(scale)"
break
case 40.1...60.0:
scale = scale * 0.6
distancelabel.text = "\(distance) \(scale)"
break
case 60.01...100.0:
scale = scale * 0.4
distancelabel.text = "\(distance) \(scale)"
break
case 100.01...10000.0:
scale = scale * 0.3
distancelabel.text = "\(distance) \(scale)"
break
default:
break
}
locationNode.scale = SCNVector3(x: scale, y: scale, z: scale)
}
}
Hi,
I discovered this amazing library and I was wondering if it is possible to use custom UIViews, including UILabel etc, instead of a UIImage.
Is it necessary to convert the UIView to a UIImage or are there better ways to achieve that?
Thanks
Receiving these errors when trying to run the demo code from a new project with ARCL added as a Pod dependency:
'showFeaturePoints' is inaccessible due to 'internal' protection level
'bestLocationEstimate' is inaccessible due to 'internal' protection level
'locationManager' is inaccessible due to 'internal' protection level
I need to store additional information inside an LocationAnnotationNode. So I subclassed LocationAnnotationNode as MyLocationAnnotationNode, with an additional property called id.
Later when I did a hit test in sceneLocationVIew's touchBegan, I wasn't able to retrieve the additional id property, because the hit-result's SCNNode is not convertible to MyLocationAnnotationNode.
I tried another way by setting the SCNNode.name before adding them to sceneLocationView. However, when I do a hit test, the name info becomes nil.
What is the recommended way to store information in pins in the scene, and retrieve them later in hit test?
As some obviously have no sense of humor, let me clarify: I'm NOT actually demanding to have the code right now, or I'll go home screaming. It was a joke. I wasn't being rude, or disrespectful. It was a JOKE.
Is there a way we can get the points where a node is placed .?
Hi,
can you make the SceneLocationView class open
so it could be subclassed from another module?
Thanks.
I would like to access this library from my objective c project. Is there a way to do that? pls hep me :)
When I ran demo on iPhone X it starts and asks permissions then briefly shows camera view and then it hangs - anybody has same problem?
I am trying to load a view upon tapping the node on the AR view.
Anybody have tried to do it?
i run project 。but I don't see the effect that you have in Git. What did I do wrong
Hey,
i cant handle to insert multiple objects as in the demo GIF like Canary Wharf, O2 Arena, City of London etc.
How did you do that?
Best regards,
Thomas
i have been trying to do a UITapGesture for the node on the SceneLocationView.
However, it returns me with the error above.
` @objc func didTapped(_ recognizer: UITapGestureRecognizer) {
let sceneView = recognizer.view as! ARSCNView
let touchLocation = recognizer.location(in: sceneView)
let hitResults = sceneView.hitTest(touchLocation, options: [:])
guard let hitResult = hitResults.first else {
return
}
let node = hitResult.node
if let name = node.childNodes[0].name {
print(name)
self.selectedTeam = name
}
performSegue(withIdentifier: "locationDetails", sender: self)
}`
Hi,
Is it possible to display only X nearest nodes or nodes in Y meters radius from user's location or should I handle removing/adding nodes each time the location changes myself?
With orientToTrueNorth
activated, the scenes heading seems to move about 90°.
Not related to this repo, but figured I might get some guidance here -- Is there any equivalent technique for placing AR objects on lat / lon coordinates in ARCore? I'm hoping to experiment with this concept but have an Android device.
The basis for this already exists on the feature/mapkit branch.
See the 2nd point of the comment here for more details on what’s required:
#7 (comment)
Hi
I'm implementing a kind of POI view with ARKit-CoreLocation. In general it works great. Thanks guys. But now I came across a challenging Issue. If i have several POIs "behind" (when the user points to one direction and there are several pois). So how do I manage that i can ensure to see every POI? They should not "touch" eachother. They should stack.
Any Ideas?
Hi,
I'd like to say thank you for such a great lib.
I'm having a problem:
I added a SceneLocationView into my view controller's ViewDidLoad like this:
sceneLocationView = SceneLocationView()
sceneLocationView.showAxesNode = true
view.insertSubview(sceneLocationView, at: 0)
sceneLocationView.translatesAutoresizingMaskIntoConstraints = false
sceneLocationView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
sceneLocationView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true
sceneLocationView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true
sceneLocationView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
sceneLocationView.locationDelegate = self
After user tapped on a button, I added a new LocationNode whose coordinate is the same to current location's, but altitude is 0.5m lower:
if let currentLocation = sceneLocationView.currentLocation() {
let location = CLLocation(coordinate: currentLocation.coordinate, altitude: currentLocation.altitude - 0.5)
let annotationNode = LocationAnnotationNode(location: location, image: #imageLiteral(resourceName: "pin"))
sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: locationNode)
}
The node displayed correctly at first. However, when I moved the device around, the node also moved, sometimes its vertical position even jumps to about the same to the axes node's, even though its y-axis was about from -0.7 to -0.5
I wonder if I did something wrong.
Hello people, how are you? Without a doubt, it is an excellent library, thank you for sharing with the community, I am new to AR development, and I am amazed at the possibilities.
So, I'm trying to include several location points, but I did not have success, could give me some help, right now, thank you.
There’s some work going on on the /feature/mapkit branch which involves adding navigational nodes. Right now, because my knowledge of SceneKit and lighting is lacking, I’ve added a number of lights to each of these. This may be the cause of some slowness once you add a certain amount of them, and is also the cause of some side effects such as over lighting of other elements.
Perhaps we just need either a few lights for the entire scene? The goal is just to create some shadowing so you can differentiate the different sides, where if we don’t have lights then each side is equally lit and thus you just see the whole 3D shape as the same colour.
If someone with knowledge of SceneKit and lighting could contribute to this then that’d be great.
When self.scaleRelativeToDistance = true then no annotations are displayed at all. Any ideas?
This project depends on geolocalisation's accuracy / quality.
Location Manager is fine for most outdoor usages, but it quickly becomes out of usage in dense city areas (multipaths) or indoor.
In theses situations, buildings / areas are getting equipped with third-party geolocation systems, often relying on BLE.
In order to use ARKit-CoreLocation indoor, it would be interesting to be able to input location / orientation.
The idea would be if delegate is specified, use it, otherwise use location manager.
See "Fixing Heading with Recent Location Data" on the wiki for Current Location Accuracy for more details.
This can be tested in the sample project by enabling map view and debug mode.
The app crashes if you move some distance away from your starting location.
It seems to happen when ARKit removes a plane anchor, and removing this line configuration.planeDetection = .horizontal
resolves the issue.
Full crash attached
I would suggest adding @objc
tags so that the library can be called from Obj-C. If you agree I could PR on this.
Hi,
Is it possible to get all LocationAnnotationNode
in the SceneLocationView
?
Thanks
what can be a good solution to solve flikering the views, can we implement clustering in that case.?
In demo-app new points occur at your current position while tapping on the screen. I can find lines in code responsible for this.
I want to change the current location while tapping for another location and don't understand which variables are responsible for this
Do anybody know how to solve this issue?
See Changing State with ARTrackingState on the wiki for more details.
I have an application which adds about 10 pins/location nodes in the scene location view.
When the application first starts, the responsiveness is good, at about 60 FPS.
When the user started moving and after about 30 sec, the FPS steadily drops to about 5 fps and won't restore.
Instead of adding normal image, I tried to add 3D object as a location node in sceneLocationView. I can add and show the 3D object in the place of destination pin. But I could not look around that 3D object by rotating the camera of sceneLocationView. Can anyone explain me for this? I was stuck in this place. Thanks.
This project is awesome. My team are trying to integrate it in a currently existing project that manages all its dependencies using Carthage. Is this something you would be interested in? we would be happy to collaborate to add support for Carthage if that's something you are happy with.
Thanks!
See the last point of the comment here:
#7 (comment)
Last code commit it dated September 6th while ARCL pod last release was made in August. Thus, pod lacks some latest changes, including such useful feature as init(coder) in SceneLocationView.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.