本文整理汇总了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);
}
示例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);
}
示例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);
}
示例4: setDriveMotorPower
import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
public void setDriveMotorPower(double power) {
for (DcMotor motor : driveMotors) {
motor.setPower(power);
}
}
示例5: setPowerAllWheels
import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
public final void setPowerAllWheels(double power) {
for (DcMotor motor : getWheels()) {
motor.setPower(power);
}
}
示例6: stopWheelsAndSpinner
import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
public final void stopWheelsAndSpinner() {
for (DcMotor motor : getWheelsAndSpinner()) {
motor.setPower(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");
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);
}
示例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);
}
示例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);
}
示例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);
}