Reputation: 21
I am referring to this Azure documentation to develop an ARKit iOS app to create and locate Azure Spatial Anchors: https://learn.microsoft.com/en-us/azure/spatial-anchors/how-tos/create-locate-anchors-swift
However, when I reach this step in the set-up of the project: _cloudSession?.processFrame(self.sceneView.session.currentFrame)
I receive the following error in Xcode:
*** Terminating app due to uncaught exception 'SCCException', reason: ' Invalid argument. (22). Invalid argument provided. RequestCorrelationVector: . ResponseCorrelationVector: ' *** First throw call stack: (0x18469986c 0x1996b4c50 0x1845924a4 0x106c00bac 0x104ab9ef8 0x104ab9f8c 0x1b8a3aec8 0x1b8a3d830 0x1b8a3de20 0x1b8a3e204 0x1b8ae09a0 0x1b8995958 0x1b8aa9be0 0x10c8896c0 0x10c899f14 0x1b8aa9b64 0x18796b6fc 0x187a44a80 0x1845f0dd0 0x184615fe8 0x184615378 0x18460f08c 0x18460e21c 0x1858bddf0 0x1b8995ea4 0x1b89961bc 0x1d0147cb0 0x1d0150778) libc++abi.dylib: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'SCCException', reason: ' Invalid argument. (22). Invalid argument provided. RequestCorrelationVector: . ResponseCorrelationVector: ' terminating with uncaught exception of type NSException
My code thus far is as follows:
class ViewController: UIViewController, ARSCNViewDelegate, ASACloudSpatialAnchorSessionDelegate {
@IBOutlet var sceneView: ARSCNView!
var _cloudSession : ASACloudSpatialAnchorSession? = nil
// Set this string to the account ID provided for the Azure Spatial Anchors account resource.
let spatialAnchorsAccountId = "****************************************"
// Set this string to the account key provided for the Azure Spatial Anchors account resource.
let spatialAnchorsAccountKey = "****************************************"
// Set this string to the account domain provided for the Azure Spatial Anchors account resource.
let spatialAnchorsAccountDomain = "eastus.mixedreality.azure.com"
override func viewDidLoad() {
super.viewDidLoad()
sceneView.delegate = self // set the view's delegate
sceneView.showsStatistics = false // show statistics
sceneView.scene = SCNScene()
// initializing the session
_cloudSession = ASACloudSpatialAnchorSession()
// start session
_cloudSession!.session = self.sceneView.session;
_cloudSession!.logLevel = .information
_cloudSession!.delegate = self;
// set auth
_cloudSession!.configuration.accountId = spatialAnchorsAccountId
_cloudSession!.configuration.accountKey = spatialAnchorsAccountKey
_cloudSession!.configuration.accountDomain = spatialAnchorsAccountDomain
_cloudSession!.start()
}
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
if let cloudSession = _cloudSession {
cloudSession.processFrame(sceneView.session.currentFrame)
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
let configuration = ARBodyTrackingConfiguration()
// Run the view's session
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Pause the view's session
sceneView.session.pause()
}
The sample iOS application is working for me, but following the steps of the set-up process for building a project from scratch has got me confused.
I am also unclear about this statement in the documentation: "...This object must implement the SSCCloudSpatialAnchorSessionDelegate protocol..."
Any help/insight would be greatly appreciated!
Upvotes: 0
Views: 142
Reputation: 11
You may want to checkout documentation on protocol ASACloudSpatialAnchorSessionDelegate
(Objective-C) for more details.
The code line _cloudSession!.delegate = self;
specifies that the class ViewController
is expected to follow ASACloudSpatialAnchorSessionDelegate
protocol and it does say so:
class ViewController: ... ASACloudSpatialAnchorSessionDelegate
, which is already a good start.
What missing in the file is probably implementation of the methods of ASACloudSpatialAnchorSessionDelegate
such as anchorLocated
, sessionUpdated
, and error
etc. These methods are typically called by ASACloudSpatialAnchorSession
during its operations. You can refer to the Swift sample on how these methods are implemented.
Moreover, it seems that you may want to change
let configuration = ARBodyTrackingConfiguration()
to
let configuration = ARWorldTrackingConfiguration()
since it is related to world tracking.
Upvotes: 1