Google Tango Java SDK开发:Motion Tracking 运动追踪

Java API Motion Tracking Tutorial运动追踪教程

This page describes how the Java API handles motion tracking. 该页面描述了如何使用Java API处理运动追踪。

Lifecycle 生命周期

The normal motion tracking system lifecycle consists of three states: TangoPoseData.POSE_INITIALIZINGTangoPoseData.POSE_VALID, and TangoPoseData.POSE_INVALID. In the POSE_INITIALIZING state, the system is not yet ready and pose data is not available. In the POSE_VALID state, the system is functioning normally. In the POSE_INVALID state, the system believes its estimate was invalid and needs to be reinitialized. A fourth state, POSE_UNKNOWN, is used for all other cases.

Should the pose data become POSE_INVALID, the motion tracking system can be reinitialized in two ways. If config_enable_auto_recovery was set to true, the system will immediately enter the POSE_INITIALIZINGstate. It will use the last valid pose as the starting point after recovery. IfTangoConfig.KEY_BOOLEAN_AUTORECOVERY was set to false, the system will essentially pause and always return poses as POSE_INVALID until Tango.resetMotionTracking() is called. Unlike auto recovery, this will also reset the starting point after recovery back to the origin.

The lifecycle state is recorded in the TangoPoseData object‘s statusCode.

For more information, although the page is based around the C API, please see our Device Pose concepts page.

Configuration

In order to use motion tracking, your TangoConfig must have KEY_BOOLEAN_MOTIONTRACKING set to true. If you are using the default TangoConfig as your starting point, it is already set to true.

You also have the option to set KEY_BOOLEAN_AUTORECOVERY. In the default TangoConfig, this is set to true. See the Lifecycle section for the behavior of this parameter.

Getting pose data

There are two coordinate frame pair options for basic motion tracking: device with respect to start of service, and device with respect to the previous device pose. With start of service, the device‘s pose is relative to the position where the motion tracking system initialized. You can receive pose data in both the callback and polling forms. With previous device pose, the device‘s pose is relative to its last position. Pose data is only available as a callback.

Callback-based

If you are using the callback-based approach, you must define the coordinate frame pairs you are interested in and construct your onPoseAvailable() callback.

You also have to implement onXyzIjAvailable and onTangoEvent, because the Tango.OnTangoUpdateListenerinterface requires an implementation for all three of those methods.

private void setTangoListeners() {    final ArrayList<TangoCoordinateFramePair> framePairs = new ArrayList<TangoCoordinateFramePair>();    framePairs.add(new TangoCoordinateFramePair(        TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,        TangoPoseData.COORDINATE_FRAME_DEVICE));

    // Listen for new Tango data    mTango.connectListener(framePairs, new OnTangoUpdateListener() {

        @Override        public void onPoseAvailable(final TangoPoseData pose) {            // Process pose data from device with respect to start of service        }

        @Override        public void onXyzIjAvailable(TangoXyzIjData arg0) {            // We need this callback even if we don‘t use it        }

        @Override        public void onTangoEvent(final TangoEvent event) {            // This callback also has to be here        }    });}

Polling-based

In the polling-based approach, you must first specify the coordinate frame pair you are interested in. For simple motion tracking, this will always be TangoPoseData.COORDINATE_FRAME_DEVICE with respect toTangoPoseData.COORDINATE_FRAME_START_OF_SERVICE.

// Define what motion is requested.TangoCoordinateFramePair frames_of_reference;frames_of_reference.baseFrame = TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE;frames_of_reference.targetFrame = TangoPoseData.COORDINATE_FRAME_DEVICE;

Then call `Tango.getPoseAtTime() as desired. In the example below, the timestamp is set to 0.0 to get the latest pose. If you specify a specific timestamp, the system will return an interpolated pose at that exact time. Timestamps are relative to the device boot.

new Thread(new Runnable() {    final int pollingUpdatePeriodMilliseconds = 66;

    @Override    public void run() {        while (true) {            try {                 Thread.sleep(pollingUpdatePeriodMilliseconds);            } catch (InterruptedException e) {                 e.printStackTrace();            }            try {                final TangoPoseData queryPoseStartDevice =                    mTango.getPoseAtTime(0.0, frames_of_reference);            } catch (TangoErrorException e) {                e.printStackTrace();            }        }    }}).start();

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.

时间: 2024-12-23 00:17:28

Google Tango Java SDK开发:Motion Tracking 运动追踪的相关文章

Google Tango Java SDK开发:Configure and Connect 配置和连接

Configure and Connect 配置和连接 Note: This section assumes you are familiar with the Android Activity Lifecycle. 注意:该节假设你已经熟悉了安卓的活动周期. Overview 概览 You will need certain API calls regardless of your use case. These are related to configuring, connecting t

[No0000105]java sdk 开发环境变量powershell 自动配置脚本

# 设置Java SDK 环境变量 $softwares = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* #$jdk = $softwares | Where-Object DisplayName -Match 'Java SE Development Kit' #$RegPath = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr

Hyperledger Fabric Java SDK最新教程

Fabric Java SDK是Fabric区块链官方提供的用于Java应用开发的SDK,全称为Fabric-sdk-java,网上可用资料不多,本文列出了精心整理的针对Fabric Java SDK的最新精选教程. 如果希望快速掌握Fabric Java SDK的使用方法,建议访问汇智网的在线互动教程: Fabric区块链Java开发详解 1.官方文档 使用Fabric Java SDK开发必备的手册,从Java SDK源代码注释生成的每个接口.类和方法的简要说明,聊胜于无,但是要指望它达到真

分享 Java微信开发SDK

分享 Java微信开发SDK •发布于 4周前  •作者 朋也  •432 次浏览  •最后一次编辑是 2周前  •来自 分享 给大家分享两个java开发微信公众号的sdk jfinal-weixin weixin-java-tools fastweixin 第一个是jfinal框架开发的微信开发sdk,貌似没什么文档,大家知道哪地方有文档可以在下方留言 第二个是在github上找的,fork人数也不少,文档写的挺好,基于maven方式搭建,开发起来也很方便 第三个是在osc上看到的,可以整合s

微博开发平台java SDK demo学习之friendships

本文解释了在java SDK的demo中与feiendships有关的功能 截图如下: 关注一个用户(需要知道该用户uid) 取消关注一个用户(用户uid) 获取用户粉丝列表(授权用户的screen__ame),最多返回粉丝的30%,上限为500 获取用户粉丝列表(授权用户的uid),最多返回粉丝的30%,上限为500 获取用户粉丝uid列表(授权用户的uid),最多返回粉丝的30%,上限为500 获取用户活跃粉丝列表(授权用户的uid),最多返回粉丝的30%,上限为500 获取用户双向关注的用

Google Tango初学者教程

Getting Started with the Tango Java API In this tutorial, we'll go through setting up your build environment and compiling and running your first "Hello Tango" project using the Java API, which will run sample code and display the pose data from

&lt;Chapter 2&gt;2-1-2.安装Java SDK

Java运行时环境的App Engine SDK运行在任何运行了Java SE开发工具(JDK)的电脑上.Java SDK App Engine 支持JDK 6,并且当运行App Engine的时候,Java 运行时环境使用Java6的JVM和JRE.(JDK5支持是受限的并且过时了) 如果你还未拥有它,你可以从Oracle的网站上下载和安装适用于大部分平台的Java 6 JDK.(Mac用户,参看下一部分): http://www.oracle.com/technetwork/java/jav

Tango Java API常数

Tango Java API Constants常数 Constant Field Values常数字段值 Contents com.google.* com.google.* com.google.atap.tangoservice.Tango  Modifier and Type修饰符和类型 Constant Field常数字段 Value值 public static final java.lang.String ANDROID_PERMISSION_DATASET "com.google

Android Studio重构之路,我们重新来了解一下Google官方的Android开发工具

Android Studio重构之路,我们重新来了解一下Google官方的Android开发工具 记得我的第一篇博客就是写Android Studio,但是现在看来还是有些粗糙了,所有重构了一下思路,覆写了一篇 Google主推-Android开发利器--Android Studio,这可能是最全的AS教程! Android Studio,自Google2013年发布以来,就倍受Android开发者的喜爱,我们本书,就是基于Android Studio来进行案例演示的,大家都知道,Android