本文整理汇总了Java中com.qualcomm.robotcore.hardware.GyroSensor.rawZ方法的典型用法代码示例。如果您正苦于以下问题:Java GyroSensor.rawZ方法的具体用法?Java GyroSensor.rawZ怎么用?Java GyroSensor.rawZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.qualcomm.robotcore.hardware.GyroSensor
的用法示例。
在下文中一共展示了GyroSensor.rawZ方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runOpMode
import com.qualcomm.robotcore.hardware.GyroSensor; //导入方法依赖的package包/类
@Override
public void runOpMode() throws InterruptedException {
GyroSensor sensorGyro;
int xVal, yVal, zVal = 0;
int heading = 0;
// write some device information (connection info, name and type)
// to the log file.
hardwareMap.logDevices();
// get a reference to our GyroSensor object.
sensorGyro = hardwareMap.gyroSensor.get("gyro");
// calibrate the gyro.
sensorGyro.calibrate();
// wait for the start button to be pressed.
waitForStart();
// make sure the gyro is calibrated.
while (sensorGyro.isCalibrating()) {
Thread.sleep(50);
}
while (opModeIsActive()) {
// if the A and B buttons are pressed, reset Z heading.
if(gamepad1.a && gamepad1.b) {
// reset heading.
sensorGyro.resetZAxisIntegrator();
}
// get the x, y, and z values (rate of change of angle).
xVal = sensorGyro.rawX();
yVal = sensorGyro.rawY();
zVal = sensorGyro.rawZ();
// get the heading info.
// the Modern Robotics' gyro sensor keeps
// track of the current heading for the Z axis only.
heading = sensorGyro.getHeading();
telemetry.addData("1. x", String.format("%03d", xVal));
telemetry.addData("2. y", String.format("%03d", yVal));
telemetry.addData("3. z", String.format("%03d", zVal));
telemetry.addData("4. h", String.format("%03d", heading));
Thread.sleep(100);
}
}
示例2: runOpMode
import com.qualcomm.robotcore.hardware.GyroSensor; //导入方法依赖的package包/类
@Override
public void runOpMode() throws InterruptedException {
GyroSensor sensorGyro;
int xVal, yVal, zVal = 0;
int heading = 0;
// write some device information (connection info, name and type)
// to the log file.
hardwareMap.logDevices();
// get a reference to our GyroSensor object.
sensorGyro = hardwareMap.gyroSensor.get("gyro");
// calibrate the gyro.
sensorGyro.calibrate();
// wait for the start button to be pressed.
waitForStart();
// make sure the gyro is calibrated.
while (sensorGyro.isCalibrating()) {
Thread.sleep(50);
}
while (opModeIsActive()) {
// if the A and B buttons are pressed, reset Z heading.
if (gamepad1.a && gamepad1.b) {
// reset heading.
sensorGyro.resetZAxisIntegrator();
}
// get the x, y, and z values (rate of change of angle).
xVal = sensorGyro.rawX();
yVal = sensorGyro.rawY();
zVal = sensorGyro.rawZ();
// get the heading info.
// the Modern Robotics' gyro sensor keeps
// track of the current heading for the Z axis only.
heading = sensorGyro.getHeading();
telemetry.addData("1. x", String.format("%03d", xVal));
telemetry.addData("2. y", String.format("%03d", yVal));
telemetry.addData("3. z", String.format("%03d", zVal));
telemetry.addData("4. h", String.format("%03d", heading));
Thread.sleep(100);
}
}