VLSDKManager
The core component responsible for managing VL API requests and performing real-time position estimation. It processes VL responses to calculate the device position in the global coordinate system.
Properties
| Property | Type | Description |
|---|---|---|
| playOnAwake | bool | Whether to start the session automatically when the VLSDKManager is created (default: true) |
| settings | VLSDKSettings | Settings of the VLSDKManager |
| arCamera | Transform | Transform of the AR camera |
| origin | Transform | Origin that converts the camera's local coordinate system into the global coordinate system in space. The Transform of the XR Origin |
| mainCamera | Camera | Main camera (Camera.main) |
| poseTracker | PoseTracker | Internal PoseTracker instance. For advanced users |
| trackerState | TrackerState | Current state of the VLSDKManager |
| version | string | VLSDK package version (read-only) |
Methods
Initialize
void Initialize()
Initializes the VLSDKManager system. Do not call it directly unless you are creating the VLSDKManager at runtime. If you create the VLSDKManager at runtime and assign VLSDKSettings yourself, you must assign the VLSDKSettings to the VLSDKManager before calling the initialization method.
Example:
m_VLSDKManager.settings = m_NewLocationSettings;
m_VLSDKManager.Initialize();
StartSession
void StartSession()
Starts the VLSDK session and begins sending VL requests. When playOnAwake is true, the session starts automatically without calling StartSession().
Example:
m_VLSDKManager.StartSession();
StopSession
void StopSession()
Stops the VLSDK session. It stops only the VL requests while retaining the current camera position and all recognition information.
Example:
m_VLSDKManager.StopSession();
ResetSession
void ResetSession()
Resets the VLSDK session, clearing all VLSDK state. When ResetSession() is called, the OnStateChanged(TrackerState) event is invoked with TrackerState.INITIAL.
Example:
m_VLSDKManager.ResetSession();
EnableResetByDevicePose
void EnableResetByDevicePose(bool active)
Sets whether to enable the session reset feature that uses the device pose. By default, VLSDK automatically resets the whole session when the top of the device faces the floor. If you pass false, the session is not reset even when the device pose is abnormal.
Parameters:
| Name | Type | Description |
|---|---|---|
| active | bool | true enables the automatic reset, false disables it |
Example:
EnableResetByDevicePose(false); // Do not reset automatically even if the device pose is abnormal.
EnableResetByDevicePose(true); // Reset automatically when the device pose is abnormal.
ChangeState
void ChangeState(TrackerState state)
Forcibly changes the VLSDK state. This is not used in normal situations; use it only for testing or special cases.
Parameters:
| Name | Type | Description |
|---|---|---|
| state | TrackerState | State to change to |
Example:
m_VLSDKManager.ChangeState(TrackerState.INITIAL);
SetTrackerConfig
void SetTrackerConfig(TrackerConfig config)
Changes the internal settings of the PoseTracker. This method is for advanced users.
Parameters:
| Name | Type | Description |
|---|---|---|
| config | TrackerConfig | TrackerConfig struct to apply |
Example:
TrackerConfig config = m_VLSDKManager.GetTrackerConfig();
config.requestIntervalAfterLocalization = 2000; // Change to 2 seconds
m_VLSDKManager.SetTrackerConfig(config);
GetTrackerConfig
TrackerConfig GetTrackerConfig()
Gets the current internal settings of the PoseTracker.
Returns:
| Type | Description |
|---|---|
| TrackerConfig | Current tracker config |
Example:
TrackerConfig config = m_VLSDKManager.GetTrackerConfig();
Debug.Log($"Request interval: {config.requestIntervalAfterLocalization}ms");
FindLocation
string FindLocation(double latitude, double longitude)
Finds the VL Location ID that corresponds to the given GPS coordinates. GPS Guide must be enabled.
Parameters:
| Name | Type | Description |
|---|---|---|
| latitude | double | Latitude |
| longitude | double | Longitude |
Returns:
| Type | Description |
|---|---|
| string | Location ID of the given position. Returns an empty string if no area matches |
Example:
string locationId = m_VLSDKManager.FindLocation(37.5665, 126.9780);
if (!string.IsNullOrEmpty(locationId))
{
Debug.Log($"Found location: {locationId}");
}
StartDetectingGPSLocation
void StartDetectingGPSLocation()
Starts GPS-based VL Location detection. When GPS Guide is enabled, it checks the GPS position every second. It is normally called automatically, so you do not need to call it yourself.
StopDetectingGPSLocation
void StopDetectingGPSLocation()
Stops GPS-based VL Location detection.
Events
VLSDKManager provides various events such as VL requests/responses, state changes, and position updates. Each event inherits from Unity's UnityEvent, so you can add listeners from the Inspector or from code.
OnVLPoseRequested
public VLRequestEvent OnVLPoseRequested
An event invoked every time a VL request is sent.
Event Data:
| Type | Description |
|---|---|
| VLRequestEventData | Request URL, secret key, request image, and so on |
Example:
m_VLSDKManager.OnVLPoseRequested.AddListener((requestData) =>
{
Debug.Log($"VL Request sent to: {requestData.Url}");
});
OnVLPoseResponded
public VLRespondedEvent OnVLPoseResponded
An event invoked every time a VL response is received.
Event Data:
| Type | Description |
|---|---|
| VLResponseEventData | Response status, VL position, confidence, etc. |
Example:
m_VLSDKManager.OnVLPoseResponded.AddListener((responseData) =>
{
if (responseData.Status == ResponseStatus.Success)
{
Debug.Log($"VL Success! Confidence: {responseData.Confidence}");
}
});
OnStateChanged
public ChangedStateEvent OnStateChanged
An event invoked every time the VLSDK state changes.
Event Data:
| Type | Description |
|---|---|
| TrackerState | INITIAL, NOT_RECOGNIZED, VL_PASS, VL_FAIL, VL_OUT_OF_SERVICE |
Example:
m_VLSDKManager.OnStateChanged.AddListener((state) =>
{
switch (state)
{
case TrackerState.VL_PASS:
Debug.Log("VL localization successful!");
break;
case TrackerState.VL_FAIL:
Debug.LogWarning("VL localization failed continuously");
break;
}
});
OnLayerInfoChanged
public ChangedLayerInfoEvent OnLayerInfoChanged
An event invoked when the layer information of the recognized space changes. The value of the datasetInfo field of the VL response is passed.
Event Data:
| Type | Description |
|---|---|
| string | Layer Info (e.g. "NAVER_GND_123") |
Example:
m_VLSDKManager.OnLayerInfoChanged.AddListener((layerInfo) =>
{
Debug.Log($"Layer changed to: {layerInfo}");
});
OnARFrameUpdated
public UpdatedARFrameEvent OnARFrameUpdated
An event invoked every frame. The raw frame data of the active AR framework is passed.
Event Data:
| Type | Description |
|---|---|
| ARFrame | Camera texture, position, rotation, intrinsic, etc. |
Example:
m_VLSDKManager.OnARFrameUpdated.AddListener((frame) =>
{
Texture cameraTexture = frame.texture;
Vector3 position = frame.localPosition;
});
OnPoseUpdated
public UpdatedPoseEvent OnPoseUpdated
An event invoked every frame. It passes the matrices related to the camera position updated in the global coordinate system.
Event Data:
| Name | Type | Description |
|---|---|---|
| viewMatrix | Matrix4x4 | View matrix of the camera |
| projMatrix | Matrix4x4 | Projection matrix of the camera |
| texMatrix | Matrix4x4 | Camera preview rendering matrix |
| relativeAltitude | double | Relative altitude (m) |
Example:
m_VLSDKManager.OnPoseUpdated.AddListener((viewMatrix, projMatrix, texMatrix, altitude) =>
{
Debug.Log($"Relative altitude: {altitude}m");
});
OnGeoCoordUpdated
public UpdatedGeoCoordEvent OnGeoCoordUpdated
An event invoked every time GPS position recognition is performed.
Event Data:
| Name | Type | Description |
|---|---|---|
| latitude | double | Latitude |
| longitude | double | Longitude |
Example:
m_VLSDKManager.OnGeoCoordUpdated.AddListener((latitude, longitude) =>
{
Debug.Log($"GPS: {latitude}, {longitude}");
});
OnRelativeAltitudeUpdated
public UpdatedRelAltitudeEvent OnRelativeAltitudeUpdated
An event invoked every time the relative altitude is updated.
Event Data:
| Name | Type | Description |
|---|---|---|
| altitude | double | Relative altitude (m) |
Example:
m_VLSDKManager.OnRelativeAltitudeUpdated.AddListener((altitude) =>
{
Debug.Log($"Altitude: {altitude}m");
});
OnObjectDetected
public DetectedObjectEvent OnObjectDetected
An event invoked when an object is detected.
Event Data:
| Type | Description |
|---|---|
| DetectedObject | Information of the detected object |
Example:
m_VLSDKManager.OnObjectDetected.AddListener((detectedObject) =>
{
Debug.Log($"Object detected: {detectedObject}");
});
Usage examples
Basic usage
using UnityEngine;
using ARCeye;
public class VLSDKController : MonoBehaviour
{
public VLSDKManager vlsdkManager;
public VLSDKSettings vlsdkSettings;
void Start()
{
// Assign VLSDKSettings and initialize
vlsdkManager.settings = vlsdkSettings;
vlsdkManager.Initialize();
// Register event listeners
vlsdkManager.OnStateChanged.AddListener(OnStateChanged);
vlsdkManager.OnVLPoseResponded.AddListener(OnVLResponded);
// Start the session (when playOnAwake is false)
vlsdkManager.StartSession();
}
void OnStateChanged(TrackerState state)
{
Debug.Log($"State changed to: {state}");
}
void OnVLResponded(VLResponseEventData data)
{
if (data.Status == ResponseStatus.Success)
{
Debug.Log($"VL Success! Position: {data.VLPosition}");
}
}
}
Session control
// Pause the session
public void PauseVL()
{
vlsdkManager.StopSession();
}
// Resume the session
public void ResumeVL()
{
vlsdkManager.StartSession();
}
// Reset the session (when the position was recognized incorrectly)
public void ResetVL()
{
vlsdkManager.ResetSession();
}
Checking the position based on GPS
void CheckLocation()
{
double latitude = 37.5665;
double longitude = 126.9780;
string locationId = vlsdkManager.FindLocation(latitude, longitude);
if (!string.IsNullOrEmpty(locationId))
{
Debug.Log($"The current position is in the {locationId} area.");
}
else
{
Debug.Log("Outside the service area.");
}
}
See also
- How to create a VLSDKManager: Creating a VLSDKManager
- Configuring VLSDKSettings: Creating VLSDKSettings
- Managing VL requests: Starting a session
- State management: TrackerState
- Using events: Using events