'How to place a 3D model on a gps position in augmented reality?

I'm having huge issues at placing a 3d model on a specific gps position. Before opening the AR ViewController im downloading the model which means I also have the file path to the model. I've tried different things to place the downloaded model on a fixed gps location in AR.

I'm using Project Dent to achieve this but I'm not sure if it is even possible with that library.

I've tried loading the model (usdz file) into a SCNNode and then attaching it to a LocationNode which I then add to the sceneLocationView.

// Load model
let model = MDLAsset(url: (self.arConfig?.models.first!)!)
model.loadTextures()
    
let modelNode: SCNNode = SCNNode(mdlObject: model.object(at: 0))
modelNode.scale = SCNVector3(x: 30, y: 30, z: 30)
    
// Create location node and add the model node to it
let locationNode = LocationNode(location: location)
locationNode.addChildNode(modelNode)
locationNode.continuallyUpdatePositionAndScale = true
locationNode.continuallyAdjustNodePositionWhenWithinRange = true
locationNode.scaleRelativeToDistance = true
locationNode.ignoreAltitude = true
    
// Add the location node for a given location which includes the model to the scene
sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: locationNode)

The result is that I'm able to see the model in front of my camera but it's not fixed to the specific location. It keeps moving with my camera when I move the camera up, to the side or go back a little.

I also looked into this answer. I used the code snippet for the "ThreeDNode" and tried initializing a SCNScene using the downloaded model which I then pass to the "ThreeDNode" class. I've tried initializing the scene using SCNScene(url, options) and converted the usdz file to a .scn file. However the scenes root node doesn't contain any geometry so the "ThreeDNode" class cannot set it to it's own.

I also searched for other frameworks which could help me achieve this but couldn't find any.



Solution 1:[1]

I used ProjectDent a few years ago, and found in general GPS coordinates would not be precise enough to place a model the way I expected. Moreover, the compass on the phone is not accurate enough for you to be able to place your model in the place where you expect with any reasonable accuracy, and the error aggregates the further away you place your model.

The only way to make it really stable and accurate is to perform localization within a mapped environment, which is possible in only a few cities using ARGeoAnchor .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 A. Claesson