Unable to create Spatial Anchors

Hello, I am trying the spatial anchors provided by the new SDK 2.1.1, when I call the NRWorldAnchor.SaveAnchor method, it returns false with the following errors:

[Info][NativeMapping] NRPerceptionAcquireNewAnchor: InvalidArgument
NRKernal.DefaultLogHelper:Log(LogLevel, Object).
NRKernal.NativeMapping:AddAnchor(Pose)
NRKernal.Persistence.NRWorldAnchorStore:CreateAnchor(NRWorldAnchor)

[Error][NativeMapping] AddAnchor: InvalidArgument
NRKernal.DefaultLogHelper:Log(LogLevel, Object)
NRKernal.NativeErrorListener:Check(NativeResult, Object, String, Boolean)
NRKernal.NativeMapping:AddAnchor(Pose)
NRKernal.Persistence.NRWorldAnchorStore:CreateAnchor(NRWorldAnchor)
XrealSpatialAnchorsManager:CreateSpatialAnchor(Vector3, Quaternion, String)

Also, I don’t know if it is related, even before calling the SaveAnchor method, in the console, I have several times per second the following error:

[ERROR][NRSDK] get perception buffer failed:12970367450127412808
[Info][NativeTrack] GetFramePresentHeadPose: trackReasonRst=Success, lost_tracking_reason=NONE
NRKernal.DefaultLogHelper:Log(LogLevel, Object)
NRKernal.NativeHeadTracking:GetFramePresentHeadPose(Pose&, LostTrackingReason&, UInt64&)
NRKernal.NRFrame:GetFramePresentHeadPose(Pose&, LostTrackingReason&, UInt64&)

Thank you in advance for your support.

Hi, Enchaaner. From the log pieces you provided, I think it may be because the feature points were not recognized well before you created the anchor. Please make sure that the glass maps the surroundings. You can try to turn around and scan the things around you slowly.
Please try to add the following method in your script to check if the Anchor can be saved before the pose is well recognized by the glass.

Hi,

thank you for the answer.
I have tried several times, even after looking around for 2/3 minutes so as to properly map the room, but the error persists.
Do you have any other suggestions?

Could you please confirm if the error ‘Failed to save anchor’ printed in the log? And the save button is in green or red before you save the anchor.

There is a small error in my first post, my problem is not during saving, but during creation. If you notice from the stack, the exception is generated by the “NRWorldAnchorStore:CreateAnchor” method.

I haven’t tried saving an anchor yet, since it gives me an error as soon as I try to create it.

Hello, I tried with the latest version of the SDK, the error changed slightly, but it still doesn’t work. Any suggestions?

As you can see, it has now changed from “InvalidArgument” to “Failure”.

[Error][NativeMapping] AddAnchor: Failure.
NRKernal.DefaultLogHelper:Log(LogLevel, Object)
NRKernal.NativeErrorListener:Check(NativeResult, Object, String, Boolean)
NRKernal.NativeMapping:AddAnchor(Pose)
NRKernal.Persistence.NRWorldAnchorStore:CreateAnchor(NRWorldAnchor)
XRealSpatialAnchorsManager:CreateSpatialAnchor(Vector3, Quaternion, String)

Hi,

Thank you for providing the details. From the error message, it’s not immediately clear what the issue might be. To help us diagnose the problem, could you please provide more detailed logs?

  1. Device and Glasses Model:
  • Could you let us know the specific model of your device and the Xreal glasses you are using?
  1. Enable Detailed Logging:
  • Please enable detailed logging by creating a file named sdk_global.json in the files directory with the following content:
{
  "sdk": {
    "log_level": "0"
  }
}
  • This will help us get more comprehensive logs to analyze the issue.

Once you have the detailed logs, please share them with us, and we’ll investigate further.