Google Tango初学者教程

Posted 2008nmj

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.

以上是关于Google Tango初学者教程的主要内容,如果未能解决你的问题,请参考以下文章

Google Tango SDK下载

Google Tango 之后的区域学习

Tango Java API常数

Google Project Tango NDK 未定义函数参考

如何在 Google Tango 中统一使用鱼眼相机?

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