Skip to content

ARNavigationKit Aims to provide easy-to-use path planning For ARKit.

License

Notifications You must be signed in to change notification settings

ferdinandl007/ARNavigationKit

Repository files navigation

ARNavigationKit

ARNavigationKit Aims to provide easy-to-use path planning For ARKit. By automatically creating dynamic navigational maps during runtime.

Example

To run the Example project, clone the repo, and run pod install Example project for a ARKit Robot With path planning capabilities.

Requirements

iOS 10.0+
Xcode 10.0+
Swift 4.2+
And ARkit enabled device

Installation

ARNavigationKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

source 'https://github.com/ferdinandl007/ARNavigationKitPodSpecs.git'
pod 'ARNavigationKit','~> 1.0.0'

Usage

import the following.

import ARNavigationKit

When initialising the ARNavigationKit, I recommend a voxel size of 7cm when dealing with single room application. However you may want to increase the grit size for larger maps to reduce computation when computing Paths.

let voxelMap = ARNavigationKit(VoxelGridCellSize: 0.07)
voxelMap.arNavigationKitDelegate = self

Once your a session is running capture the feature points and add them into the map as follows. 10Hz should be sufficient to capture a good map and reduce computation to a minimum.

Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { _ in
    guard let currentFrame = self.augmentedRealitySession.currentFrame,
    let featurePointsArray = currentFrame.rawFeaturePoints?.points else { return }
    self.voxelMap.addVoxels(featurePointsArray)
}

ARNavigationKit needs to know about the ground height to detect obstacles, therefore use

extension ViewController: ARSCNViewDelegate {
  func renderer(_: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
       guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
       voxelMap.updateGroundPlane(planeAnchor)
  }

  func renderer(_: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
       guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
       voxelMap.updateGroundPlane(planeAnchor)
   }
}

To request a path.

voxelMap.getPath(start: SCNVector3, end: SCNVector3)

As Path calculation can take some time, a delegate method is called once the calculation is complete.

extension ViewController: ARNavigationKitDelegate {
   func getPathupdate(_ path: [vector_float3]?) {
    }	
   func updateDebugView(_ View: UIView) {
   }
}

Author

Ferdinand Loesch, ferdinandloesch@gmail.com

License

ARNavigationKit is available under the MIT license. See the LICENSE file for more info.

About

ARNavigationKit Aims to provide easy-to-use path planning For ARKit.

Resources

License

Stars

Watchers

Forks

Packages

No packages published