/** * Sets up the tango configuration object. Make sure mTango object is initialized before making * this call. */ private TangoConfig setupTangoConfig(Tango tango, boolean isAutoRecovery) { // Create a new Tango Configuration and enable the MotionTrackingActivity API TangoConfig config = new TangoConfig(); config = tango.getConfig(config.CONFIG_TYPE_CURRENT); config.putBoolean(TangoConfig.KEY_BOOLEAN_MOTIONTRACKING, true); // The Auto-Recovery ToggleButton sets a boolean variable to determine // if the // Tango service should automatically attempt to recover when // / MotionTrackingActivity enters an invalid state. config.putBoolean(TangoConfig.KEY_BOOLEAN_AUTORECOVERY, isAutoRecovery); Log.i(TAG, "Auto Reset: " + mIsAutoRecovery); return config; }
/** * Sets Texts views to display statistics of Poses being received. This also sets the buttons used * in the UI. Please note that this needs to be called after TangoService and Config objects are * initialized since we use them for the SDK related stuff like version number etc. */ private void setupTextViewsAndButtons(TangoConfig config) { // Text views for displaying translation and rotation data mPoseTextView = (TextView) findViewById(R.id.pose); mQuatTextView = (TextView) findViewById(R.id.quat); mPoseCountTextView = (TextView) findViewById(R.id.posecount); mDeltaTextView = (TextView) findViewById(R.id.deltatime); mTangoEventTextView = (TextView) findViewById(R.id.tangoevent); // Text views for the status of the pose data and Tango library versions mPoseStatusTextView = (TextView) findViewById(R.id.status); mTangoServiceVersionTextView = (TextView) findViewById(R.id.version); mApplicationVersionTextView = (TextView) findViewById(R.id.appversion); // Buttons for selecting camera view and Set up button click listeners findViewById(R.id.first_person_button).setOnClickListener(this); findViewById(R.id.third_person_button).setOnClickListener(this); findViewById(R.id.top_down_button).setOnClickListener(this); // Button to reset motion tracking mMotionResetButton = (Button) findViewById(R.id.resetmotion); // Set up button click listeners mMotionResetButton.setOnClickListener(this); // Display the library version for debug purposes mTangoServiceVersionTextView.setText(config.getString("tango_service_library_version")); PackageInfo packageInfo; try { packageInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), 0); mApplicationVersionTextView.setText(packageInfo.versionName); } catch (NameNotFoundException e) { e.printStackTrace(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_point_cloud); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); mPoseTextView = (TextView) findViewById(R.id.pose); mQuatTextView = (TextView) findViewById(R.id.quat); mPoseCountTextView = (TextView) findViewById(R.id.posecount); mDeltaTextView = (TextView) findViewById(R.id.deltatime); mTangoEventTextView = (TextView) findViewById(R.id.tangoevent); mPoseStatusTextView = (TextView) findViewById(R.id.status); mPointCountTextView = (TextView) findViewById(R.id.pointCount); mAverageZTextView = (TextView) findViewById(R.id.averageZ); mFrequencyTextView = (TextView) findViewById(R.id.frameDelta); mFirstPersonButton = (Button) findViewById(R.id.first_person_button); mFirstPersonButton.setOnClickListener(this); mThirdPersonButton = (Button) findViewById(R.id.third_person_button); mThirdPersonButton.setOnClickListener(this); mTopDownButton = (Button) findViewById(R.id.top_down_button); mTopDownButton.setOnClickListener(this); mTango = new Tango(this); mConfig = new TangoConfig(); mConfig = mTango.getConfig(TangoConfig.CONFIG_TYPE_CURRENT); mConfig.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true); mTangoUxLayout = (TangoUxLayout) findViewById(R.id.layout_tango); mTangoUx = new TangoUx(this); mTangoUx.setLayout(mTangoUxLayout); mTangoUx.setUxExceptionEventListener(mUxExceptionListener); int maxDepthPoints = mConfig.getInt("max_point_cloud_elements"); mRenderer = new PCRenderer(maxDepthPoints); mGLView = (GLSurfaceView) findViewById(R.id.gl_surface_view); mGLView.setEGLContextClientVersion(2); mGLView.setRenderer(mRenderer); mIsTangoServiceConnected = false; startUIThread(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTranslationTextView = (TextView) findViewById(R.id.translation_text_view); mRotationTextView = (TextView) findViewById(R.id.rotation_text_view); // Instantiate Tango client mTango = new Tango(this); // Set up Tango configuration for motion tracking // If you want to use other APIs, add more appropriate to the config // like: mConfig.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true) mConfig = mTango.getConfig(TangoConfig.CONFIG_TYPE_CURRENT); mConfig.putBoolean(TangoConfig.KEY_BOOLEAN_MOTIONTRACKING, true); }