ARKit + CoreLocation (ARCL)
February 16, 2019
In this blog post, I’m going to talk about how I am updating the Example app in GeoTrackKit to leverage ARCL to allow me to:
- Track my location and create a “track”
- Save that track to my device
- Load the saved track to render it in AR to draw a path of arrows.
Motivation
Why do something like this? I have aspirations of creating an experience that shows a user a path along a recorded geo track. Think: I’ve taken a hike and I want to share it with people so that they can get visual instructions about where to go.
I’m not always great at reading maps and being able to show an arrow that points me in the direction of where to go could be pretty useful.
Existing App
Let me give some context about the GeoTrackKit Example app. This is merely an app that’s built to demonstrate the capabilities of GeoTrackKit. This is not a polished app; more like a testbed for the library it exposes.
The existing GeoTrackKit Example app didn’t save tracks, so I needed to update it to save track data. I figured I’d just go with simple: Write a ".track"
file and generate the filename using the date of the first point of the track. I needed this before I could do any prototyping with ARCL (at least for my needs). I added, tested and merged this PR in to allow me to record some tracks and save them off. Then I was ready to start with ARCL.
Updates - ARCL
I iterated on that and went through a sequence of updates like this:
- When you tap on a track, open a map for that track
- Add a menu button that opens the track in an ARCL View
- Render a sphere for each track point in AR, then test it out
This was the first iteration of my experimentation with ARCL. Ideally, though; I wanted something more compelling than just a sphere that represented each point. I iterated on this and built an arrow model for each point instead of the sphere. They looked alright, but the problem was that they weren’t pointing in any specific direction. It turns out that SceneKit nodes have an API for this: look(at:up:localFront:)
. After figuring this out, I was able to make a more compelling demo:
How can I mess with this thing?
- Clone the repo:
git clone https://github.com/intere/GeoTrackKit -b feature/ARCL && cd GeoTrackKit
- Open the project:
open GeoTrackKitExample/*.xcworkspace
- Xcode 10.1 at the time of this writing
- Set your development team for the
GeoTrackKitExample
target so that you can install on your own device - Pick your device for the run target
- Run it (by typing
⌘R
)
Once you get the app running, on the first tab (console), select “Start Tracking”:
After you’ve stopped recording your track, go to the Tracks
tab and open your track.
Finally, click the AR
button in the upper left hand corner of the screen and you’ll start up an AR experience from your track. A green stack of tori for the start and arrows for each point thereafter until the end.
Caveats
It’s worth mentioning that there are some issues with the app and with ARCL:
- ARCL gets about 15º of accuracy with respect to true north
- Your GPS will only ever get to 3 meters of accuracy
- The example app does not use any heuristics (currently) to manage memory efficiently, so you’ll notice performance issues at time.
- This is prototype code, not production ready code.
Summary
If you’re looking for a tool to help get you started messing with ARCL, this might be a good approach for you to try.
References
- GeoTrackKit: ARCL Pull Request
- At the time of this writing, I was at this commit