9
9
import com .qualcomm .robotcore .hardware .Servo ;
10
10
import com .qualcomm .robotcore .util .ElapsedTime ;
11
11
import com .qualcomm .robotcore .util .Range ;
12
+ import com .qualcomm .robotcore .hardware .Gamepad ;
12
13
13
14
14
15
/*
@@ -56,32 +57,38 @@ public void runOpMode() {
56
57
57
58
// run until the end of the match (driver presses STOP)
58
59
while (opModeIsActive ()) {
60
+ intake (gamepad2 );
61
+ }
59
62
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
+ }
75
64
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
+ }
76
83
77
84
85
+ intakeMotor .setPower (power );
78
86
79
87
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 ();
86
93
}
87
94
}
0 commit comments