Search code examples
iosaugmented-realityarkitworld-map

ARKit – How to generate a worldMap for big environment?


I'm developing 4-players game using ARKit. I know how to save and then to get a worldMap. It's not difficult.

sceneView.session.getCurrentWorldMap { worldMap, error in
    guard let map = worldMap
        else { self.showAlert(title: "Can't get current world map", message: error!.localizedDescription); return }

    guard let snapshotAnchor = SnapshotAnchor(capturing: self.sceneView)
        else { fatalError("Can't take snapshot") }
    map.anchors.append(snapshotAnchor)

    do {
        let data = try NSKeyedArchiver.archivedData(withRootObject: map, requiringSecureCoding: true)
        try data.write(to: self.mapSaveURL, options: [.atomic])
        DispatchQueue.main.async {
            self.loadExperienceButton.isHidden = false
            self.loadExperienceButton.isEnabled = true
        }
    } catch {
        fatalError("Can't save map: \(error.localizedDescription)")
    }
}

But I don't know how to track with iPhone the following place (it's 50x50 meters) to generate this worldMap.

enter image description here

Could you give me an idea how to track this space?


Solution

  • If you wanna effectively move within the real environment with AR objects around you, you should use the whole developer's arsenal for precise positioning: Core Location framework (it provides services for determining a device’s geographic location, altitude, orientation, or position relative to a nearby iBeacon), iBeacon framework and certified hardware for it (interactive possibilities for location awareness of iBeacon is especially cool for indoor navigation), Vision and Core ML frameworks (designed for use of a trained machine learning model to classify input data like signs and images).

    Before using the aforementioned frameworks you should track with iPhone the whole environment multiple times (every time adding new feature points to the existing array of features). Look at the picture below to imagine how point cloud looks like:

    enter image description here

    P.S.

    In addition to the above, ARKit 4.0 offers to developers such tools as ARGeoTrackingConfiguration with ARGeoAnchors and Scene Reconstruction feature (works when your device equipped with a LiDAR scanner).