Class AnchorManager
Encapsulation of spongy world (raw input) state. Its primary duty is the creation and maintenance of the graph of (spongy) anchors built up over the space traversed by the camera.
Inherited Members
Namespace: Microsoft.MixedReality.WorldLocking.Core
Assembly: cs.temp.dll.dll
Syntax
public abstract class AnchorManager : IAnchorManager, IDisposable
Remarks
Anchor and Edge creation algorithm:
Goal: a simple and robust algorithm that guarantees an even distribution of anchors, fully connected by edges between nearest neighbors with a minimum of redundant edges
For simplicity, the algorithm should be stateless between time steps
Rules
- two parameters define spheres MIN and MAX around current position
- whenever MIN does not contain any anchors, a new anchor is created
- when a new anchor is created is is linked by edges to all anchors within MAX
- the MAX radius is 20cm larger than MIN radius which would require 12 m/s beyond world record sprinting speed to cover in one frame
- whenever MIN contains more than one anchor, the anchor closest to current position is connected to all others within MIN
Constructors
AnchorManager(IPlugin, IHeadPoseTracker)
Set up an anchor manager.
Declaration
public AnchorManager(IPlugin plugin, IHeadPoseTracker headTracker)
Parameters
Type | Name | Description |
---|---|---|
IPlugin | plugin | The engine interface to update with the current anchor graph. |
IHeadPoseTracker | headTracker |
Properties
AnchorFromSpongy
Declaration
public virtual Pose AnchorFromSpongy { get; }
Property Value
Type | Description |
---|---|
Pose |
ErrorStatus
Error string for last error, cleared at beginning of each update.
Declaration
public string ErrorStatus { get; }
Property Value
Type | Description |
---|---|
String |
MaxAnchorEdgeLength
Maximum distance between two anchors to create an edge between them.
Declaration
public float MaxAnchorEdgeLength { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
Note that the MaxAnchorEdgeLength should be longer than the MinAnchorDistance, or else anchors will not be connected into a graph as they are created.
MaxLocalAnchors
Maximum number of local anchors in the internal anchor graph.
Declaration
public int MaxLocalAnchors { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
Zero or negative means unlimited anchors.
MinNewAnchorDistance
Minimum distance of head to nearest anchor to create a new anchor.
Declaration
public float MinNewAnchorDistance { get; set; }
Property Value
Type | Description |
---|---|
Single |
NumAnchors
Return the current number of spongy anchors.
Declaration
public int NumAnchors { get; }
Property Value
Type | Description |
---|---|
Int32 |
NumEdges
The number of edges connecting spongy anchors.
Declaration
public int NumEdges { get; }
Property Value
Type | Description |
---|---|
Int32 |
SpongyAnchors
Declaration
public List<AnchorManager.SpongyAnchorWithId> SpongyAnchors { get; }
Property Value
Type | Description |
---|---|
List<AnchorManager.SpongyAnchorWithId> |
SupportsPersistence
Whether the underlying anchors can be locally persisted and reloaded.
Declaration
public abstract bool SupportsPersistence { get; }
Property Value
Type | Description |
---|---|
Boolean |
TrackingStartDelayTime
Declaration
protected abstract float TrackingStartDelayTime { get; }
Property Value
Type | Description |
---|---|
Single |
Methods
CreateAnchor(AnchorId, Transform, Pose)
Platform dependent instantiation of a local anchor at given position.
Declaration
protected abstract SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose initialPose)
Parameters
Type | Name | Description |
---|---|---|
AnchorId | id | Anchor id to give new anchor. |
Transform | parent | Object to hang anchor off of. |
Pose | initialPose | Pose for the anchor. |
Returns
Type | Description |
---|---|
SpongyAnchor | The new anchor |
DebugLogExtra(String)
Declaration
[Conditional("WLT_EXTRA_LOGGING")]
protected static void DebugLogExtra(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message |
DebugLogSetup(String)
Declaration
[Conditional("WLT_LOG_SETUP")]
protected static void DebugLogSetup(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message |
DestroyAnchor(AnchorId, SpongyAnchor)
Platform dependent disposal of local anchors.
Declaration
protected abstract SpongyAnchor DestroyAnchor(AnchorId id, SpongyAnchor spongyAnchor)
Parameters
Type | Name | Description |
---|---|---|
AnchorId | id | The id of the anchor to destroy. |
SpongyAnchor | spongyAnchor | Reference to the anchor to destroy. |
Returns
Type | Description |
---|---|
SpongyAnchor | Null |
Remarks
The id is used to delete from any stored lists. If the SpongyAnchor hasn't been added to any lists (is still initializing), id can be AnchorId.Invalid.
Dispose()
Explicit dispose to release resources.
Declaration
public void Dispose()
Finalize()
GC release of resources.
Declaration
protected void Finalize()
IsTracking()
Declaration
protected abstract bool IsTracking()
Returns
Type | Description |
---|---|
Boolean |
LoadAnchors()
Load the spongy anchors from persistent storage
Declaration
public async Task LoadAnchors()
Returns
Type | Description |
---|---|
Task |
Remarks
The set of spongy anchors loaded by this routine is defined by the frozen anchors previously loaded into the plugin.
Likewise, when a spongy anchor fails to load, this routine will delete its frozen counterpart from the plugin.
LoadAnchors(IPlugin, AnchorId, Transform, List<AnchorManager.SpongyAnchorWithId>)
Declaration
protected virtual async Task LoadAnchors(IPlugin plugin, AnchorId firstId, Transform parent, List<AnchorManager.SpongyAnchorWithId> spongyAnchors)
Parameters
Type | Name | Description |
---|---|---|
IPlugin | plugin | |
AnchorId | firstId | |
Transform | parent | |
List<AnchorManager.SpongyAnchorWithId> | spongyAnchors |
Returns
Type | Description |
---|---|
Task |
RemoveSpongyAnchorById(AnchorId)
Remove all internal references to the anchor identified.
Declaration
protected void RemoveSpongyAnchorById(AnchorId id)
Parameters
Type | Name | Description |
---|---|---|
AnchorId | id | The anchor to forget. |
Remarks
It is not an error to pass in AnchorId.Unknown or AnchorId.Invalid, although neither will have any effect. It is an error to pass in a valid id which doesn't correspond to a valid anchor. This function should be called as part of any IAnchorManager's implementation of DestroyAnchor().
Reset()
Delete all spongy anchor objects and reset internal state
Declaration
public void Reset()
SaveAnchors()
Save the spongy anchors to persistent storage
Declaration
public async Task SaveAnchors()
Returns
Type | Description |
---|---|
Task |
SaveAnchors(List<AnchorManager.SpongyAnchorWithId>)
Declaration
protected virtual async Task SaveAnchors(List<AnchorManager.SpongyAnchorWithId> spongyAnchors)
Parameters
Type | Name | Description |
---|---|---|
List<AnchorManager.SpongyAnchorWithId> | spongyAnchors |
Returns
Type | Description |
---|---|
Task |
Update()
Create missing spongy anchors/edges and feed plugin with up-to-date input
Declaration
public virtual bool Update()
Returns
Type | Description |
---|---|
Boolean | Boolean: Has the plugin received input to provide an adjustment? |