/vps-sdk-android

Visual Positioning System SDK for native Android apps

Primary LanguageKotlinOtherNOASSERTION

logo

VPS SDK (Android)

MavenCentral

This is Visual Positioning System SDK for native Android apps. Main features are:

  • High-precision global user position localization for your AR apps
  • Easy to use public API and premade Fragments
  • Integration in SceneForm Maintained

For more information visit our page on SmartMarket. If you want access to other VPS locations or want to scan your own proprerty, please contact us at arvrlab@sberbank.ru.

Requirements

  • Android SDK 24+
  • ARCore supported device

Installation

  1. Open your project's build.gradle. Add mavenCentral repository if it doesn't exist:

    allprojects {
        repositories {
            mavenCentral()
            ...
        }
    }
  2. In your module's build.gradle add dependency:

    dependencies {
        ...
        implementation "com.sberlabs:vps-sdk:0.6.1"
    }
  3. Sync Project with Gradle Files

Sample

There is an sample project in this repository.

Just clone the repository and build it as a regular Android app. Make sure that your device support ARCore.

Usage

Android Manifest

Add this in AndroidManifest.xml, if android min sdk less than 24:

<uses-sdk tools:overrideLibrary="com.arvrlab.vps_sdk, com.google.ar.sceneform.ux" />

By default VPS SDK has limited visibility in the Google Play Store to ARCore supported devices

<uses-feature
    android:name="android.hardware.camera.ar"
    android:required="true" />

To override visibility add this in your app's AndroidManifest.xml

<uses-feature
    android:name="android.hardware.camera.ar"
    android:required="false"
    tools:replace="android:required" />

Using VpsArFragment

You can use build-in VpsArFragment. You can add into xml or by code:

res/layout/main_activity.xml

<androidx.fragment.app.FragmentContainerView
    android:id="@+id/vFragmentContainer"
    android:name="com.arvrlab.vps_sdk.ui.VpsArFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

or

src/main/java/…/MainActivity.kt

supportFragmentManager.beginTransaction()
            .replace(R.id.vFragmentContainer, VpsArFragment())
            .commit()

Setup VpsService

Create a config for VpsService:

val vpsConfig = VpsConfig.getIndoorConfig(
                    <vpsUrl>,
                    <location_ID>
                )

or

val vpsConfig = VpsConfig.getOutdoorConfig(
                    <vpsUrl>,
                    <location_ID>
                )

Setup a VpsService:

val vpsService = vpsArFragment.vpsService

vpsService.setVpsConfig(vpsConfig)

//optional
vpsService.setVpsCallback(object : VpsCallback {
                override fun onSuccess() {
                }

                override fun onFail() {
                }

                override fun onStateChange(state: State) {
                }

                override fun onError(error: Throwable) {
                }
            })

Start VpsService:

vpsService.startVpsService()

Stop VpsService:

vpsService.stopVpsService()

VpsService in a custom ArFragment

For initialize VPS SDK in your app class add next code:

VpsSdk.init(this)

Create a new instance of VpsService:

VpsService.newInstance(): VpsService

You will also need to sync lifecycle of VpsService with lifecycle your ArFragment:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    vpsService.bindArSceneView(arSceneView)
}

override fun onResume() {
    super.onResume()
    vpsService.resume()
}

override fun onPause() {
    super.onPause()
    vpsService.pause()
}

override fun onDestroy() {
    super.onDestroy()
    vpsService.destroy()
}

After that you can use VpsService as mentioned above.

Place 3D model

You can add a custom 3D model using worldNode in VpsService

vpsService.worldNode

All object placed under worldNode will have correct global position after localization.

License

This project is licensed under Sber Public License at-nc-sa v.2.

Google SceneForm library is licensed under Apache License 2.0.