# Location Drift Mitigation Source: https://www.nianticspatial.com/docs/nsdk/how-to/vps/location_manager/?platform=swift `NsdkVpsSession.Configuration` allows you to customize VPS (Visual Positioning System) behavior including localization frequency, quality settings, and advanced features like temporal fusion. Use this class to optimize VPS performance for your specific use case. ## Important Notes 1. **Configuration Timing**: Configuration must be applied when the VPS session isn't running. 2. **System Defaults**: Setting numeric values to `0` uses system defaults, which are optimized for most use cases. Only override these if you have specific requirements. 3. **Feature Dependencies**: Some options work best together: - `temporalFusionEnabled` is most effective with `continuousLocalizationEnabled` - `interpolationEnabled` works best with `temporalFusionEnabled` - `gpsCorrectionForContinuousLocalization` requires `continuousLocalizationEnabled` 4. **Performance Trade-offs**: Higher request rates and compression quality improve accuracy but increase bandwidth usage and API quota consumption. 5. **GPS Requirements**: When `gpsCorrectionForContinuousLocalization` is `true`, ensure GPS location data is included in frames sent to NSDK. ## Configuration Properties - `continuousLocalizationEnabled` Enables continuous localization updates after initial anchor tracking. When enabled, VPS will continue to refine the device's position even after an anchor has been successfully localized. - `temporalFusionEnabled` Enables temporal fusion to smooth localization results over time. This provides more stable and accurate tracking by fusing results across multiple frames. - `interpolationEnabled` Enables interpolation between localization updates. This provides smoother motion between discrete localization results. - `gpsCorrectionForContinuousLocalization` Enables GPS correction for continuous localization. This is required when using `devicePoseAsGeolocation()` to convert VPS poses to GPS coordinates. ***Note:** When set to `true`, ensure GPS location data is included in frames sent to NSDK* - `deviceMapLocalizationEnabled` Enables device-side map localization. This allows localization using maps stored on the device rather than requiring cloud connectivity. - `cloudLocalizerInitialRequestsPerSecond` Controls the rate of cloud localization requests during the initial tracking phase (when first localizing an anchor). Higher values provide faster initial localization but consume more bandwidth and API quota. - `cloudLocalizerContinuousRequestsPerSecond` Controls the rate of cloud localization requests during continuous tracking (after initial localization). Lower values are typically used to maintain localization while reducing bandwidth. - `cloudTemporalFusionWindowSize` Size of the temporal fusion window in number of frames. This determines how many previous localization results are used when fusing results over time. - `jpegCompressionQuality` JPEG compression quality for images sent to the cloud for localization. Higher values provide better image quality but larger file sizes and more bandwidth usage. ## Complete Configuration Example Here's an example with all configuration options set to recommended values: ```swift var config = NsdkVpsSession.Configuration( continuousLocalizationEnabled: true, temporalFusionEnabled: true, interpolationEnabled: true, cloudLocalizerInitialRequestsPerSecond: 2.0, cloudLocalizerContinuousRequestsPerSecond: 0.5, cloudTemporalFusionWindowSize: 5, jpegCompressionQuality: 85, gpsCorrectionForContinuousLocalization: true, deviceMapLocalizationEnabled: false ) do { try vpsSession.configure(with: config) vpsSession.start() } catch { print("Failed to configure VPS: \(error)") } ```