本文整理汇总了Java中android.hardware.Sensor.TYPE_ROTATION_VECTOR属性的典型用法代码示例。如果您正苦于以下问题:Java Sensor.TYPE_ROTATION_VECTOR属性的具体用法?Java Sensor.TYPE_ROTATION_VECTOR怎么用?Java Sensor.TYPE_ROTATION_VECTOR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.Sensor
的用法示例。
在下文中一共展示了Sensor.TYPE_ROTATION_VECTOR属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_ROTATION_VECTOR:
System.arraycopy(event.values, 0, mRotation, 0, 3);
calculateOrientation();
break;
case Sensor.TYPE_ACCELEROMETER:
mAccel = LowPassFilter.lowPass(event.values.clone(), mAccel);
calculateOrientation();
break;
case Sensor.TYPE_MAGNETIC_FIELD:
mMagnet = LowPassFilter.lowPass(event.values.clone(), mMagnet);
break;
case Sensor.TYPE_STEP_DETECTOR:
mStep = event.values[0] == 1.0;
announceChange(STEP_UPDATE);
break;
}
}
示例2: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
if (internalCompassListener == null) {
return;
}
// check when the last time the compass was updated, return if too soon.
long currentTime = SystemClock.elapsedRealtime();
if (currentTime < compassUpdateNextTimestamp) {
return;
}
if (lastAccuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
Timber.d("Compass sensor is unreliable, device calibration is needed.");
return;
}
if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
updateOrientation(event.values);
// Update the compassUpdateNextTimestamp
compassUpdateNextTimestamp = currentTime + LocationLayerConstants.COMPASS_UPDATE_RATE_MS;
} else if (event.sensor.getType() == Sensor.TYPE_ORIENTATION) {
internalCompassListener.onCompassChanged((event.values[0] + 360) % 360);
for (CompassListener compassListener : compassListeners) {
compassListener.onCompassChanged((event.values[0] + 360) % 360);
}
}
}
示例3: onSensorChanged
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if(sensorEvent.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
synchronized (this.mutex) {
float[] quaternion = new float[4];
SensorManager.getQuaternionFromVector(quaternion, sensorEvent.values);
this.imu.getOrientation().setW(quaternion[0]);
this.imu.getOrientation().setX(quaternion[1]);
this.imu.getOrientation().setY(quaternion[2]);
this.imu.getOrientation().setZ(quaternion[3]);
Collection<Double> tmpCov = Arrays.asList(0.001d, 0d, 0d, 0d, 0.001d, 0d, 0d, 0d, 0.001d);// TODO Make Parameter
this.imu.setOrientationCovariance(tmpCov);
this.quatTime = sensorEvent.timestamp;
// logger.debug("Sensor rotate value : " + this.imu);
// System.out.println("Sensor rotate value : " + this.imu);
}
}
}
示例4: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
// we received a sensor event. it is a good practice to check
// that we received the proper event
if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
// convert the rotation-vector to a 4x4 matrix. the matrix
// is interpreted by Open GL as the inverse of the
// rotation-vector, which is what we want.
SensorManager.getRotationMatrixFromVector(currentOrientationRotationMatrix.matrix, event.values);
// Get Quaternion
// Calculate angle. Starting with API_18, Android will provide this value as event.values[3], but if not, we have to calculate it manually.
SensorManager.getQuaternionFromVector(temporaryQuaternion, event.values);
currentOrientationQuaternion.setXYZW(temporaryQuaternion[1], temporaryQuaternion[2], temporaryQuaternion[3], -temporaryQuaternion[0]);
}
}
示例5: isXYZ
private boolean isXYZ(Sensor s) {
switch (s.getType()) {
case Sensor.TYPE_ACCELEROMETER:
case Sensor.TYPE_GRAVITY:
case Sensor.TYPE_GYROSCOPE:
case Sensor.TYPE_LINEAR_ACCELERATION:
case Sensor.TYPE_MAGNETIC_FIELD:
case Sensor.TYPE_ROTATION_VECTOR:
return true;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (s.getType() == Sensor.TYPE_GAME_ROTATION_VECTOR
|| s.getType() == Sensor.TYPE_GYROSCOPE_UNCALIBRATED
|| s.getType() == Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED) {
return true;
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (s.getType() == Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR) {
return true;
}
}
return false;
}
示例6: onSensorChanged
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if (this.accelAdapter != null && sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
this.accelAdapter.onSensorChanged(sensorEvent);
}
if (this.gyroAdapter != null && sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
this.gyroAdapter.onSensorChanged(sensorEvent);
}
if (this.rotaAdapter != null && sensorEvent.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
this.rotaAdapter.onSensorChanged(sensorEvent);
}
}
示例7: isRestricted
@SuppressWarnings("deprecation")
private boolean isRestricted(XParam param, int type) throws Throwable {
if (type == Sensor.TYPE_ALL)
return false;
else if (type == Sensor.TYPE_ACCELEROMETER || type == Sensor.TYPE_LINEAR_ACCELERATION) {
if (isRestricted(param, "acceleration"))
return true;
} else if (type == Sensor.TYPE_GRAVITY) {
if (isRestricted(param, "gravity"))
return true;
} else if (type == Sensor.TYPE_RELATIVE_HUMIDITY) {
if (isRestricted(param, "humidity"))
return true;
} else if (type == Sensor.TYPE_LIGHT) {
if (isRestricted(param, "light"))
return true;
} else if (type == Sensor.TYPE_MAGNETIC_FIELD || type == Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED) {
if (isRestricted(param, "magnetic"))
return true;
} else if (type == Sensor.TYPE_SIGNIFICANT_MOTION) {
if (isRestricted(param, "motion"))
return true;
} else if (type == Sensor.TYPE_ORIENTATION || type == Sensor.TYPE_GYROSCOPE
|| type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) {
if (isRestricted(param, "orientation"))
return true;
} else if (type == Sensor.TYPE_PRESSURE) {
if (isRestricted(param, "pressure"))
return true;
} else if (type == Sensor.TYPE_PROXIMITY) {
if (isRestricted(param, "proximity"))
return true;
} else if (type == Sensor.TYPE_GAME_ROTATION_VECTOR || type == Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR
|| type == Sensor.TYPE_ROTATION_VECTOR) {
if (isRestricted(param, "rotation"))
return true;
} else if (type == Sensor.TYPE_TEMPERATURE || type == Sensor.TYPE_AMBIENT_TEMPERATURE) {
if (isRestricted(param, "temperature"))
return true;
} else if (type == Sensor.TYPE_STEP_COUNTER || type == Sensor.TYPE_STEP_DETECTOR) {
if (isRestricted(param, "step"))
return true;
} else if (type == Sensor.TYPE_HEART_RATE) {
if (isRestricted(param, "heartrate"))
return true;
} else if (type == 22) {
// 22 = TYPE_TILT_DETECTOR
// Do nothing
} else if (type == 23 || type == 24 || type == 25) {
// 23 = TYPE_WAKE_GESTURE
// 24 = TYPE_GLANCE_GESTURE
// 25 = TYPE_PICK_UP_GESTURE
// 23/24 This sensor is expected to only be used by the system ui
// 25 Expected to be used internally for always on display
} else
Util.log(this, Log.WARN, "Unknown sensor type=" + type);
return false;
}
示例8: RotationVectorUpdatesProvider
RotationVectorUpdatesProvider(int sensorDelay) {
super(Sensor.TYPE_ROTATION_VECTOR, sensorDelay);
}