ARCore Geospatial API is a cloud localization service that allows clients to precisely geolocate smartphones with six degrees of freedom (6dof).
Unlike GPS, it can provide a <1m translational and ~1-2 degrees rotational accuracy. This is accomplished through visually matching your surroundings in streetview covered areas.
Dig into the API https://developers.google.com/ar/develop/geospatial
Here's a quick rundown on how to use the app:
To look behind the curtain and see the data generated via the Geospatial API, tap the menu button in the upper right and select the globe-shaped icon. Have fun planting!
The Geospatial APi is supported on most devices that run ARCore. To check your specific device visit https://developers.google.com/ar/devices
You can download and run Pocket Garden using this repo.
- In Google Cloud Console enable the ARCore api https://console.cloud.google.com/apis/library/arcore.googleapis.com
- Create a Google Cloud Console api key by visiting https://console.cloud.google.com/. Click APIs & Serviecs, and click Credentials.
- Create a new API key and if you choose to restrict it, make sure you enable the ARCoreAPI
- Clone this repo and open it in Unity version: 2021.3.1f1 LTS
- Add your API key in Project Settings > XR Plug-in Management > ARCore Extensions > Android API Key
- Build and deploy to your Android device
Generally core reuseable classes can be found in the Assets/_GeoAR Framework
folder, while files specific to this project like UI and plans have been organized into the Assets/_Pocket Garden
folder.
Load the default Unity scene in the Assets/_Pocket Garden
folder.
- Note the managers described below on the root Geospatial AR object.
The bulk of Geospatial API calls take place in GeospatialManager
class. You can use this to manage tracking state as well as accuracy. Place an instance on a scene object to begin updating. It inerfaces with all of the common ARCore and ARCore Extension libraires.
This is our base class for handling screen to real world interactions for touching PlaceableObject
s and intersecting ground planes.
This singleton contains a factory method CreateGroupAnchor
to create PlaceablesGroup
objects which store geospatial objects. It also is responsible for saving and loading and generally keeping track of these objects.
A PlaceablesGroup is a convenience class to use if you want to create an empty container that will track to a Geospatial Anchor. This is how we keep plants in the same place across different app sessions. To add plants to it, we have plants implement PlaceableObject
, and we add them to the group with the PlaceablesGroup.RegisterPlaceable()
method.
When when the application is closed, PlaceableObject data is serialized and saved as a GroupData
object, so we can restore it on app launch.
My location never localizes
Make sure you're in an outdoors area with Google Street View coverage, places like public parks may be tougher to localize. Make sure you also have data service, and not just GPS.
I can't initialize the app
Make sure you've created an API key in Google Cloud Console and enabled the ARCore API. A data service is also necessary to use this API.
Can I use the Pocket Garden assets in my own project?
Yes!