What Are Tango Poses?什么是Tango姿态?
As your device moves through 3D space, it calculates where it is (position) and how it's rotated (orientation) up to 100 times per second. A single instance of this combined calculation is called the device's pose. The pose is an essential concept when working with motion tracking, area learning, or depth perception.
当你的设备通过3D空间时,它计算它在哪里(位置)以及它是如何旋转的(方向)。这达到每秒100次。一个单个的这种复合计算的实例称为设备的姿态。
To calculate the poses, you must choose base and target frames of reference , which may use different coordinate systems. You can view a pose as the translation and rotation required to transform vertices from the target frame to the base frame.为了计算位姿,你必须选择基础和目标参考框架,这可能会使用不同的坐标系统。
Here is a simplified version of a Tango pose struct in C:
这里是一个C语言简洁版的Tango姿态结构体:
struct PoseData {
double orientation[4];
double translation[3];
}
The two key components of a pose are:
姿态的两个关键组件是:
A quaternion that defines the rotation of the target frame with respect to the base frame.定义目标框架相对于基础框架的旋转四元数。
A 3D vector that defines the translation of the target frame with respect to the base frame.定义目标框架相对于基础框架的三维矢量。
An actual pose struct contains other fields, such as a timestamp and a copy of the frame pair, as you'll see below.一个真正的姿态结构体包含其他域名,比如时间戳以及框架对的复件,正如下面看到的。
Note: The examples on this page use the C API, but function calls and data structures are similar for Java. In Unity, there are prefabs which handle a lot of these details for you.
Pose data姿态数据
You can request pose data in two ways: 你可以以两种方式请求姿态数据:
Request Method #1 请求方法 #1
Poll for poses using TangoService_getPoseAtTime()
. This returns the pose closest to a given timestamp from the base to the target frame. Here is the code for this function in the C API:使用TangoService_getPoseAtTime()方法请求姿态。它返回从基础框架到目标框架最靠近给定时间戳的姿态。
TangoErrorType TangoService_getPoseAtTime(
double timestamp,
TangoCoordinateFramePair frame_pair,
TangoPoseData* pose);
The TangoCoordinateFramePair
struct specifies the base frame and the target frame.TangoCoordinateFramePair结构体指定了基础框架和目标框架。
Note: If you are making an augmented reality app, we recommend that you use TangoService_getPoseAtTime() or TangoSupport_getPoseAtTime() because, in addition to polling for poses, they allow you to align the pose timestamps with the video frames.
The following code gets a pose of the device frame with respect to the start-of- service frame:
下面的代码可以获取相对于服务开始帧的设备帧的位姿:
TangoPoseData pose_start_service_T_device;
TangoCoordinateFramePair frame_pair;
frame_pair.base = TANGO_COORDINATE_FRAME_START_OF_SERVICE;
frame_pair.target = TANGO_COORDINATE_FRAME_DEVICE;
TangoService_getPoseAtTime(
timestamp,
frame_pair,
&pose_start_service_T_device);
In this example, including the names of the base and target frames in the pose variable name makes the name more descriptive:
在该例子中,由于包含了基础和目标框架的名字,所以位姿变量名更具有描述性:
TangoPoseData pose_start_service_T_device;
Request Method #2 请求方法 #2
Receive pose updates as they become available. To do so, attach an onPoseAvailable()
callback toTangoService_connectOnPoseAvailable()
. This sample is from our hello_motion_tracking example project and can be found in the tango_handler.cc file:
如果位姿更新可用便接受它。为了这么做,添加onPoseAvailable()反馈到TangoService_connectOnPoseAvailable()中。该样例是来自我们的hello_motion_tracking样例项目中,可以在tango_handler.cc文件中找到它:
TangoCoordinateFramePair pair;
pair.base = TANGO_COORDINATE_FRAME_START_OF_SERVICE;
pair.target = TANGO_COORDINATE_FRAME_DEVICE;
if (TangoService_connectOnPoseAvailable(1, &pair, onPoseAvailable) !=
TANGO_SUCCESS) {
LOGE("TangoHandler::ConnectTango, connectOnPoseAvailable error.");
std::exit(EXIT_SUCCESS);
In both cases, you receive a TangoPoseData
struct:
在两种情况下,你都接收一个TangoPoseData结构体:
typedef struct TangoPoseData {
int version;
double timestamp; // In seconds
double orientation[4]; // As a quaternion
double translation[3]; // In meters
TangoPoseStatusType status_code;
TangoCoordinateFramePair frame;
int confidence; // Currently unused
float accuracy; // Currently unused
} TangoPoseData;
Pose status姿态状态
TangoPoseData
contains a state, denoted by the TangoPoseStatusType
enum, which provides information about the status of the pose estimation system. The available TangoPoseStatusType
members are: TangoPoseData包括一个状态,是由TangoPoseStatusType枚举型贡献的,它提供了关于姿态估计系统的状态的信息。可用的TangoPoseStatusType成员有:
typedef enum {
TANGO_POSE_INITIALIZING = 0,
TANGO_POSE_VALID,
TANGO_POSE_INVALID,
TANGO_POSE_UNKNOWN
} TangoPoseStatusType;
INITIALIZING
: The motion tracking system is either starting or recovering from an invalid state, and the pose data should not be used.
INITIALIZING:运动追踪系统要么是启动中,要么是从一个无效的状态中恢复,该姿态数据不可用。
VALID
: The system believes the poses being returned are valid and should be used.
VALID:系统相信返回的姿态是合理的,可用的。
INVALID
: The system has encountered difficulty of some kind, so pose estimations are likely incorrect.
INVALID:系统经历了某些困难,所以姿态预测值很可能是不对的。
UNKNOWN
: The system is in an unknown state.
UNKOWN:系统是处于位姿未知状态。
Lifecycle of pose status位姿状态的声明周期
The TANGO_POSE_INITIALIZING
status code indicates that the Tango framework is initializing and pose data is not yet available. If you are using callbacks, you will receive only one pose update with the status code set toTANGO_POSE_INITIALIZING
while the framework is initializing.
TANGO_POSE_INITIALIZING状态码表示Tango框架正在初始化,而姿态数据还不可用。如果你正在使用反馈机制,你会在当框架初始化时只接收到一个带有一个TANGO_POSE_INITIALIZING的姿态更新。
After initialization finishes, poses are in the TANGO_POSE_VALID
state. If you are using callbacks, you will receive updates as frequently as they are available.
初始化结束后,姿态是TANGO_POSE_VALID状态。如果你使用反馈机制,你将在它们姿态可用时接收更新。
If the system encounters difficulty and enters the TANGO_POSE_INVALID
state, recovery depends on your configuration during initialization. If config_enable_auto_recovery
is set to True
, the system immediately resets the motion tracking system and enters the TANGO_POSE_INITIALIZING
state. Ifconfig_enable_auto_recovery
is set to False
, pose data remains in the TANGO_POSE_INVALID
state and no updates are received until you call TangoService_resetMotionTracking()
.
如果系统遇到困难遇到TANGO_POSE_INVALID状态,恢复依赖于你在初始化时的配置信息。如果config_enable_auto_recovery设置为真,系统将会迅速重置运动追踪系统,进入TANGO_POSE_INITIALIZING状态。如果config_enable_auto_recovery设为否,姿态数据保持在TANGO_POSE_INVALID状态,不接收更新直到你调用TangoService_resetMotionTracking()函数。
Using pose status 使用位姿状态
Your application should react to the status being returned within the pose data. For example, wait until the pose data you are interested in becomes valid before starting interactions in your application. If the pose becomes invalid, pause interactions until after the system recovers. Depending on your application, what you do after the system recovers will vary. If you are using motion tracking alone, you can simply resume your application. If you are using area learning or ADFs, instruct your user to move around until the device can localize itself.
你的应用应该对位姿数据中返回的状态做出反应。举例来说,在开始你的应用交互之前等待直到你感兴趣的姿态数据变得有效为止。如果姿态无效了,中止交互直到你的系统恢复之后。取决于你的应用,系统恢复之后你做什么是不同的。如果你只是在使用运动追踪,那么你只是简单继续你的应用。如果你在使用区域学习或者ADF文件,那么引导你的用户四处转转直到你的设备能够定位。
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
上次更新日期:三月 9, 2017