简体   繁体   English

Argon.js / A-Frame:来自getEntityPose()的局部坐标不是相对于RefereceFrame的

[英]Argon.js/A-Frame: local coordinates from getEntityPose() are not relative to refereceFrame

I am attempting to use argon.js to convert lla coordinates to local coordinates from a predefined reference frame. 我正在尝试使用argon.js将lla坐标转换为来自预定义参考系的本地坐标。 The method that has been recommended to me (as I understand it) requires that I create a cesium entity from a set of lla's, and then use that ceisum entity as a reference when creating subsequent cesium entities with other lla's. 向我推荐的方法(据我了解)要求我从一组lla中创建一个铯实体,然后在与其他lla中创建后续铯实体时使用该铯实体作为参考。

I have tried to do this using two methods: the first by creating the reference cesium entity in argon.js, and the second by creating an a-frame entity with a geopose, and then grabbing the cesium entity from a-frame entity's list of components. 我尝试使用两种方法来执行此操作:第一种方法是在argon.js中创建参考铯实体,第二种方法是使用geopose创建a框架实体,然后从a框架实体的列表中获取铯实体。组件。 I use argon.js to make all subsequent conversions. 我使用argon.js进行所有后续转换。

In both methods, I am having success creating the reference cesium entities, and it appears (to me, at least) that the converted cesium entities include the reference entities as their reference frame. 在这两种方法中,我都成功创建了参考铯实体,并且(至少在我看来)转换后的铯实体包括参考实体作为其参考框架。 However, the entityPose of the converted entities are still 0, 0, 0. My expectation is that the reference entity would be 0, 0, 0, and the converted entities would have local coordinates relative to that (eg 4, 8, 10). 但是,转换后的实体的entityPose仍然为0、0、0。我的期望是参考实体将为0、0、0,并且转换后的实体将具有相对于该坐标的局部坐标(例如4、8、10) 。 Additionally, in each case the entities have a poseStatus of 0 but the argon.js documentation only lists the possibilities as KNOWN = 1, FOUND = 2, and LOST = 4. 此外,在每种情况下,实体的poseStatus均为0,但argon.js文档仅列出了可能性,例如KNOWN = 1,FOUND = 2和LOST = 4。

I have included my code below, as well as some feedback from the inspector. 我在下面包括了我的代码以及检查员的一些反馈。 The objects that are returned are very large so I have only included what I think is relevant but please let me know if there are other attributes I should include. 返回的对象非常大,因此我只包含了我认为相关的内容,但是请告知我是否应该包含其他属性。 Also note, the code contains the two options I listed above with the second option commented out. 还要注意,代码包含上面列出的两个选项,第二个选项已被注释掉。

For some history see: 有关一些历史记录,请参见:

Using Geo-coordintes Instead of Cartesian to Draw in Argon and A-Frame 使用地理坐标而不是笛卡尔坐标在Argon和A框架中绘制

Argon.js: Error: A frame state has not yet been received Argon.js:错误:尚未收到框架状态

<!DOCTYPE html>
<html>
  <head>
    <title>Hello world</title>
    <script src="/socket.io/socket.io.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/geolocator/2.1.0/geolocator.js"></script>
    <script src="arframe/main/resources/js/aframe.js"></script>
    <script src="arframe/main/resources/js/argon.min.js"></script>
    <script src="arframe/main/build.js"></script>
    <script src="arframe/main/resources/js/CSS3DArgonRenderer.js"></script>
    <script src="arframe/main/resources/js/CSS3DArgonHUD.js"></script>
    <script src="arframe/main/resources/js/aframe-look-at-component.js"></script>
  </head>
   <body>

<h1>Hello world</h1>

<ar-scene>
  <!--OPTION 2-->
  <!-- <a-entity id='madRefFrame' referenceframe='lla: -84.31169 33.756128'></a-entity> -->
</ar-scene>

<script>

  // OPTION 1
  var app = Argon.init();

  // OPTION 2
  //var scene = document.querySelector('ar-scene');
  //var app = scene.argonApp;

  var Cesium = Argon.Cesium;
  var Cartesian3 = Cesium.Cartesian3;
  var ConstantPositionProperty = Cesium.ConstantPositionProperty;
  var ReferenceFrame = Cesium.ReferenceFrame;
  var ReferenceEntity = Cesium.ReferenceEntity;

  app.context.setDefaultReferenceFrame(app.context.localOriginEastUpSouth);

  app.updateEvent.addEventListener(function (frame) {

    if (Argon.PoseStatus.KNOWN) {

      // OPTION 1
      var madRefData = { lla : { x : -84.31169, y : 33.756128, z : 299 }};
      var madRef = Cartesian3.fromDegrees(madRefData.lla.x, madRefData.lla.y, madRefData.lla.z);
      var options = { position: new ConstantPositionProperty(madRef, ReferenceFrame.FIXED),
                      orientation:  Cesium.Quaternion.IDENTITY
                    };
      var madRefEntity = new Cesium.Entity(options);

      console.log('madRefEntity');
      console.log(madRefEntity);

      var madRefEntityPose = app.context.getEntityPose(madRefEntity);

      console.log('madRefEntityPose');
      console.log(madRefEntityPose);

      // OPTION 2
      // var madRefEL = document.querySelector('#madRefFrame');
      // var madRefFrame = madRefEL.components['referenceframe'];
      // var madRefEntity = madRefFrame.cesiumEntity;
      // 
      // console.log('madRefEntity');
      // console.log(madRefEntity);
      // 
      // var madRefEntityPose = app.context.getEntityPose(madP1Entity);
      // 
      // console.log('madRefEntityPose');
      // console.log(madRefEntityPose);

      // USED IN OPTIONS 1 AND 2
      var madP1Data = { lla : { x : -84.31169, y : 33.755602, z : 297 }};
      var madP1Ref = Cartesian3.fromDegrees(madP1Data.lla.x, madP1Data.lla.y, madP1Data.lla.z);
      var options = { position: new ConstantPositionProperty(madP1Ref, madRefEntity),
                      orientation:  Cesium.Quaternion.IDENTITY
                    };
      var madP1Entity = new Cesium.Entity(options);

      console.log('madP1Entity');
      console.log(madP1Entity);

      var madP1EntityPose = app.context.getEntityPose(madP1Entity);

      console.log('madP1EntityPose');
      console.log(madP1EntityPose);

    } else {
      // if we don't know the user pose we can't do anything
      console.log("we don't know.");
      return;
    };

  });

</script>
</body>
</html>

Feedback from inspector: 检查员的反馈:

A-Frame Version: 0.3.2 
three Version: ^0.76.1 
WebVR Polyfill Version: 0.9.15
Reality changed to: {"uri":"reality:empty","title":"Reality","providedReferenceFrames":["FIXED"]}
THREE.CSS3DArgonRenderer 76CSS3D
THREE.CSS3DArgonHUD 76CSS3D
THREE.WebGLRenderer 76
Reality changed to: {"uri":"reality:empty","title":"Reality","providedReferenceFrames":["FIXED"]}
reference frame changed to FOUND

madRefEntity
Object { _availability: undefined, 
       _id: "ae5fe824-12ea-4d7f-87e8-0eee0ca31008", 
       // METHOD 2
       // _id: "madRefFrame"
       _parent: undefined, 
       _propertyNames: Array[19], 
       ...
       _position:Object
        _definitionChanged:Object
        _referenceFrame:0
        _value:Object
          x:526169.6230387943
          y:-5282445.040716821
          z:3524154.8442182266
          // METHOD 2
          //x:526144.9834483624
          //y:-5282197.673182507
          //z:3523988.702129788
       ...
     }

madRefEntityPose
Object { position : { x: 0, y: 0, z: 0 },
       orientation: { w: 1, x: 0, y: 0, z: 0 },
       time: {dayNumber: 2457689, secondsOfDay : 81280.139927485},
       poseStatus: 0 }

madRefP1Entity
Object { _availability: undefined, 
      _id: "9ded96ab-961c-4ba3-b766-8c37e919877f", 
      ...
      _parent: undefined,
      _position: object
       _referenceFrame: object
         _id: "ae5fe824-12ea-4d7f-87e8-0eee0ca31008",
      // METHOD 2
      // _id: "madRefFrame"
         _orientation: object 
          _value: Object
           _w: 1,
           _x: 0,
           _y: 0
           _z: 0
         ...
         _position: Object
          _value:Object
            x:526169.6230387943
            y:-5282445.040716821
            z:3524154.8442182266
            // METHOD 2
            //x:526144.9834483624
            //y:-5282197.673182507
            //z:3523988.702129788
          ...
        ...
      ...
      _value:Object
        x:526172.6715934229
        y:-5282475.646478866
        z:3524105.2236363157
      ...
    }

madRefEntityPose
madRefEntityPose = { position : { x: 0, y: 0, z: 0 },
                  orientation: { w: 1, x: 0, y: 0, z: 0 },
                  time: {dayNumber: 2457689, secondsOfDay : 81281.12722016001},
                  poseStatus: 0 }

A few simple things, first. 首先,一些简单的事情。 To answer your question about Argon.PoseStatus , it is a bitmask, so 0 is implicitly "none of the above" (so, not known, not just been found or lost). 要回答有关Argon.PoseStatus的问题,它是一个位掩码,因此0暗含“以上都不存在”(因此,未知,不只是被发现或丢失)。 KNOWN is set when the pose is known, LOST or FOUND are set when the state has just changed between KNOWN and not KNOWN. 已知姿势时设置为KNOWN,当状态仅在KNOWN和KNOWN之间改变时,设置LOST或FOUND。

Thus, your line 因此,你的线

if (Argon.PoseStatus.KNOWN) {

needs to change to 需要更改为

if (userPose.poseStatus & Argon.PoseStatus.KNOWN) {

if you want to make sure we know where the user is located, which you need if you want to do things in local coordinates. 如果要确保我们知道用户所在的位置,并且要在本地坐标中进行操作,则需要该位置。

That said, madRefEntityPose is likely not being computed (it's poseStatus is 0) because the user's position is not yet determined. 就是说,由于尚未确定用户的位置, madRefEntityPose可能尚未被计算(其poseStatus为0)。 For both options. 对于这两种选择。

Now, regarding the code. 现在,关于代码。 Option 1 gives you the entity in FIXED coordinates (those large numbers are likely correct, they are the value in meters of the position of that point on the surface of the earth, using the standard elliptical approximation to the earth as elevation 0). 选项1为您提供了FIXED坐标中的实体(那些大数可能是正确的,它们是以地球的标准椭圆近似值为0的高度表示该点在地球表面上的位置的米值)。 If the user's pose was known, I would expect the poseStatus to be KNOWN , and the values of position and orientation to be something non-zero. 如果用户的姿势是众所周知的,我期望poseStatusKNOWN ,和值positionorientation是什么非零。

Option 2 is a bit weird. 选项2有点奇怪。 You are giving it the big numbers as the position of the entity, but then saying they are being expressed in the coordinates of the previous entity. 您要给它一个大数字作为实体的位置,但是要说它们是在前一个实体的坐标中表示的。 Which means you are probably telling it to position the second entity out in outer space, by the distance equivalent to the distance from the center of the earth ... 这意味着您可能正在告诉它将第二个实体放置在外层空间中,其距离等于到地球中心的距离...

I recall that your goal is to get the pose of the 2nd point relative to the first. 我记得您的目标是获得相对于第一个点的第二个点的姿势。 To do that, you need to 为此,您需要

  • wait until the user's pose is known 等到知道用户的姿势
  • get the pose of both points in local coordinates (as you are doing for Option 1) 获取局部坐标中两个点的姿势(与方法1一样)
  • subtract the first (or whichever one you want as your "local origin") from the second (and from the subsequent ones) to give you small meters-based offsets of the subsequent points from the first one (assign this to madP1Ref ). 从第二个(以及后续的一个)中减去第一个(或您想要作为“本地原点”的任何一个),以为您提供第一个后继点的基于米的小偏移量(将其分配给madP1Ref )。
  • create an entity (like in Option 2) using those small meters (now in madP1Ref ) just like you are doing there. 就像您在madP1Ref一样,使用这些小仪表(现在在madP1Ref )创建一个实体(如选项2中madP1Ref )。

As I understand it, the issue is that while a desktop browser will give a location, since it will not provide an orientation, a full 3D pose cannot be obtained. 据我了解,问题在于,尽管桌面浏览器会提供位置,但由于无法提供方向,所以无法获得完整的3D姿势。 Therefore, the user entity is defined against an arbitrary reference frame. 因此,针对任意参考系定义了用户实体。 A future release will assume an orientation when one is not available. 将来的发行版将以一种不可用的方式进行定位。

EDIT: mischaracterized nature of issue. 编辑:问题的性质错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM