• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ModernRoboticsI2cGyro类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro的典型用法代码示例。如果您正苦于以下问题:Java ModernRoboticsI2cGyro类的具体用法?Java ModernRoboticsI2cGyro怎么用?Java ModernRoboticsI2cGyro使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: initRobot

import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro; //导入依赖的package包/类
private void initRobot()
{
    lfWheel = hardwareMap.dcMotor.get("lfWheel");
    rfWheel = hardwareMap.dcMotor.get("rfWheel");
    lrWheel = hardwareMap.dcMotor.get("lrWheel");
    rrWheel = hardwareMap.dcMotor.get("rrWheel");
    lfWheel.setDirection(LEFTWHEEL_DIRECTION);
    lrWheel.setDirection(LEFTWHEEL_DIRECTION);
    rfWheel.setDirection(RIGHTWHEEL_DIRECTION);
    rrWheel.setDirection(RIGHTWHEEL_DIRECTION);

    lfWheel.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
    rfWheel.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
    lrWheel.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
    rrWheel.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
    lfWheel.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
    rfWheel.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
    lrWheel.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
    rrWheel.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);

    gyro = (ModernRoboticsI2cGyro)hardwareMap.gyroSensor.get("gyroSensor");
    gyro.resetZAxisIntegrator();
}
 
开发者ID:trc492,项目名称:FtcSamples,代码行数:24,代码来源:SensorSampleTimeTest.java


示例2: FtcMRGyro

import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro; //导入依赖的package包/类
/**
     * Constructor: Creates an instance of the object.
     *
     * @param hardwareMap specifies the global hardware map.
     * @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 FtcMRGyro(HardwareMap hardwareMap, String instanceName, TrcFilter[] filters)
    {
        super(instanceName, 3, GYRO_HAS_X_AXIS | GYRO_HAS_Y_AXIS | GYRO_HAS_Z_AXIS, filters);

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

        gyro = (ModernRoboticsI2cGyro)hardwareMap.gyroSensor.get(instanceName);
//        sensorState = new FtcI2cDeviceState(instanceName, gyro);
    }
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:21,代码来源:FtcMRGyro.java


示例3: runOpMode

import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro; //导入依赖的package包/类
@Override
public void runOpMode() {

    /*
     * Initialize the standard drive system variables.
     * The init() method of the hardware class does most of the work here
     */
    robot.init(hardwareMap);
    gyro = (ModernRoboticsI2cGyro)hardwareMap.gyroSensor.get("gyro");

    // Ensure the robot it stationary, then reset the encoders and calibrate the gyro.
    robot.leftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
    robot.rightMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);

    // Send telemetry message to alert driver that we are calibrating;
    telemetry.addData(">", "Calibrating Gyro");    //
    telemetry.update();

    gyro.calibrate();

    // make sure the gyro is calibrated before continuing
    while (!isStopRequested() && gyro.isCalibrating())  {
        sleep(50);
        idle();
    }

    telemetry.addData(">", "Robot Ready.");    //
    telemetry.update();

    robot.leftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
    robot.rightMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

    // Wait for the game to start (Display Gyro value), and reset gyro before we move..
    while (!isStarted()) {
        telemetry.addData(">", "Robot Heading = %d", gyro.getIntegratedZValue());
        telemetry.update();
        idle();
    }
    gyro.resetZAxisIntegrator();

    // Step through each leg of the path,
    // Note: Reverse movement is obtained by setting a negative distance (not speed)
    // Put a hold after each turn
    gyroDrive(DRIVE_SPEED, 48.0, 0.0);    // Drive FWD 48 inches
    gyroTurn( TURN_SPEED, -45.0);         // Turn  CCW to -45 Degrees
    gyroHold( TURN_SPEED, -45.0, 0.5);    // Hold -45 Deg heading for a 1/2 second
    gyroTurn( TURN_SPEED,  45.0);         // Turn  CW  to  45 Degrees
    gyroHold( TURN_SPEED,  45.0, 0.5);    // Hold  45 Deg heading for a 1/2 second
    gyroTurn( TURN_SPEED,   0.0);         // Turn  CW  to   0 Degrees
    gyroHold( TURN_SPEED,   0.0, 1.0);    // Hold  0 Deg heading for a 1 second
    gyroDrive(DRIVE_SPEED,-48.0, 0.0);    // Drive REV 48 inches
    gyroHold( TURN_SPEED,   0.0, 0.5);    // Hold  0 Deg heading for a 1/2 second

    telemetry.addData("Path", "Complete");
    telemetry.update();
}
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:57,代码来源:PushbotAutoDriveByGyro_Linear.java


示例4: runOpMode

import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro; //导入依赖的package包/类
@Override
public void runOpMode() {

    /*
     * Initialize the standard drive system variables.
     * The init() method of the hardware class does most of the work here
     */
    robot.init(hardwareMap);
    gyro = (ModernRoboticsI2cGyro)hardwareMap.gyroSensor.get("gyro");

    // Ensure the robot it stationary, then reset the encoders and calibrate the gyro.
    robot.leftDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
    robot.rightDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);

    // Send telemetry message to alert driver that we are calibrating;
    telemetry.addData(">", "Calibrating Gyro");    //
    telemetry.update();

    gyro.calibrate();

    // make sure the gyro is calibrated before continuing
    while (!isStopRequested() && gyro.isCalibrating())  {
        sleep(50);
        idle();
    }

    telemetry.addData(">", "Robot Ready.");    //
    telemetry.update();

    robot.leftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
    robot.rightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

    // Wait for the game to start (Display Gyro value), and reset gyro before we move..
    while (!isStarted()) {
        telemetry.addData(">", "Robot Heading = %d", gyro.getIntegratedZValue());
        telemetry.update();
    }

    gyro.resetZAxisIntegrator();

    // Step through each leg of the path,
    // Note: Reverse movement is obtained by setting a negative distance (not speed)
    // Put a hold after each turn
    gyroDrive(DRIVE_SPEED, 48.0, 0.0);    // Drive FWD 48 inches
    gyroTurn( TURN_SPEED, -45.0);         // Turn  CCW to -45 Degrees
    gyroHold( TURN_SPEED, -45.0, 0.5);    // Hold -45 Deg heading for a 1/2 second
    gyroDrive(DRIVE_SPEED, 12.0, -45.0);  // Drive FWD 12 inches at 45 degrees
    gyroTurn( TURN_SPEED,  45.0);         // Turn  CW  to  45 Degrees
    gyroHold( TURN_SPEED,  45.0, 0.5);    // Hold  45 Deg heading for a 1/2 second
    gyroTurn( TURN_SPEED,   0.0);         // Turn  CW  to   0 Degrees
    gyroHold( TURN_SPEED,   0.0, 1.0);    // Hold  0 Deg heading for a 1 second
    gyroDrive(DRIVE_SPEED,-48.0, 0.0);    // Drive REV 48 inches

    telemetry.addData("Path", "Complete");
    telemetry.update();
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:57,代码来源:PushbotAutoDriveByGyro_Linear.java


示例5: runOpMode

import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro; //导入依赖的package包/类
@Override
public void runOpMode() {

  boolean lastResetState = false;
  boolean curResetState  = false;

  // Get a reference to a Modern Robotics gyro object. We use several interfaces
  // on this object to illustrate which interfaces support which functionality.
  modernRoboticsI2cGyro = hardwareMap.get(ModernRoboticsI2cGyro.class, "gyro");
  gyro = (IntegratingGyroscope)modernRoboticsI2cGyro;
  // If you're only interested int the IntegratingGyroscope interface, the following will suffice.
  // gyro = hardwareMap.get(IntegratingGyroscope.class, "gyro");
  // A similar approach will work for the Gyroscope interface, if that's all you need.

  // Start calibrating the gyro. This takes a few seconds and is worth performing
  // during the initialization phase at the start of each opMode.
  telemetry.log().add("Gyro Calibrating. Do Not Move!");
  modernRoboticsI2cGyro.calibrate();

  // Wait until the gyro calibration is complete
  timer.reset();
  while (!isStopRequested() && modernRoboticsI2cGyro.isCalibrating())  {
    telemetry.addData("calibrating", "%s", Math.round(timer.seconds())%2==0 ? "|.." : "..|");
    telemetry.update();
    sleep(50);
  }

  telemetry.log().clear(); telemetry.log().add("Gyro Calibrated. Press Start.");
  telemetry.clear(); telemetry.update();

  // Wait for the start button to be pressed
  waitForStart();
  telemetry.log().clear();
  telemetry.log().add("Press A & B to reset heading");

  // Loop until we're asked to stop
  while (opModeIsActive())  {

    // If the A and B buttons are pressed just now, reset Z heading.
    curResetState = (gamepad1.a && gamepad1.b);
    if (curResetState && !lastResetState) {
      modernRoboticsI2cGyro.resetZAxisIntegrator();
    }
    lastResetState = curResetState;

    // The raw() methods report the angular rate of change about each of the
    // three axes directly as reported by the underlying sensor IC.
    int rawX = modernRoboticsI2cGyro.rawX();
    int rawY = modernRoboticsI2cGyro.rawY();
    int rawZ = modernRoboticsI2cGyro.rawZ();
    int heading = modernRoboticsI2cGyro.getHeading();
    int integratedZ = modernRoboticsI2cGyro.getIntegratedZValue();

    // Read dimensionalized data from the gyro. This gyro can report angular velocities
    // about all three axes. Additionally, it internally integrates the Z axis to
    // be able to report an absolute angular Z orientation.
    AngularVelocity rates = gyro.getAngularVelocity(AngleUnit.DEGREES);
    float zAngle = gyro.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES).firstAngle;

    // Read administrative information from the gyro
    int zAxisOffset = modernRoboticsI2cGyro.getZAxisOffset();
    int zAxisScalingCoefficient = modernRoboticsI2cGyro.getZAxisScalingCoefficient();

    telemetry.addLine()
      .addData("dx", formatRate(rates.xRotationRate))
      .addData("dy", formatRate(rates.yRotationRate))
      .addData("dz", "%s deg/s", formatRate(rates.zRotationRate));
    telemetry.addData("angle", "%s deg", formatFloat(zAngle));
    telemetry.addData("heading", "%3d deg", heading);
    telemetry.addData("integrated Z", "%3d", integratedZ);
    telemetry.addLine()
      .addData("rawX", formatRaw(rawX))
      .addData("rawY", formatRaw(rawY))
      .addData("rawZ", formatRaw(rawZ));
    telemetry.addLine().addData("z offset", zAxisOffset).addData("z coeff", zAxisScalingCoefficient);
    telemetry.update();
  }
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:79,代码来源:SensorMRGyro.java


示例6: runOpMode

import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro; //导入依赖的package包/类
@Override
public void runOpMode() throws InterruptedException {

    /*
     * Initialize the standard drive system variables.
     * The init() method of the hardware class does most of the work here
     */
    robot.init(hardwareMap);
    gyro = (ModernRoboticsI2cGyro)hardwareMap.gyroSensor.get("gyro");

    // Ensure the robot it stationary, then reset the encoders and calibrate the gyro.
    robot.leftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
    robot.rightMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);

    // Send telemetry message to alert driver that we are calibrating;
    telemetry.addData(">", "Calibrating Gyro");    //
    telemetry.update();

    gyro.calibrate();

    // make sure the gyro is calibrated before continuing
    while (gyro.isCalibrating())  {
        Thread.sleep(50);
        idle();
    }

    telemetry.addData(">", "Robot Ready.");    //
    telemetry.update();

    robot.leftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
    robot.rightMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

    // Wait for the game to start (Display Gyro value), and reset gyro before we move..
    while (!isStarted()) {
        telemetry.addData(">", "Robot Heading = %d", gyro.getIntegratedZValue());
        telemetry.update();
        idle();
    }
    gyro.resetZAxisIntegrator();

    // Step through each leg of the path,
    // Note: Reverse movement is obtained by setting a negative distance (not speed)
    // Put a hold after each turn
    gyroDrive(DRIVE_SPEED, 48.0, 0.0);    // Drive FWD 48 inches
    gyroTurn( TURN_SPEED, -45.0);         // Turn  CCW to -45 Degrees
    gyroHold( TURN_SPEED, -45.0, 0.5);    // Hold -45 Deg heading for a 1/2 second
    gyroTurn( TURN_SPEED,  45.0);         // Turn  CW  to  45 Degrees
    gyroHold( TURN_SPEED,  45.0, 0.5);    // Hold  45 Deg heading for a 1/2 second
    gyroTurn( TURN_SPEED,   0.0);         // Turn  CW  to   0 Degrees
    gyroHold( TURN_SPEED,   0.0, 1.0);    // Hold  0 Deg heading for a 1 second
    gyroDrive(DRIVE_SPEED,-48.0, 0.0);    // Drive REV 48 inches
    gyroHold( TURN_SPEED,   0.0, 0.5);    // Hold  0 Deg heading for a 1/2 second

    telemetry.addData("Path", "Complete");
    telemetry.update();
}
 
开发者ID:forgod01,项目名称:5094-2016-2017,代码行数:57,代码来源:PushbotAutoDriveByGyro_Linear.java


示例7: runOpMode

import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro; //导入依赖的package包/类
@Override
public void runOpMode() throws InterruptedException {

    /*
     * Initialize the standard drive system variables.
     * The init() method of the hardware class does most of the work here
     */
    robot.init(hardwareMap);
    gyro = (ModernRoboticsI2cGyro)hardwareMap.gyroSensor.get("gyro");

    // Ensure the robot it stationary, then reset the encoders and calibrate the gyro.
    robot.leftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
    robot.rightMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);

    // Send telemetry message to alert driver that we are calibrating;
    telemetry.addData(">", "Calibrating Gyro");    //
    telemetry.update();

    gyro.calibrate();

    // make sure the gyro is calibrated before continuing
    while (!isStopRequested() && gyro.isCalibrating()) {
        sleep(50);
        idle();
    }

    telemetry.addData(">", "Robot Ready.");    //
    telemetry.update();

    robot.leftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
    robot.rightMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

    // Wait for the game to start (Display Gyro value), and reset gyro before we move..
    while (!isStarted()) {
        telemetry.addData(">", "Robot Heading = %d", gyro.getIntegratedZValue());
        telemetry.update();
        idle();
    }
    gyro.resetZAxisIntegrator();

    // Step through each leg of the path,
    // Note: Reverse movement is obtained by setting a negative distance (not speed)
    // Put a hold after each turn
    gyroDrive(DRIVE_SPEED, 48.0, 0.0);    // Drive FWD 48 inches
    gyroTurn( TURN_SPEED, -45.0);         // Turn  CCW to -45 Degrees
    gyroHold( TURN_SPEED, -45.0, 0.5);    // Hold -45 Deg heading for a 1/2 second
    gyroTurn( TURN_SPEED,  45.0);         // Turn  CW  to  45 Degrees
    gyroHold( TURN_SPEED,  45.0, 0.5);    // Hold  45 Deg heading for a 1/2 second
    gyroTurn( TURN_SPEED,   0.0);         // Turn  CW  to   0 Degrees
    gyroHold( TURN_SPEED,   0.0, 1.0);    // Hold  0 Deg heading for a 1 second
    gyroDrive(DRIVE_SPEED,-48.0, 0.0);    // Drive REV 48 inches
    gyroHold( TURN_SPEED,   0.0, 0.5);    // Hold  0 Deg heading for a 1/2 second

    telemetry.addData("Path", "Complete");
    telemetry.update();
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:57,代码来源:PushbotAutoDriveByGyro_Linear.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RepositoryImpl类代码示例发布时间:2022-05-23
下一篇:
Java PrestoException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap