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 your device.

在本教程中,我们将尝试设置你的开发环境,使用Java API编译并运行你的第一个“Hello Tango”工程。它将运行样本代码,并且展示你的设备的姿态数据。

Prerequisites提前条件

To successfully follow this guide, you will need:要成功进行该指示,你需要:

  • Android Studio

  • Experience developing Android apps. If you have never created an Android app before, you can get started with our Building Your First App tutorial.体验开发Android应用。如果你从未创建过Android应用,你可以从这里开始。

  • The sample project. This includes the Tango Java API files, which you can find in the subfolder named TangoReleaseLibs after you download the project. For download instructions, see the next section.样例程序。它包括Tango Java API文件,下载完后你能在子文件夹名为TangoReleaseLibs中发现它。下载指南请看下一节。

  • A Tango Tablet Development Kit. You can build the code without one, but you won't be able to run it.一个Tango平板开发套件。没有它你也可以生成项目,但是你没办法运行它。

Note: The Android emulator cannot be used for this project or any other project that uses the Tango API. You musthave a Tango device.安卓模拟器不能用在使用Tango API的项目。

Download the sample project 下载示例项目

The sample project is hosted on GitHub. You can download it as a zip file or use git to clone the repository:样例项目是在Github上保管。你可以以zip文件的形式下载或者使用git克隆该仓库:

git clone https://github.com/googlesamples/tango-examples-java.git

You should now have a directory called tango-examples-java on your machine. Within this directory you should see a subdirectory called java_basic_examples, which contains the code for this guide.现在你应该有一个叫tango-examples-java的目录。在该目录中你应该看到一个叫java_basic_examples的子目录。它包含本向导的代码。

Import the project into Android Studio将工程导入到Android Studio中

  1. Do one of the following: 做下面中的一个:

    • Open Android Studio.打开Android Studio
    • If you are already in Android Studio with a project loaded, close the project.如果你已经在Android Studio中打开一个项目,那么关闭该项目。

    Either action takes you to the Welcome to Android Studio screen.任何一个都会带你到Android Studio的欢迎界面。

  2. Select Import Project (Eclipse ADT, Gradle, etc.). In older versions of Android Studio, this may be Import Non-Android Studio project or simply Import Project. 选择Import Project导入项目。在其他版本的Android Studio中,这可能是Import Non-Android Studio project导入非Android Studio项目或仅仅是Import Project导入项目。

  3. In the Select Eclipse or Gradle Project to Import dialog, navigate to the repository you just cloned. Choose the java_basic_examples directory and then click OK.在导入对话框,跳转到你刚刚克隆的仓库。选择java_basic_examples目录然后单击OK。

Note: If an error appears that says "failed to find target-android-19" and offers you a link to "Install missing platform(s) and sync project", click that link and go through the steps to update your Android platform.如果错误出现说“查找target-android-19失败”,并给你提供一个链接“安装缺少的平台和同步项目”,点击该链接并运行各步骤从而更新你的Android平台。

Connect your device连接你的设备

If you haven't already connected your Tango device to your computer, you should do so now.如果你还没有连接你的Tango设备到你的计算机,你应该现在连接上。

Tango手机USB驱动C:\Users\Administrator\AppData\Local\Android\Sdk\extras\google\usb_driver

Build and run an application建立并运行一个应用

Within the basic examples project you loaded, you have a choice of several different "hello"-style apps to build and run. For this tutorial, we'll choose "Hello Motion Tracking."

在你已经加载的基本样本项目中,你有几个不同的“hello”类型的应用建立和运行。对本教程,我们选择“Hello Motion Tracking”。

  1. On the toolbar, view the Run/Debug Configuration field and make sure hello_motion_tracking is the active configuration. If it is not, click the field and select it.在工具栏中,查看Run/Debug配置栏中确保hello_motion_tracking是活动配置。如果不是,请点击该区域选择它。

  2. Do one of the following:做下面的一个:

    • On the Run menu, click Run.在运行菜单,点击Run运行。
    • On the toolbar, click the Run button (the green arrow).
  3. In the Device Chooser dialog, select Choose a running device, then select your Tango tablet, and then click OK.

Note: If your device isn't showing up in the Device Chooser dialog, make sure it is plugged in and has Developer options enabled. For more information, see "Enabling On-device Developer Options".

See logcat for the raw pose data查看logcat中的原始姿态数据

You can see logcat output automatically in the bottom part of Android Studio.你可以在Android Studio的下部看到自动输出的logcat。

If you want to see it in your terminal, type如果你想在你的终端看到,输入:

 
adt_path/sdk/platform-tools/adb logcat

You will see the pose data being printed in your terminal:你将看到在你的终端打印的姿态数据(平移xyz/旋转/比例尺?):

 
I/MainActivity( 6010): Translation: 0.020329, 0.013915,
-0.008571 | Rotation: 0.581630, 0.014597, -0.021857, 0.813029

Add to your own project添加到你自己的项目中

The Tango SDK for Java components are distributed on Bintray and are available through the JCenter repository when using Maven.

支持Java组件的Tango SDK分布在Bintray中,在使用Maven时通过JCenter的仓库获取。

  1. First, add jcenter() to your build.gradle file so Gradle can find the AARs. For example: 首先,添加jcenter()到你的build.gradle文件中,从而Gradle可以找到AAR。

     
    allprojects {
        repositories {
            jcenter()
        }
    }
  2. Add the appropriate dependencies to the build.gradle files in your modules. You can determine this by looking at the samples' build.gradle files to see what each one needs. For example, our motion tracking sample uses: 将合适的依赖添加到你的模块中的build.gradle文件中。你可以看一下样例“build.gradle”文件看一下每一个都需要什么。例如,我们的motion tracking运动追踪样例需要:

     
    dependencies {
        compile 'com.google.tango:sdk-base:LATEST_VERSION'
        compile 'com.google.tango:support-base:LATEST_VERSION'
    }

    The latest version looks like 1.51 and can be found on the downloads page. This code indicates that an application similar to the motion tracking sample needs sdk-base and support-base. This will also recursively fetch dependent libraries. 最新版本比如1.51,可以在下载页找到。该代码显示了类似于motion tracking的应用需要sdk-base和support-base两个开发包。这也会递归地获取依赖库。

Once this is done for all of the required libraries, you will be able to reference code in the Tango SDK in your app. 一旦对于所有的所需的类库都完成了,你将会能够引用Tango SDK中的代码。

If you are using your own build system, the Tango libraries are also available from the downloads page.如果你想使用你自己的编译系统,Tango类库也可以在下载页面下载。

Next steps 接下来

Now that you have learned how to set up your environment for development with the Tango Java API, proceed to the following links to learn how to use specific features of Tango in your app:你已经学会如何设置你的Tango Java API的开发环境了,继续下面的链接学习如何使用Tango特定的特征吧:

Also, take a look at our code samples on Github. 然后看一下我们在Github托管的代码例子。

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.

上次更新日期:四月 7, 2017

本文转自:https://developers.google.com/tango/apis/java/

Google Tango初学者教程的更多相关文章

  1. Getting Started with Google Tango(Google Tango开始教程)

    https://developers.google.com/tango/ Build apps that understand space and motion in high fidelity on ...

  2. [转]Google Guava官方教程(中文版)

    Google Guava官方教程(中文版) http://ifeve.com/google-guava/

  3. Google Guava官方教程(中文版)

    Google Guava官方教程(中文版) 原文链接  译文链接 译者: 沈义扬,罗立树,何一昕,武祖  校对:方腾飞 引言 Guava工程包含了若干被Google的 Java项目广泛依赖 的核心库, ...

  4. Google Guava官方教程(中文版)地址

    Google Guava官方教程(中文版) http://ifeve.com/google-guava/ 瓜娃啊瓜娃

  5. Go GraphQL初学者教程

    Go GraphQL初学者教程 https://tutorialedge.net/golang/go-graphql-beginners-tutorial/ https://tutorialedge. ...

  6. [视频]K8飞刀 Google黑客功能教程

    [视频]K8飞刀 Google黑客功能教程 链接:https://pan.baidu.com/s/1kbK5jNH8ZaddUEeQ9IwTaw 提取码:lwl6

  7. 《SLAM for Dummies》中文版《SLAM初学者教程》

    SLAM for Dummies  SLAM初学者教程A Tutorial Approach to Simultaneous Localization and Mapping  一本关于实时定位及绘图 ...

  8. SLAM for Dummies SLAM初学者教程 中文翻译 1到4章

    SLAM for Dummies  SLAM初学者教程A Tutorial Approach to Simultaneous Localization and Mapping  一本关于实时定位及绘图 ...

  9. ARKit对安卓的提示 ARKit与Google Tango

    我们知道安卓是Google开发的,那么关于AR谷歌有哪些作为呢?就是开发了Google Tango,尽管Tango还未开源,但是用户可以免费使用,可是一般的安卓手机是无法运行的,它对硬件有要求,这对它 ...

随机推荐

  1. Django models中关于blank与null

    建立一个简易Model class Person(models.Model): GENDER_CHOICES=( (1,'Male'), (2,'Female'), ) name=models.Cha ...

  2. ZedGraph控件的使用 --归类(转帖)

    在我们编写程序的时候,有时候是要做一些统计的,为了达到一目了然的效果,饼状图,曲线图,柱状图都是很好的表现统计的直观形式.这个时候,ZedGraph控件给我们带来了极大的方便. 1.下载ZedGrap ...

  3. Phonegap 工程项目介绍

    一.工程项目的路径在www下面,www下面的文件如下图 1. index.html <!DOCTYPE html> <!-- Licensed to the Apache Softw ...

  4. 为什么JSP会比Beetl慢

    转自:http://my.oschina.net/xiandafu/blog/475740 JSP是预编译成class的,然后模板渲染里比Beetl慢很多,文章从JSP静态文本处理不足,以及JSTL实 ...

  5. C语言 字符串处理函数 转自 http://blog.chinaunix.net/uid-25885064-id-3175049.html

     C字符串处理函数 2012-04-13 18:14:16 分类: C/C++ void *memccpy (void *dest, const void *src, int c, size_t n) ...

  6. JSON数组对象某个属性值查找

    1.引用国外开源Linq写法的js框架 地址:https://archive.codeplex.com/?p=jslinq https://www.nuget.org/packages/jslinq ...

  7. Excel VBA 找出选定范围不重复值和重复值

    Sub 找出选定范围内不重复的值() On Error Resume Next Dim d As Object Set d = CreateObject("scripting.diction ...

  8. java web 程序---内置对象application的log方法的使用

    application的主要方法里,有log方法,是日志文件里可以查看到信息的. 当老师写好代码后,他发现在tomact里的log目录下找不到信息,原因是:我们用myeclipse这个客户端软件,应该 ...

  9. ES6系列_14之promise对象的简单使用

    1.产生原因 在前端开发中,最常见的的就是"回调",我相信很多人对于这个"回调"可谓是印象深刻呢.究其原因是因为层层回调会造成所谓的“回调地狱 (callbac ...

  10. 37.使用PreResultListener实现回调

    转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 在进行本实例前请前复习:五.2自定义拦截器.因为PreResultListe ...