Skip to content

Commit 56cc7d8

Browse files
committed
yippie!
1 parent e6d37df commit 56cc7d8

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed
Binary file not shown.

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/teleOp/drive.java

+28-21
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.qualcomm.robotcore.hardware.Servo;
1010
import com.qualcomm.robotcore.util.ElapsedTime;
1111
import com.qualcomm.robotcore.util.Range;
12+
import com.qualcomm.robotcore.hardware.Gamepad;
1213

1314

1415
/*
@@ -56,32 +57,38 @@ public void runOpMode() {
5657

5758
// run until the end of the match (driver presses STOP)
5859
while (opModeIsActive()) {
60+
intake(gamepad2);
61+
}
5962

60-
// POV Mode uses left stick to go forward, and right stick to turn.
61-
// - This uses basic math to combine motions and is easier to drive straight.
62-
double power = 0;
63-
double position = intakeMotor.getCurrentPosition();
64-
// Send calculated power to wheels
65-
//Max is 4200m min is 0
66-
67-
if(position >= 4200){
68-
power = Range.clip(-gamepad1.left_stick_y, -1.0, 0);
69-
} else if(position <= 0){
70-
power = Range.clip(-gamepad1.left_stick_y, 0, 1.0);
71-
} else{
72-
power = Range.clip(-gamepad1.left_stick_y, -1.0, 1.0);
73-
}
74-
intakeMotor.setPower(power);
63+
}
7564

65+
public void intake(Gamepad gp){
66+
double power = 0;
67+
double position = intakeMotor.getCurrentPosition();
68+
// Send calculated power to wheels
69+
//Max is 4200m min is 0
70+
71+
// 3000 to be incredibly conservative, 4200 is a more realistic limit but we never have to extend that far anyways
72+
int intakeMaxPosition = 3000;
73+
// 100 is a very good limit, limit of zero causes "jitters" on the way back down quickly
74+
int intakeMinPosition = 100;
75+
76+
if(position >= intakeMaxPosition){
77+
power = Range.clip(-gp.left_stick_y, -1.0, 0);
78+
} else if(position <= intakeMinPosition){
79+
power = Range.clip(-gp.left_stick_y, 0, 1.0);
80+
} else{
81+
power = Range.clip(-gp.left_stick_y, -1.0, 1.0);
82+
}
7683

7784

85+
intakeMotor.setPower(power);
7886

7987

80-
// Show the elapsed game time and wheel power.
81-
telemetry.addData("Status", "Run Time: " + runtime.toString());
82-
telemetry.addData("Motors", "power (%.2f)", power);
83-
telemetry.addData("Motors", "position (%.2f)", position);
84-
telemetry.update();
85-
}
88+
// Show the elapsed game time and wheel power.
89+
telemetry.addData("Status", "Run Time: " + runtime.toString());
90+
telemetry.addData("Motors", "power (%.2f)", power);
91+
telemetry.addData("Motors", "position (%.2f)", position);
92+
telemetry.update();
8693
}
8794
}

0 commit comments

Comments
 (0)