# Getting Started with VPS Source: https://www.nianticspatial.com/docs/nsdk/how-to/vps/adding_vps/?platform=swift This guide assumes that you've already gone through: - Importing the NSDK for Swift. - How to set up a basic AR session guide. # Adding VPS to your projects The `NsdkVpsSession` provides capabilities for precise localization using visual features. VPS can determine device position and orientation relative to a pre-mapped environment, enabling persistent AR experiences that maintain accuracy across sessions and devices. ### Setting Up and Configuring VpsSession The `NsdkVpsSession` manages the VPS feature lifecycle -- configuration, activation, and retrieval of the latest anchors data. It is created from an existing `NsdkSession` instance and works independently of other AR features. ```swift let vpsSession = nsdkSession.createVpsSession() let config = NsdkVpsSession.Configuration( continuousLocalizationEnabled: true, temporalFusionEnabled: true, gpsCorrectionForContinuousLocalization: true ) do { try vpsSession.configure(with: config) } catch { print("Configuration failed: \(error)") } ``` The available config settings: - **Continuous Localization:** (Default: off) Continue to send localization requests after localization. This mitigates drift but consumes more bandwidth. If enabled then you can also use: - **Interpolation Enabled:** (Default: off) Interpolates anchors positions instead of snapping them in place. - **Temporal Fusion Enabled:** (Default: off) Average/fused multiple localization results to provide a more stable localization. - **Cloud Localizer Continuous Requests per Second:** (Default: 0.2) Number of seconds between server requests after the first successful localization. The default of 0.2 translates to one request every 5 seconds. - **JPEG compression Quality:** (Default: 70) 0-100 value, determines the quality of the JPEG image sent to the servers for cloud localization. We have benchmarked that 50-90 quality for jpeg compression does not significantly impact the accuracy of the localization results. - **Cloud Localizer Initial Requests per Second:** (Default: 1.0) Number of seconds between server requests, prior to the first successful localization. - **GPS Correction for Continuous Localization:** (Default: off) If checked, VPS localization will use estimated GPS location from previously localized information instead of device GPS read. Intended for large and poor GPS area localization. - **Device Map Localization Enabled:** (Default: off) Whether to enable localization for locally-created Device Maps. ### Starting and Stopping Vps Start the VPS session to begin collecting sensor data needed for localization: ```swift vpsSession.start() ``` Once started, VPS begins collecting local device sensor data. Refer to the [How to Use Location AR with Code](https://www.nianticspatial.com/docs/nsdk/how-to/vps/location_ar_code/) guide to learn how to localize against maps. To stop the VPS session, simply call: ```swift vpsSession.stop() ``` After stopping, you can reconfigure and restart the session. All anchor tracking will be paused when stopped. > **Caution:** > > **Attention!** > > Be sure to stop the `VpsSession` before calling start again!