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


Java GyroSensor.rawX方法代码示例

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


在下文中一共展示了GyroSensor.rawX方法的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);
  }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:FTC-Simple,代码行数:51,代码来源:MRGyroTest.java

示例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);
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:51,代码来源:MRGyroTest.java


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