ios - ARSessionConfiguration.WorldAlignment = .gravityAndHeading 不稳定的世界原点/对齐

标签 ios swift arkit

[注意:这个问题是在 iOS11/High Sierra 预发布期间针对 ARKit 测试版编写的。仅出于历史兴趣而保留]

当我将 ARWorldTrackingSessionConfiguration.worldAlignment 设置为 .gravityAndHeading 时,我发现世界原点的位置和方向不稳定。

场景打开后原点位置稳定。但是轴通常绕 Y 轴旋转 180 度或 90 度。

我还缺少其他设置吗?我运行的是 2017 iPad(vanilla,不是 Pro)和 Xcode 9 beta 2。我已经在这个 iPad 上测试了几个指南针应用程序,它们给了我正确的结果,所以我相信硬件工作正常。

override func viewDidLoad() {
    super.viewDidLoad()
    
    // Set the view's delegate
    sceneView.delegate = self
    
    // Show statistics such as fps and timing information
    sceneView.showsStatistics = true
    
    // Create a new scene
    let scene = SCNScene()

    // debug options
    let debugOptions: SCNDebugOptions = [ARSCNDebugOptions.showFeaturePoints,ARSCNDebugOptions.showWorldOrigin]
    sceneView.debugOptions = debugOptions

    // Set the scene to the view
    sceneView.scene = scene
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    
    // Create a session configuration
    let configuration = ARWorldTrackingSessionConfiguration()
    configuration.worldAlignment = .gravityAndHeading
    configuration.planeDetection = .horizontal

    // Run the view's session
    sceneView.session.run(configuration)
}

这里有一些示例(在所有示例中我都面朝南)。

正 X 和 Z 指向西和北(不正确,180 度异相):

enter image description here

正 X 和 Z 指向东南东和西南南(接近正确):

enter image description here

正 X 和 Z 指向东和南(正确),但原点偏移了几米:

enter image description here

正 X 和 Z 指向南和西(90 度异相):

enter image description here

来自.gravityAndHeading documentation:

The y-axis matches the direction of gravity as detected by the device's motion sensing hardware; that is, the vector (0,-1,0) points downward.

The x- and z-axes match the longitude and latitude directions as measured by Location Services. The vector (0,0,-1) points to true north and the vector (-1,0,0) points west. (That is, the positive x-, y-, and z-axes point east, up, and south, respectively.)

最佳答案

我意识到这是一个旧线程,但是即使发布了 ARKit 2 并且我在 iPhone 8 上使用 iOS 12、Xcode 10.1,我仍然得到不一致的世界起源。在某些情况下,蓝线应指向南,但实际上指向东或西。

我确实通过使用位置管理器标题尝试了 Sander 的建议,但这仍然不能 100% 保证我得到正确的开始方向。

谁有其他建议?

关于ios - ARSessionConfiguration.WorldAlignment = .gravityAndHeading 不稳定的世界原点/对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44896627/

相关文章:

ios - AudioKit - 立体声 channel 从输入翻转到输出?

ios - Twitter/Fabric 登录按钮只能工作一次

ios - 在 Swift 属性包装器中支持可选参数值

swift - 在 iOS 12.0+ 的 Swift 中更新眼睛变换位置

ios - SceneKit: Material 预览始终为黑色

c++ - SDL 2.0 Sprite 在 OpenGL 绘制后绘制倾斜(转换)

iphone - 如何确定滚动 UITableView 的触摸次数

IOS : UITableView is showing data when i tap on it

ios - 如何在 Swift3 中使用 Enum 在 UITableView 中分配自定义单元格?

arkit - iPad Pro 激光雷达 - 导出几何和纹理