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


Java DcMotorController类代码示例

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


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

示例1: init_loop

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
@Override
public void init_loop() {

  devMode = DcMotorController.DeviceMode.WRITE_ONLY;

  motorRight.setDirection(DcMotor.Direction.REVERSE);
  //motorLeft.setDirection(DcMotor.Direction.REVERSE);

  // set the mode
  // Nxt devices start up in "write" mode by default, so no need to switch device modes here.
  motorLeft.setMode(DcMotorController.RunMode.RUN_WITHOUT_ENCODERS);
  motorRight.setMode(DcMotorController.RunMode.RUN_WITHOUT_ENCODERS);

  wristPosition = 0.6;
  clawPosition = 0.5;
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:FTC-Simple,代码行数:17,代码来源:NxtTeleOp.java

示例2: run_without_left_drive_encoder

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
/**
 * Set the left drive wheel encoder to run, if the mode is appropriate.
 */
public void run_without_left_drive_encoder ()

{
    if (v_motor_left_drive != null)
    {
        if (v_motor_left_drive.getMode () ==
            DcMotorController.RunMode.RESET_ENCODERS)
        {
            v_motor_left_drive.setMode
                ( DcMotorController.RunMode.RUN_WITHOUT_ENCODERS
                );
        }
    }

}
 
开发者ID:MHS-FIRSTrobotics,项目名称:FTC-Simple,代码行数:19,代码来源:PushBotHardware.java

示例3: run_without_right_drive_encoder

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
/**
 * Set the right drive wheel encoder to run, if the mode is appropriate.
 */
public void run_without_right_drive_encoder ()

{
    if (v_motor_right_drive != null)
    {
        if (v_motor_right_drive.getMode () ==
            DcMotorController.RunMode.RESET_ENCODERS)
        {
            v_motor_right_drive.setMode
                ( DcMotorController.RunMode.RUN_WITHOUT_ENCODERS
                );
        }
    }

}
 
开发者ID:MHS-FIRSTrobotics,项目名称:FTC-Simple,代码行数:19,代码来源:PushBotHardware.java

示例4: runOpMode

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
@Override
public void runOpMode() throws InterruptedException {
    leftMotor = hardwareMap.dcMotor.get("left_drive");
    rightMotor = hardwareMap.dcMotor.get("right_drive");
    rightMotor.setDirection(DcMotor.Direction.REVERSE);
    leftMotor.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    rightMotor.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);

    waitForStart();

    for(int i=0; i<4; i++) {
        leftMotor.setPower(1.0);
        rightMotor.setPower(1.0);

        sleep(1000);

        leftMotor.setPower(0.5);
        rightMotor.setPower(-0.5);

        sleep(500);
    }

    leftMotor.setPowerFloat();
    rightMotor.setPowerFloat();

}
 
开发者ID:MHS-FIRSTrobotics,项目名称:FTC-Simple,代码行数:27,代码来源:PushBotSquare.java

示例5: mapMatrixController

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
private void mapMatrixController(HardwareMap map, DeviceManager deviceMgr, LegacyModule legacyModule, DeviceConfiguration devConf) {
    if (!devConf.isEnabled()) return;
    MatrixMasterController master = new MatrixMasterController((ModernRoboticsUsbLegacyModule) legacyModule, devConf.getPort());

    DcMotorController mc = new MatrixDcMotorController(master);
    map.dcMotorController.put(devConf.getName() + "Motor", mc);
    map.dcMotorController.put(devConf.getName(), mc);
    for (DeviceConfiguration motorConf : ((MatrixControllerConfiguration) devConf).getMotors()) {
        mapMotor(map, deviceMgr, motorConf, mc);
    }

    ServoController sc = new MatrixServoController(master);
    map.servoController.put(devConf.getName() + "Servo", sc);
    map.servoController.put(devConf.getName(), sc);
    for (DeviceConfiguration servoConf : ((MatrixControllerConfiguration) devConf).getServos()) {
        mapServo(map, deviceMgr, servoConf, sc);
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:19,代码来源:XtensibleEventLoop.java

示例6: create

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
public static DcMotorController create(DcMotorController target, DcMotor motor1, DcMotor motor2) {
    if (MemberUtil.isLegacyMotorController(target)) {
        LegacyModule legacyModule = MemberUtil.legacyModuleOfLegacyMotorController(target);
        int port = MemberUtil.portOfLegacyMotorController(target);
        int i2cAddr8Bit = MemberUtil.i2cAddrOfLegacyMotorController(target);

        // Make a new legacy motor controller
        II2cDevice i2cDevice = new I2cDeviceOnI2cDeviceController(legacyModule, port);
        I2cDeviceClient i2cDeviceClient = new I2cDeviceClient(null, i2cDevice, i2cAddr8Bit, false);
        HiTechnicDcMotorController controller = new HiTechnicDcMotorController(i2cDeviceClient, target);

        controller.setMotors(motor1, motor2);
        controller.arm();

        return controller;
    } else {
        // The target isn't a legacy motor controller, so we can't swap anything in for him.
        // Return the raw target (rather than, e.g., throwing) so that caller doesn't need to check
        // what kind of controller he has in hand.
        return target;
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:23,代码来源:HiTechnicDcMotorController.java

示例7: create

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
public static DcMotorController create(OpMode context, DcMotorController target, DcMotor motor1, DcMotor motor2) {
    if (MemberUtil.isLegacyMotorController(target)) {
        LegacyModule legacyModule = MemberUtil.legacyModuleOfLegacyMotorController(target);
        int port = MemberUtil.portOfLegacyMotorController(target);
        int i2cAddr8Bit = MemberUtil.i2cAddrOfLegacyMotorController(target);

        // Make a new legacy motor controller
        II2cDevice i2cDevice = new I2cDeviceOnI2cDeviceController(legacyModule, port);
        I2cDeviceClient i2cDeviceClient = new I2cDeviceClient(context, i2cDevice, i2cAddr8Bit, false);
        EasyLegacyMotorController controller = new EasyLegacyMotorController(context, i2cDeviceClient, target);

        controller.setMotors(motor1, motor2);
        controller.arm();

        return controller;
    } else {
        // The target isn't a legacy motor controller, so we can't swap anything in for him.
        // Return the raw target (rather than, e.g., throwing) so that caller doesn't need to check
        // what kind of controller he has in hand.
        return target;
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:23,代码来源:EasyLegacyMotorController.java

示例8: init_loop

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
@Override
public void init_loop() {

    devMode = DcMotorController.DeviceMode.WRITE_ONLY;

    motorRight.setDirection(DcMotor.Direction.REVERSE);
    //motorLeft.setDirection(DcMotor.Direction.REVERSE);

    // set the mode
    // Nxt devices start up in "write" mode by default, so no need to switch device modes here.
    motorLeft.setMode(DcMotorController.RunMode.RUN_WITHOUT_ENCODERS);
    motorRight.setMode(DcMotorController.RunMode.RUN_WITHOUT_ENCODERS);

    wristPosition = 0.6;
    clawPosition = 0.5;
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:17,代码来源:NxtTeleOp.java

示例9: moveRobot

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
public void moveRobot(int distance) {
    stopRobot();
    double clicks = (distance / WHEEL_CIRCUMFERENCE) * GEAR_RATIO * ENCODER_CPR;
    frontMotorLeft.setMode(DcMotorController.RunMode.RESET_ENCODERS);
    frontMotorRight.setMode(DcMotorController.RunMode.RESET_ENCODERS);
    frontMotorLeft.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    frontMotorRight.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    while (frontMotorLeft.getCurrentPosition() < clicks || frontMotorRight.getCurrentPosition() < clicks) {
        frontMotorLeft.setPower(MAX_POWER);
        frontMotorRight.setPower(MAX_POWER);
        backMotorLeft.setPower(MAX_POWER);
        backMotorRight.setPower(MAX_POWER);
        telemetry.addData("RCLicks", frontMotorRight.getCurrentPosition());
        telemetry.addData("LCLicks", frontMotorLeft.getCurrentPosition());
    }
    stopRobot();
}
 
开发者ID:TinoShockwave,项目名称:Opmodes,代码行数:18,代码来源:AutonomousTesting.java

示例10: moveRobot

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
public void moveRobot(int distance) {
    stopRobot();
    double clicks = (distance / WHEEL_CIRCUMFERENCE) * GEAR_RATIO * ENCODER_CPR * -1;
    frontMotorLeft.setMode(DcMotorController.RunMode.RESET_ENCODERS);
    frontMotorRight.setMode(DcMotorController.RunMode.RESET_ENCODERS);
    frontMotorLeft.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    frontMotorRight.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    while (frontMotorLeft.getCurrentPosition() > clicks || frontMotorRight.getCurrentPosition() > clicks) {
        frontMotorLeft.setPower(-MAX_POWER);
        frontMotorRight.setPower(-MAX_POWER);
        backMotorLeft.setPower(-MAX_POWER);
        backMotorRight.setPower(-MAX_POWER);
        telemetry.addData("RCLicks", frontMotorRight.getCurrentPosition());
        telemetry.addData("LCLicks", frontMotorLeft.getCurrentPosition());
    }
    stopRobot();
}
 
开发者ID:TinoShockwave,项目名称:Opmodes,代码行数:18,代码来源:AutonomousBlue_v3.java

示例11: runOpMode

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
@Override
public void runOpMode() throws InterruptedException {
    leftMotor = hardwareMap.dcMotor.get("left_drive");
    rightMotor = hardwareMap.dcMotor.get("right_drive");
    rightMotor.setDirection(DcMotor.Direction.REVERSE);
    leftMotor.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    rightMotor.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);

    waitForStart();

    for (int i = 0; i < 4; i++) {
        leftMotor.setPower(1.0);
        rightMotor.setPower(1.0);

        sleep(1000);

        leftMotor.setPower(0.5);
        rightMotor.setPower(-0.5);

        sleep(500);
    }

    leftMotor.setPowerFloat();
    rightMotor.setPowerFloat();

}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:27,代码来源:PushBotSquare.java

示例12: start

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
@Override
public void start() {

    driveRightFront.setTargetPosition((int) Counts);
    driveLeftFront.setTargetPosition((int) Counts);
    driveRightBack.setTargetPosition((int) Counts);
    driveLeftBack.setTargetPosition((int) Counts);

    driveRightFront.setChannelMode(DcMotorController.RunMode.RUN_TO_POSITION);
    driveLeftFront.setChannelMode(DcMotorController.RunMode.RUN_TO_POSITION);
    driveRightBack.setChannelMode(DcMotorController.RunMode.RUN_TO_POSITION);
    driveLeftBack.setChannelMode(DcMotorController.RunMode.RUN_TO_POSITION);

    driveRightFront.setPower(0.5);
    driveLeftFront.setPower(0.5);
    driveRightBack.setPower(0.5);
    driveLeftBack.setPower(0.5);

}
 
开发者ID:FTCTeam4991,项目名称:FTC2015-2016Game,代码行数:20,代码来源:FTC4991EncoderTest.java

示例13: moveRobot

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
public void moveRobot(int distance, double power, String direction) {
    resetEncoders();
    double encoderClicks = (distance / WHEEL_CIRCUMFERENCE) * GEAR_RATIO * ENCODER_CPR;
    frontMotorLeft.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    frontMotorRight.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    if (direction.equals("forward")) {
        while (frontMotorLeft.getCurrentPosition() <= encoderClicks || frontMotorRight.getCurrentPosition() <= encoderClicks) {
            moveMotor(frontMotorLeft, power);
            moveMotor(frontMotorRight, power);
            moveMotor(backMotorLeft, power);
            moveMotor(backMotorRight, power);
            telemetry.addData("Encoder Left", frontMotorLeft.getCurrentPosition());
            telemetry.addData("Encoder Right", frontMotorRight.getCurrentPosition());
        }
    } else if (direction.equals("backward")) {
        while (frontMotorLeft.getCurrentPosition() <= encoderClicks || frontMotorRight.getCurrentPosition() <= encoderClicks) {
            moveMotor(frontMotorLeft, -power);
            moveMotor(frontMotorRight, -power);
            moveMotor(backMotorLeft, -power);
            moveMotor(backMotorRight, -power);
            telemetry.addData("Encoder Left", frontMotorLeft.getCurrentPosition());
            telemetry.addData("Encoder Right", frontMotorRight.getCurrentPosition());
        }
    }
}
 
开发者ID:TinoShockwave,项目名称:Opmodes,代码行数:26,代码来源:Autonomous.java

示例14: run_using_left_drive_encoder

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
/**
 * Set the left drive wheel encoder to run, if the mode is appropriate.
 */
public void run_using_left_drive_encoder ()

{
    if (v_motor_left_drive != null)
    {
        v_motor_left_drive.setMode
            ( DcMotorController.RunMode.RUN_USING_ENCODERS
            );
    }

}
 
开发者ID:MHS-FIRSTrobotics,项目名称:FTC-Simple,代码行数:15,代码来源:PushBotHardware.java

示例15: run_using_right_drive_encoder

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
/**
 * Set the right drive wheel encoder to run, if the mode is appropriate.
 */
public void run_using_right_drive_encoder ()

{
    if (v_motor_right_drive != null)
    {
        v_motor_right_drive.setMode
            ( DcMotorController.RunMode.RUN_USING_ENCODERS
            );
    }

}
 
开发者ID:MHS-FIRSTrobotics,项目名称:FTC-Simple,代码行数:15,代码来源:PushBotHardware.java


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