Java API Area Learning Tutorial
Configuration
There are two configuration options that are relevant to area learning.
有两个与区域学习相关的配置选项。
Loading area descriptions
加载区域学习
To load an area description file, your TangoConfig must have KEY_STRING_AREADESCRIPTION set to the UUID of the ADF you wish to load. When the TangoService starts, it loads this area description.
要加载区域描述文件,您的TangoConfig必须将KEY_STRING_AREADESCRIPTION设置为要加载的ADF的UUID。 当TangoService启动时,它加载此区域描述。
Here is an example of how you could load the latest saved area description file. It retrieves a list of all area description files and takes the last one in the list, which would be the most recent:
下面是一个如何加载最新保存的区域描述文件的示例。 它检索所有区域描述文件的列表,并获取列表中的最后一个,这将是最近的:
Learning mode
In order to use area learning, your Tango Config must have KEY BOOLEAN LEARNING MODE set to true. In the default Tango Config, KEY BOOLEAN LEARNING MODE is set to false.
为了使用区域学习,您的Tango配置必须将KEY BOOLEAN LEARNING MODE设置为true。 在默认Tango配置中,KEY BOOLEAN LEARNING MODE设置为false。
You can save an ADF by callingTango.saveAreaDescription(). This call can be long-running, so don't call it on the UI thread.
您可以通过调用Tango.saveAreaDescription()保存ADF。这个调用可以是长时间运行的,所以不要在UI线程上调用它。
Learning mode with a loaded area description
具有加载区描述的学习模式
If both options are used, an area description of the current session will be built. If localization occurs against the loaded ADF and Tango.saveAreaDescription() is called, a new ADF will be saved containing the combination of both.
如果使用这两个选项,将构建当前会话的区域描述。 如果针对加载的ADF进行本地化,并调用Tango.saveAreaDescription(),则将保存包含两者组合的新ADF。
Note:You cannot save an area description in this way until you have localized against the loaded ADF. SeeArea Learning Mode and Loaded Area Description Filesfor more information.
Motion tracking with area learning
运动追踪与区域学习
In general, using motion tracking with area learning is very similar to basic motion tracking. You need to define the coordinate pairs you are interested in, then use either callbacks or polling to get data.
There are two coordinate frame pairs for area learning. The TangoCoordinateFramePair
with baseFrame == TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION and targetFrame == TangoPoseData.COORDINATE_FRAME_DEVICE gets you the pose of the device from the area description's origin, including drift corrections. If an ADF was loaded, pose data is only available after you have localized to the ADF and the origin will be the same as the ADF. If learning mode enabled without loading an ADF, pose data will be available immediately after initialization and the origin will be the same as the start of service.
The frame pair with baseFrame == TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION and targetFrame == TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE provides the offset between the area description and start of service at the requested time. This pair updates only when a localization occurs.
Applications should use TangoPoseData.COORDINATE_FRAME_DEVICE with respect to TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION for tracking a device's motion, and use TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE with respect to TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION only as a localization signal.
一般来说,使用具有区域学习的运动跟踪与基本运动跟踪非常相似。您需要定义您感兴趣的坐标对,然后使用回调或轮询获取数据。
有两个用于区域学习的坐标框架对。 TangoCoordinateFramePair
使用baseFrame == TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION和targetFrame == TangoPoseData.COORDINATE_FRAME_DEVICE从您的区域描述的原点获取设备的姿势,包括漂移修正。如果加载了ADF,姿势数据只有在本地化到ADF之后才可用,并且原点将与ADF相同。如果启用学习模式而无需加载ADF,则初始化后立即可以使用姿势数据,并且原点将与启动服务相同。
具有baseFrame == TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION和targetFrame == TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE的帧对提供了在请求的时间区域描述和服务开始之间的偏移。此对仅在发生本地化时更新。
应用程序应使用TangoPoseData.COORDINATE_FRAME_DEVICE相对于TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION来跟踪设备的运动,并且仅将TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION的TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE用作本地化信号。
Working with ADFs
Using metadata
ADFs have metadata you can use, so you don't have to work with UUID alone. The metadata consists of key-value pairs; for a list of supported keys see the constant values for TangoAreaDescriptionMetaData.
ADF具有您可以使用的元数据,因此您不必单独使用UUID。 元数据由键值对组成; 有关支持的键列表,请参阅TangoAreaDescriptionMetaData的常量值。
Get the name field for the ADF identified by uuid:
Set the name field to name, for the ADF identified by uuid:
Listing all the UUIDs of currently accessible ADFs:
源网页地址:https://developers.google.com/tango/apis/java/java-area-learning