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


Java DcMotor.setPower方法代码示例

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


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

示例1: initTeleOp

import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
/**
     * Initializes all drive and ball motors in NO ENCODERS mode
     * @param hwMap
     */
    public void initTeleOp(HardwareMap hwMap) {
        this.hwMap = hwMap;
        initDrive();
        initBall();
//        initCap();
//        initServos();

        for(DcMotor driveMotor : driveMotors) {
            driveMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
            driveMotor.setDirection(DcMotorSimple.Direction.FORWARD);
            driveMotor.setPower(0);
        }
        for(DcMotor ballMotor : ballMotors) {
            ballMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
            ballMotor.setDirection(DcMotorSimple.Direction.FORWARD);
            ballMotor.setPower(0);
        }
//        cap.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
//        cap.setDirection(DcMotorSimple.Direction.FORWARD);
//        cap.setPower(0);
    }
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:26,代码来源:Robot.java

示例2: initAutoOp

import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
/**
     * Initializes all drive and ball motors in USING ENCODERS mode
     * @param hwMap
     */
    public void initAutoOp(LinearOpMode opMode, HardwareMap hwMap) {
        this.hwMap = hwMap;

        initDrive();
        initBall();
//        initCap();
//        initServos();
//        initSensors();

        for(DcMotor driveMotor : driveMotors) {
            driveMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
            opMode.idle();
            driveMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
            driveMotor.setDirection(DcMotorSimple.Direction.FORWARD);
            driveMotor.setPower(0);
        }
        for(DcMotor ballMotor : ballMotors) {
            ballMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
            opMode.idle();
            ballMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
            ballMotor.setDirection(DcMotorSimple.Direction.FORWARD);
            ballMotor.setPower(0);
        }
//        cap.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
//        cap.setDirection(DcMotorSimple.Direction.FORWARD);
//        cap.setPower(0);
    }
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:32,代码来源:Robot.java

示例3: runOpMode

import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
@Override
public void runOpMode() throws InterruptedException
    {
    DcMotor motor = this.hardwareMap.dcMotor.get("motorRight");
    Servo servo = this.hardwareMap.servo.get("servo");

    waitForStart();

    double servoPosition = 0;
    servo.setPosition(servoPosition);

    motor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);

    ElapsedTime elapsedTime = new ElapsedTime();
    int spinCount = 0;

    while (this.opModeIsActive())
        {
        servoPosition += 1. / 256.;
        if (servoPosition >= 1)
            servoPosition = 0;
        servo.setPosition(servoPosition);

        motor.setPower(0.15);

        spinCount++;
        double ms = elapsedTime.milliseconds();
        telemetry.addData("position", format(servoPosition));
        telemetry.addData("#spin",    format(spinCount));
        telemetry.addData("ms/spin",  format(ms / spinCount));
        this.updateTelemetry(telemetry);
        }

    motor.setPower(0);
    }
 
开发者ID:forgod01,项目名称:5094-2016-2017,代码行数:36,代码来源:TestMotorServoLinear.java

示例4: setDriveMotorPower

import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
public void setDriveMotorPower(double power) {
    for (DcMotor motor : driveMotors) {
        motor.setPower(power);
    }
}
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:6,代码来源:Robot.java

示例5: setPowerAllWheels

import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
public final void setPowerAllWheels(double power) {
    for (DcMotor motor : getWheels()) {
        motor.setPower(power);
    }
}
 
开发者ID:FTC7729,项目名称:2016-FTC,代码行数:6,代码来源:Dutchess.java

示例6: stopWheelsAndSpinner

import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
public final void stopWheelsAndSpinner() {
    for (DcMotor motor : getWheelsAndSpinner()) {
        motor.setPower(0);
    }
}
 
开发者ID:FTC7729,项目名称:2016-FTC,代码行数:6,代码来源:Dutchess.java

示例7: runOpMode

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



        FrontRight= (DcMotor) hardwareMap.get("FrontRight");
        FrontLeft= (DcMotor) hardwareMap.get("FrontLeft");
        BackRight= (DcMotor) hardwareMap.get("BackRight");
        BackLeft= (DcMotor) hardwareMap.get("BackLeft");
        Beacon= (Servo) hardwareMap.get("Beacon");
        launcher=(DcMotor) hardwareMap.get("Launcher");
        bd= (Servo) hardwareMap.get("BD");
        ball= (DcMotor) hardwareMap.get("Ball");


        FrontRight.setDirection(DcMotorSimple.Direction.REVERSE);
        BackRight.setDirection(DcMotorSimple.Direction.REVERSE);
        waitForStart();

//Shooting two pre-loaded balls

        sleep(1000);

        launcher.setPower(1.0);

        sleep(1000);

        launcher.setPower(0.0);
        ball.setPower(-1.0);

        sleep(3000);
        ball.setPower(0.0);
        sleep(100);

        launcher.setPower(1.0);

        sleep(1000);

        launcher.setPower(0.0);

        sleep(200);
//Driving forward
        FrontRight.setPower(1.0);
        FrontLeft.setPower(1.0);
        BackRight.setPower(1.0);
        BackLeft.setPower(1.0);

        sleep(2300);



        FrontRight.setPower(0.0);
        FrontLeft.setPower(0.0);
        BackRight.setPower(0.0);
        BackLeft.setPower(0.0);



















    }
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:76,代码来源:StriaghtTest.java

示例8: runOpMode

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



    FrontRight= (DcMotor) hardwareMap.get("FrontRight");
    FrontLeft= (DcMotor) hardwareMap.get("FrontLeft");
    BackRight= (DcMotor) hardwareMap.get("BackRight");
    BackLeft= (DcMotor) hardwareMap.get("BackLeft");
    Beacon= (Servo) hardwareMap.get("Beacon");
    launcher=(DcMotor) hardwareMap.get("Launcher");
    bd= (Servo) hardwareMap.get("BD");


    FrontRight.setDirection(DcMotorSimple.Direction.REVERSE);
    BackRight.setDirection(DcMotorSimple.Direction.REVERSE);



    sleep(1000);

    launcher.setPower(1.0);

    sleep(1000);

    launcher.setPower(0.0);
    bd.setPosition(180d);
    sleep(1400);

    launcher.setPower(1.0);

    sleep(1000);

    launcher.setPower(0.0);

    sleep(100);

    FrontRight.setPower(1.0);
    FrontLeft.setPower(1.0);
    BackRight.setPower(1.0);
    BackLeft.setPower(1.0);

    sleep(2300);


    FrontRight.setPower(0.0);
    FrontLeft.setPower(0.0);
    BackRight.setPower(0.0);
    BackLeft.setPower(0.0);



















}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:70,代码来源:RedAllianceCapBall.java

示例9: runOpMode

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



    FrontRight= (DcMotor) hardwareMap.get("FrontRight");
    FrontLeft= (DcMotor) hardwareMap.get("FrontLeft");
    BackRight= (DcMotor) hardwareMap.get("BackRight");
    BackLeft= (DcMotor) hardwareMap.get("BackLeft");
    Beacon= (Servo) hardwareMap.get("Beacon");
    launcher=(DcMotor) hardwareMap.get("Launcher");
    bd= (Servo) hardwareMap.get("BD");


    FrontRight.setDirection(DcMotorSimple.Direction.REVERSE);
    BackRight.setDirection(DcMotorSimple.Direction.REVERSE);



    sleep(1000);

    launcher.setPower(1.0);

    sleep(1000);

    launcher.setPower(0.0);
    bd.setPosition(180d);
    sleep(1400);

    launcher.setPower(1.0);

    sleep(1000);

    launcher.setPower(0.0);

    sleep(100);

    FrontRight.setPower(1.0);
    FrontLeft.setPower(1.0);
    BackRight.setPower(1.0);
    BackLeft.setPower(1.0);

    sleep(2300);



    FrontRight.setPower(0.0);
    FrontLeft.setPower(0.0);
    BackRight.setPower(0.0);
    BackLeft.setPower(0.0);



















}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:71,代码来源:BlueAllianceCapBall.java

示例10: runOpMode

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



    FrontRight= (DcMotor) hardwareMap.get("FrontRight");
    FrontLeft= (DcMotor) hardwareMap.get("FrontLeft");
    BackRight= (DcMotor) hardwareMap.get("BackRight");
    BackLeft= (DcMotor) hardwareMap.get("BackLeft");
    Beacon= (Servo) hardwareMap.get("Beacon");
    launcher=(DcMotor) hardwareMap.get("Launcher");
    bd= (Servo) hardwareMap.get("BD");


    FrontRight.setDirection(DcMotorSimple.Direction.REVERSE);
    BackRight.setDirection(DcMotorSimple.Direction.REVERSE);



    sleep(1000);

    launcher.setPower(1.0);

    sleep(1000);

    launcher.setPower(0.0);
    bd.setPosition(180d);
    sleep(1400);

    launcher.setPower(1.0);

    sleep(1000);

    launcher.setPower(0.0);























}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:59,代码来源:BackupCode.java


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