当前位置: 首页>>代码示例>>Java>>正文


Java Sensor.TYPE_GYROSCOPE属性代码示例

本文整理汇总了Java中android.hardware.Sensor.TYPE_GYROSCOPE属性的典型用法代码示例。如果您正苦于以下问题:Java Sensor.TYPE_GYROSCOPE属性的具体用法?Java Sensor.TYPE_GYROSCOPE怎么用?Java Sensor.TYPE_GYROSCOPE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.hardware.Sensor的用法示例。


在下文中一共展示了Sensor.TYPE_GYROSCOPE属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSensorChanged

@Override
    public void onSensorChanged(SensorEvent sensorEvent) {
        if(sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
            synchronized (this.mutex) {
                this.imu.getAngularVelocity().setX(sensorEvent.values[0]);
                this.imu.getAngularVelocity().setY(sensorEvent.values[1]);
                this.imu.getAngularVelocity().setZ(sensorEvent.values[2]);

                Collection<Double> tmpCov = Arrays.asList(0.0025d,0d,0d, 0d,0.0025d,0d, 0d,0d,0.0025d);// TODO Make Parameter
                this.imu.setAngularVelocityCovariance(tmpCov);
                this.gyroTime = sensorEvent.timestamp;

//                logger.debug("Sensor gyro value : " + this.imu);
//                System.out.println("Sensor gyro value : " + this.imu);
            }
        }
    }
 
开发者ID:ros2java-alfred,项目名称:ros2_android,代码行数:17,代码来源:GyroscopeSensorAdapter.java

示例2: 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;
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:27,代码来源:SensorListActivity.java

示例3: FtcAndroidGyro

/**
 * Constructor: Creates an instance of the object.
 *
 * @param instanceName specifies the instance name.
 * @param filters specifies an array of filters to use for filtering sensor noise, one for each axis. Since we
 *                have 3 axes, the array should have 3 elements. If no filters are used, it can be set to null.
 */
public FtcAndroidGyro(String instanceName, TrcFilter[] filters)
{
    super(instanceName, 3, GYRO_HAS_X_AXIS | GYRO_HAS_Y_AXIS | GYRO_HAS_Z_AXIS | GYRO_INTEGRATE, filters);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    sensor = new FtcAndroidSensor(instanceName, Sensor.TYPE_GYROSCOPE, 3);
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:18,代码来源:FtcAndroidGyro.java

示例4: 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);
    }
}
 
开发者ID:ros2java-alfred,项目名称:ros2_android,代码行数:14,代码来源:ImuSensorAdapter.java

示例5: 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_GYROSCOPE) {

        // This timestamps delta rotation to be multiplied by the current rotation
        // after computing it from the gyro sample data.
        if (timestamp != 0) {
            final float dT = (event.timestamp - timestamp) * NS2S;
            // Axis of the rotation sample, not normalized yet.
            float axisX = event.values[0];
            float axisY = event.values[1];
            float axisZ = event.values[2];

            // Calculate the angular speed of the sample
            gyroscopeRotationVelocity = Math.sqrt(axisX * axisX + axisY * axisY + axisZ * axisZ);

            // Normalize the rotation vector if it's big enough to get the axis
            if (gyroscopeRotationVelocity > EPSILON) {
                axisX /= gyroscopeRotationVelocity;
                axisY /= gyroscopeRotationVelocity;
                axisZ /= gyroscopeRotationVelocity;
            }

            // Integrate around this axis with the angular speed by the timestep
            // in order to get a delta rotation from this sample over the timestep
            // We will convert this axis-angle representation of the delta rotation
            // into a quaternion before turning it into the rotation matrix.
            double thetaOverTwo = gyroscopeRotationVelocity * dT / 2.0f;
            double sinThetaOverTwo = Math.sin(thetaOverTwo);
            double cosThetaOverTwo = Math.cos(thetaOverTwo);
            deltaQuaternion.setX((float) (sinThetaOverTwo * axisX));
            deltaQuaternion.setY((float) (sinThetaOverTwo * axisY));
            deltaQuaternion.setZ((float) (sinThetaOverTwo * axisZ));
            deltaQuaternion.setW(-(float) cosThetaOverTwo);

            // Matrix rendering in CubeRenderer does not seem to have this problem.
            synchronized (synchronizationToken) {
                // Move current gyro orientation if gyroscope should be used
                deltaQuaternion.multiplyByQuat(currentOrientationQuaternion, currentOrientationQuaternion);
            }

            correctedQuaternion.set(currentOrientationQuaternion);
            // We inverted w in the deltaQuaternion, because currentOrientationQuaternion required it.
            // Before converting it back to matrix representation, we need to revert this process
            correctedQuaternion.w(-correctedQuaternion.w());

            synchronized (synchronizationToken) {
                // Set the rotation matrix as well to have both representations
                SensorManager.getRotationMatrixFromVector(currentOrientationRotationMatrix.matrix,
                        correctedQuaternion.array());
            }
        }
        timestamp = event.timestamp;
    }
}
 
开发者ID:peter10110,项目名称:Android-SteamVR-controller,代码行数:58,代码来源:CalibratedGyroscopeProvider.java

示例6: 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;
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:58,代码来源:XSensorManager.java

示例7: sendSensorUnavailableReport

private void sendSensorUnavailableReport(int type) {
    switch(type) {
        case Sensor.TYPE_GYROSCOPE:
        ACRA.getErrorReporter().handleSilentException(new Throwable("no sensors are found for type TYPE_GYROSCOPE"));
        break;
        //default:
        //ACRA.getErrorReporter().handleSilentException(new Throwable("test error send"));
        //break;
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:10,代码来源:GravityAccelerometerDetector.java

示例8: GyroscopeUpdatesProvider

GyroscopeUpdatesProvider(int sensorDelay) {
    super(Sensor.TYPE_GYROSCOPE, sensorDelay);
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:3,代码来源:GyroscopeUpdatesProvider.java

示例9: PGyroscope

public PGyroscope(AppRunner appRunner) {
    super(appRunner);

    type = Sensor.TYPE_GYROSCOPE;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:5,代码来源:PGyroscope.java

示例10: before

@Override
protected void before(XParam param) throws Throwable {
	switch (mMethod) {
	case getDefaultSensor:
		if (isRestricted(param))
			param.setResult(null);
		else if (param.args.length > 0 && param.args[0] instanceof Integer)
			if (isRestricted(param, (Integer) param.args[0]))
				param.setResult(null);
		break;

	case getSensorList:
		if (isRestricted(param))
			param.setResult(new ArrayList<Sensor>());
		else if (param.args.length > 0 && param.args[0] instanceof Integer)
			if (isRestricted(param, (Integer) param.args[0]))
				param.setResult(new ArrayList<Sensor>());
		break;

	case registerListener:
		if (param.args.length > 2 && param.args[1] instanceof Sensor && param.args[2] instanceof Integer) {
			int type = ((Sensor) param.args[1]).getType();
			if (type == Sensor.TYPE_GYROSCOPE || type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) {
				int rateUs = (Integer) param.args[2];

				// http://developer.android.com/guide/topics/sensors/sensors_overview.html
				if (rateUs == SensorManager.SENSOR_DELAY_NORMAL)
					return; // 200,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_UI)
					return; // 60,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_GAME)
					return; // 20,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_FASTEST)
					; // 0 us

				if (rateUs < cMaxRateUs) // 10,000 us
					if (isRestricted(param))
						param.args[2] = cMaxRateUs;
			}
		}
		break;
	}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:43,代码来源:XSensorManager.java

示例11: onSensorChanged

@Override
public void onSensorChanged(SensorEvent event)
{
	if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
	{
		// Get a local copy of the raw magnetic values from the device
		// sensor.
		//Log.d(tag, "Hello ~~");
		System.arraycopy(event.values, 0, this.vAcceleration, 0,
				this.vGyroscope.length);

		if (meanFilterSmoothingEnabled)
		{
			this.vAcceleration = meanFilterAcceleration	//杩涜绉诲姩骞冲潎婊ゆ尝
					.addSamples(this.vAcceleration);
		}

		// We fuse the orientation of the magnetic and acceleration sensor
		// based on acceleration sensor updates. It could be done when the
		// magnetic sensor updates or when they both have updated if you
		// want to spend the resources to make the checks.
		calculateOrientationAccelMag();		//?
	}

	if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD)
	{
		// Get a local copy of the raw magnetic values from the device
		// sensor.
		//Log.d(tag, "Hello ~~");
		System.arraycopy(event.values, 0, this.vMagnetic, 0,
				this.vGyroscope.length);

		if (meanFilterSmoothingEnabled)
		{
			this.vMagnetic = meanFilterMagnetic.addSamples(this.vMagnetic);
		}
	}

	if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE)
	{
		//Log.d(tag, "Hello ~~");
		System.arraycopy(event.values, 0, this.vGyroscope, 0,
				this.vGyroscope.length);

		if (meanFilterSmoothingEnabled)
		{
			this.vGyroscope = meanFilterGyroscope
					.addSamples(this.vGyroscope);
		}

		timeStampGyroscope = event.timestamp;

		onGyroscopeChanged();
	}

	if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE_UNCALIBRATED)
	{
		System.arraycopy(event.values, 0, this.vGyroscope, 0,
				this.vGyroscope.length);

		if (meanFilterSmoothingEnabled)
		{
			this.vGyroscope = meanFilterGyroscope
					.addSamples(this.vGyroscope);
		}

		timeStampGyroscope = event.timestamp;

		onGyroscopeChanged();
	}

}
 
开发者ID:HyfUestc,项目名称:PDR,代码行数:72,代码来源:Orientation.java


注:本文中的android.hardware.Sensor.TYPE_GYROSCOPE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。