Google Tango Java SDK Development: Motion Tracking Movement tracking

Source: Internet
Author: User

Java API Motion Tracking Tutorial Motion Tracking Tutorial

This page describes how the Java API handles motion tracking. This page describes how to use the Java API to handle motion tracking.

Lifecycle life cycle

The normal motion tracking system lifecycle consists of three states:  tangoposedata.pose_initializing ,  tangoposedata.pose_valid , and  tangoposedata.pose_invalid . in the  pose_initializing  state, the system was not yet ready and POSE data was not available. in the  pose_valid  state, and the system is functioning normally. in the  pose_invalid  state, the system believes its estimate is INVALID and needs to be Reinitializ Ed. A fourth state,  Pose_unknown , is used for all, and cases.

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

The lifecycle State was recorded in the Tangoposedata object ' s statusCode .

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

Configuration

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

You also has the option to set KEY_BOOLEAN_AUTORECOVERY . TangoConfigin the default, this is set to true. See the Lifecycle sections for the behavior of this parameter.

Getting Pose data

There is 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 is using the callback-based approach, you must define the coordinate frame pairs your is interested in and Constru CT your onPoseAvailable() callback.

You also has to implement onxyzijavailable and Ontangoevent, because the Tango.ontangoupdatelistenerinterface requires an Implementation for all three of those methods.

Private voidSettangolisteners() {
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 voidOnposeavailable(Final TangoposedataPose) {
Process pose data from device with respect to start of service
}

@Override
Public voidOnxyzijavailable(Tangoxyzijdataarg0) {
We need this callback even if we don ' t use it
        }

      & nbsp @Override
        public void Ontangoevent ( Final tangoevent event ) {
            //this callback also have to be Here
        }
    });
}
/span>
Polling-based

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

  //Define what motion is Requested. 
tangocoordinateframepair Frames_of_reference;
Frames_of_reference. Baseframe = tangoposedata.;
Frames_of_reference. TargetFrame = tangoposedata.;
/span>

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

New Thread(New Runnable() {
Final IntPollingupdateperiodmilliseconds= 66;

@Override
Public voidRun() {
While (True) {
Try {
Thread.Sleep(Pollingupdateperiodmilliseconds);
} Catch (InterruptedexceptionE) {
E.Printstacktrace();
}
Try {
Final TangoposedataQueryposestartdevice=
Mtango.Getposeattime(0.0, Frames_of_reference);
            } catch (tangoerrorexception E) {
                E. Printstacktrace             }
        }
    }
}). Span class= "PLN" >start ();
/span>

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and Co De samples is licensed under the Apache 2.0 License. For details, see our Site policies. Java is a registered trademark of the Oracle and/or its affiliates.

Google Tango Java SDK Development: Motion Tracking Movement tracking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.