本文整理汇总了Java中com.qualcomm.robotcore.hardware.DcMotor.setDirection方法的典型用法代码示例。如果您正苦于以下问题:Java DcMotor.setDirection方法的具体用法?Java DcMotor.setDirection怎么用?Java DcMotor.setDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.qualcomm.robotcore.hardware.DcMotor
的用法示例。
在下文中一共展示了DcMotor.setDirection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: DriveTrain
import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
public DriveTrain(ExtensibleGamepad controlGamepad, DcMotor leftFront, DcMotor rightFront, DcMotor leftRear, DcMotor rightRear) {
this.leftFront = leftFront;
this.rightFront = rightFront;
this.leftRear = leftRear;
this.rightRear = rightRear;
rightFront.setDirection(DcMotorSimple.Direction.REVERSE);
rightRear.setDirection(DcMotorSimple.Direction.REVERSE);
leftFront.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
rightFront.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
leftFront.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
rightFront.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
this.controlGamepad = controlGamepad;
//this.drive = drive;
disableMap = new double[4];
for (int i = 0; i < disableMap.length; i++) {
disableMap[i] = 1;
}
}
示例3: 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);
}
示例4: dcMotorInit
import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
/**
* Initialize a dcMotor by setting parameters and checking that they were set properly
*
* @param dcMotor the motor to initialize
* @param reversed whether or not the motor direction should be reversed
* @param brake whether to brake or float when stopping
* @param runMode what mode to start the motor in
*/
private static void dcMotorInit(DcMotor dcMotor, boolean reversed, boolean brake, DcMotor.RunMode runMode) {
//reset the encoder position to zero
do {
dcMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
} while (dcMotor.getMode() != DcMotor.RunMode.STOP_AND_RESET_ENCODER);
//determine the motor's direction as a Direction object
DcMotor.Direction direction;
if (reversed) {
direction = DcMotorSimple.Direction.REVERSE;
} else {
direction = DcMotorSimple.Direction.FORWARD;
}
//set the motor's direction
do {
dcMotor.setDirection(direction);
} while (dcMotor.getDirection() != direction);
//set the motor's mode
do {
dcMotor.setMode(runMode);
} while (dcMotor.getMode() != runMode);
//determine the ZeroPowerBehavior
DcMotor.ZeroPowerBehavior zeroPowerBehavior;
if (brake) {
zeroPowerBehavior = DcMotor.ZeroPowerBehavior.BRAKE;
} else {
zeroPowerBehavior = DcMotor.ZeroPowerBehavior.FLOAT;
}
//set the motor's ZeroPowerBehavior
do {
dcMotor.setZeroPowerBehavior(zeroPowerBehavior);
} while (dcMotor.getZeroPowerBehavior() != zeroPowerBehavior);
}
示例5: 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);
}
示例6: 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);
}
示例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");
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);
}
示例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);
}