Add code for moving intake
This commit is contained in:
parent
02528c6d94
commit
b565bdd4b4
|
@ -106,7 +106,7 @@ public class API {
|
|||
* Stops the motor and sets the power to 0
|
||||
*/
|
||||
public void stop() {
|
||||
start(0);
|
||||
rawMotor.setPower(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +129,7 @@ public class API {
|
|||
|
||||
public void setDirection(Direction direction, boolean immediate) {
|
||||
this.direction = direction;
|
||||
if (immediate) start(this.power);
|
||||
if (immediate) start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,15 +9,13 @@ public class BasicOpMode extends LinearOpMode {
|
|||
@Override
|
||||
public void runOpMode() {
|
||||
API.init(this);
|
||||
API.Motor m6 = API.Motor.M6;
|
||||
m6.setDirection(API.Direction.REVERSE);
|
||||
API.Servo s3 = API.Servo.S3;
|
||||
API.Motor motor = API.Motor.M0;
|
||||
motor.setDirection(API.Direction.REVERSE);
|
||||
|
||||
waitForStart();
|
||||
|
||||
while(opModeIsActive()) {
|
||||
m6.start(1);
|
||||
s3.start(1);
|
||||
motor.start(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
|||
@TeleOp(name="Gamepad 1.0 IMU 1.0")
|
||||
public class Gamepad extends OpMode {
|
||||
private double speed = 1;
|
||||
private double prevSpeed = 1;
|
||||
private double imuOut = 0;
|
||||
private API.Motor intake = API.Motor.M4;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
@ -24,6 +26,7 @@ public class Gamepad extends OpMode {
|
|||
public void start() {
|
||||
API.clear();
|
||||
API.imu.reset();
|
||||
intake.setPower(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,17 +38,24 @@ public class Gamepad extends OpMode {
|
|||
if (gamepad1.y && gamepad1.right_stick_x == 0) turn = imuOut/180;
|
||||
else API.imu.reset();
|
||||
|
||||
MovementAPI.move(-gamepad1.left_stick_y, gamepad1.left_stick_x, turn, speed, true);
|
||||
MovementAPI.move(-gamepad1.left_stick_y, gamepad1.left_stick_x, turn, speed, false);
|
||||
|
||||
API.print(
|
||||
"Speed: " + speed + System.lineSeparator() +
|
||||
"Rotation (degrees, IMU): " + imuOut + System.lineSeparator() +
|
||||
"IMU Active: " + !gamepad1.y
|
||||
);
|
||||
|
||||
|
||||
if (gamepad1.right_bumper) speed = Math.min(speed+0.01, 1);
|
||||
else if (gamepad1.left_bumper) speed = Math.max(speed-0.01, 0.2);
|
||||
else if (gamepad1.x) speed = 0.35;
|
||||
|
||||
if (gamepad1.a) {
|
||||
intake.setDirection(API.Direction.REVERSE, true);
|
||||
} else if (gamepad1.b) {
|
||||
intake.setDirection(API.Direction.FORWARD, true);
|
||||
} else {
|
||||
intake.stop();
|
||||
}
|
||||
|
||||
ms-=System.currentTimeMillis();
|
||||
if (ms>5) try {
|
||||
|
|
Loading…
Reference in a new issue