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 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.
  • 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.
  • A Tango Tablet Development Kit. You can build the code without one, but you won‘t be able to run it.

Note: The Android emulator cannot be used for this project or any other project that uses the Tango API. You musthave a Tango device.

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:

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.

Import the project into Android Studio

  1. Do one of the following:

    • Open Android Studio.
    • If you are already in Android Studio with a project loaded, close the project.

    Either action takes you to the Welcome to Android Studio screen.

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

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.

Connect your device

If you haven‘t already connected your Tango device to your computer, you should do so now.

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."

  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.

  2. Do one of the following:
    • On the Run menu, click 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

You can see logcat output automatically in the bottom part of Android Studio.

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:

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.

  1. First, add jcenter() to your build.gradle file so Gradle can find the AARs. For example:

    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:
    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.

Once this is done for all of the required libraries, you will be able to reference code in the Tango SDK in your app.

If you are using your own build system, the Tango libraries are also available from the downloads page.

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:

Also, take a look at our code samples on 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/

时间: 2024-10-05 20:36:09

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

Apache Solr初学者教程(入门之旅)

Apache Solr初学者教程(入门之旅) 写在前面:本文涉及solr入门的各方面,请逐行阅读,相信能帮助你对solr有个清晰全面的了解和使用. 在Apache Solr初学者教程的这个例子中,我们将讨论有关如何安装最新版本的Apache Solr,并告诉你如何配置它.此外,我们将告诉你如何进行使用solr的样本数据文件索引.Apache Solr支持不同格式,包括各种数据库,PDF文件,XML文件,CSV文件等等.在这个例子中,我们的索引将研究如何索引数据从一个CSV文件. 我们首选的这个例

Google Maps 基础教程

谷歌地图 是 Google 公司提供的电子地图服务是通过javascript调用,直接将代码嵌入到HTML页面,同时提供不同的CSS风格的地图调用代码,包括局部详细的卫星照片.此款服务可以提供含有政区和交通以及商业信息的矢量地图.不同分辨率的卫星照片和可以用来显示地形和等高线地形视图.在2014年3月5日谷歌表示印度22个城市的用户已经可以访问谷歌地图中75个在当地比较流行的室内场地地图,包括位于古尔冈的Ambience Mall,以及德里的Select City Walk购物中心等. Goog

Google Guice 入门教程

01 - 依赖注入 1. 依赖注入 1.1 类依赖注入 所谓的绑定就是将一个接口绑定到具体的类中,这样客户端不用关心具体的实现,而只需要获取相应的接口完成其服务即可. HelloWorld.java 1     public interface HelloWorld { 2 3         String sayHello(); 4     } 5 然后是具体的实现,HelloWorldImpl.java 1     public class HelloWorldImpl implements

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_INITIALIZING, Tang

Github初学者教程(一)

如果你是一名程序员,或者是相关专业的学生,那么Github你不应不知道.很多开源组织和大神,会选择在Github这个平台上,发布他们的开源项目,学会使用Github将能够给你的学习和工作带来巨大帮助!可是Github的使用依靠的是Git命令或者是客户端,对于初学者来说入门有一点麻烦,网上相关的教程很多都是copy别人的,学起来会遇到很多不明白的地方,于是有了这一篇博客. 一.注册Github账号  github官网地址:https://github.com/,有了账号之后就可以建立创建仓库了(C

IbatisNet初学者教程

一.什么是 IbatisNet   : 应该有很多人都听说过Ibatis吧,没错IbatisNet就是Ibatis在.net上的一个移植版本,所以它们俩基本是差不多的.所以IbatisNet自然也是一个轻量级的ORM框架,于是我们又想起来了hibnate和Nhibnate,学习了IbatisNet  ,我会与 Nhibnate做一个简单的对比. 严格的来说IbatisNet并不是一种很正统的ORM解决方案.因为它不像NHibernate那样,具备全自动的数据操作,包括查询,插入,更新,删除,也没

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

Google Tango SDK下载

Tango SDK files谷歌Tango开发包 The Tango SDK is under active development; please keep this in mind as you explore its capabilities. See our Release Notes for information on the most recent changes to the SDK. If you discover any issues, feel free to commu

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

  原文链接  译文链接 译者: 沈义扬,罗立树,何一昕,武祖  校对:方腾飞 引言 Guava工程包含了若干被Google的 Java项目广泛依赖 的核心库,例如:集合 [collections] .缓存 [caching] .原生类型支持 [primitives support] .并发库 [concurrency libraries] .通用注解 [common annotations] .字符串处理 [string processing] .I/O 等等. 所有这些工具每天都在被Goog