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

Java DcMotorController类代码示例

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

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



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


示例16: reset_left_drive_encoder

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
/**
 * Reset the left drive wheel encoder.
 */
public void reset_left_drive_encoder ()

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

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


示例17: reset_right_drive_encoder

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
/**
 * Reset the right drive wheel encoder.
 */
public void reset_right_drive_encoder ()

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

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


示例18: createDeviceMaps

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
/**
 * Move the propriety {@link HardwareMap.DeviceMapping} to our {@link DeviceMap} for our
 * internal use
 */
private void createDeviceMaps() {
    fullMap.checkedPut(DcMotorController.class, new DeviceMap<>(basicMap.dcMotorController));
    fullMap.checkedPut(DcMotor.class, new DeviceMap<>(basicMap.dcMotor));
    fullMap.checkedPut(ServoController.class, new DeviceMap<>(basicMap.servoController));
    fullMap.checkedPut(Servo.class, new DeviceMap<>(basicMap.servo));
    fullMap.checkedPut(LegacyModule.class, new DeviceMap<>(basicMap.legacyModule));
    fullMap.checkedPut(TouchSensorMultiplexer.class, new DeviceMap<>(basicMap.touchSensorMultiplexer));
    fullMap.checkedPut(DeviceInterfaceModule.class, new DeviceMap<>(basicMap.deviceInterfaceModule));
    fullMap.checkedPut(AnalogInput.class, new DeviceMap<>(basicMap.analogInput));
    fullMap.checkedPut(DigitalChannel.class, new DeviceMap<>(basicMap.digitalChannel));
    fullMap.checkedPut(OpticalDistanceSensor.class, new DeviceMap<>(basicMap.opticalDistanceSensor));
    fullMap.checkedPut(TouchSensor.class, new DeviceMap<>(basicMap.touchSensor));
    fullMap.checkedPut(PWMOutput.class, new DeviceMap<>(basicMap.pwmOutput));
    fullMap.checkedPut(I2cDevice.class, new DeviceMap<>(basicMap.i2cDevice));
    fullMap.checkedPut(AnalogOutput.class, new DeviceMap<>(basicMap.analogOutput));
    fullMap.checkedPut(ColorSensor.class, new DeviceMap<>(basicMap.colorSensor));
    fullMap.checkedPut(LED.class, new DeviceMap<>(basicMap.led));
    fullMap.checkedPut(AccelerationSensor.class, new DeviceMap<>(basicMap.accelerationSensor));
    fullMap.checkedPut(CompassSensor.class, new DeviceMap<>(basicMap.compassSensor));
    fullMap.checkedPut(GyroSensor.class, new DeviceMap<>(basicMap.gyroSensor));
    fullMap.checkedPut(IrSeekerSensor.class, new DeviceMap<>(basicMap.irSeekerSensor));
    fullMap.checkedPut(LightSensor.class, new DeviceMap<>(basicMap.lightSensor));
    fullMap.checkedPut(UltrasonicSensor.class, new DeviceMap<>(basicMap.ultrasonicSensor));
    fullMap.checkedPut(VoltageSensor.class, new DeviceMap<>(basicMap.voltageSensor));

    LinkedHashMultimap<DcMotorController, DcMotor> multimap = LinkedHashMultimap.create();
    for (DcMotor motor : dcMotors()) {
        multimap.put(motor.getController(), motor);
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:35,代码来源:ExtensibleHardwareMap.java


示例19: i2cAddrOfLegacyMotorController

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
public static int i2cAddrOfLegacyMotorController(DcMotorController controller) {
    // From the spec from HiTechnic:
    //
    // "The first motor controller in the daisy chain will use an I2C address of 02/03. Subsequent
    // controllers will obtain addresses of 04/05, 06/07 and 08/09. Only four controllers may be
    // daisy chained."
    //
    // The legacy module appears not to support daisy chaining; it only supports the first
    // address. Note that these are clearly 8-bit addresses, not 7-bit.
    //
    return 0x02;
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:13,代码来源:MemberUtil.java


示例20: calculateUsbDevices

import com.qualcomm.robotcore.hardware.DcMotorController; //导入依赖的package包/类
protected int calculateUsbDevices(HardwareMap map) {
    byte var2 = 0;
    int var7 = var2 + map.legacyModule.size();
    var7 += map.deviceInterfaceModule.size();
    Iterator var3 = map.servoController.iterator();

    String var5;
    Pattern pattern = Pattern.compile("(?i)usb");
    while (var3.hasNext()) {
        ServoController var4 = (ServoController) var3.next();
        var5 = var4.getDeviceName();
        if (pattern.matcher(var5).find()) {
            ++var7;
        }
    }

    var3 = map.dcMotorController.iterator();

    while (var3.hasNext()) {
        DcMotorController var8 = (DcMotorController) var3.next();
        var5 = var8.getDeviceName();
        pattern = Pattern.compile("(?i)usb");
        if (pattern.matcher(var5).find()) {
            ++var7;
        }
    }

    return var7;
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:30,代码来源:Analytics.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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