Skip to content

Commit bd7e37c

Browse files
committed
opmodes
1 parent 360a1ff commit bd7e37c

File tree

5 files changed

+45
-26
lines changed

5 files changed

+45
-26
lines changed

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/OmegaTeleOp.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package org.firstinspires.ftc.teamcode.opmode;
22

3+
import com.acmerobotics.dashboard.config.Config;
34
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
5+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
46
import com.qualcomm.robotcore.hardware.DcMotor;
57
import com.qualcomm.robotcore.hardware.DcMotorSimple;
6-
8+
@TeleOp
9+
@Config
710
public class OmegaTeleOp extends LinearOpMode {
811
private DcMotor topLeftMotor;
912
private DcMotor topRightMotor;
1013
private DcMotor bottomLeftMotor;
1114
private DcMotor bottomRightMotor;
1215

13-
private DcMotor trumansArm = hardwareMap.get(DcMotor.class, "arm");
1416

1517
@Override
1618

@@ -21,6 +23,7 @@ public void runOpMode() throws InterruptedException {
2123
bottomRightMotor = hardwareMap.get(DcMotor.class,"BR");
2224
topLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
2325
bottomLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
26+
waitForStart();
2427
while (opModeIsActive()) {
2528
double y = -gamepad1.left_stick_y; // Y stick is reversed!
2629
double x = gamepad1.left_stick_x;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
11
package org.firstinspires.ftc.teamcode.opmode;
22
////this loop is for driving forward and backwards////
33

4+
import com.acmerobotics.dashboard.config.Config;
45
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
6+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
57
import com.qualcomm.robotcore.hardware.DcMotor;
68

9+
10+
@TeleOp
11+
@Config
712
public class PIDLOOP extends LinearOpMode {
13+
private double k1 = 0.01;
14+
private double k2 = -0.0002;
15+
private double k3 = 0.0;
16+
private double reference = 300;
17+
private double ierror = 0;
18+
private double diff = 0;
19+
private double prevError = 0;
820
public void runOpMode() throws InterruptedException {
21+
DcMotor topLeftMotor = hardwareMap.get(DcMotor.class, "FL");
22+
DcMotor topRightMotor = hardwareMap.get(DcMotor.class, "FR");
23+
DcMotor bottomLeftMotor = hardwareMap.get(DcMotor.class, "BL");
24+
DcMotor bottomRightMotor = hardwareMap.get(DcMotor.class, "BR");
25+
26+
topLeftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
27+
topLeftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
28+
29+
930

31+
waitForStart();
32+
while (opModeIsActive()) {
33+
telemetry.addData("ticks",topLeftMotor.getCurrentPosition());
34+
double error = reference - topLeftMotor.getCurrentPosition();
35+
ierror = ierror + error;
36+
diff = error - prevError;
37+
prevError = error;
38+
topLeftMotor.setPower(k1*error+k2*ierror+k3*diff);
39+
telemetry.update();
40+
}
1041
}
1142
}

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/THEONE.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ public void runOpMode() throws InterruptedException {
4141
while (opModeIsActive()) {
4242

4343
while (gamepad1.b) {
44-
45-
4644
// obtain the encoder position
4745
encoderPosition = Arm.getCurrentPosition();
4846
// calculate the error
@@ -54,7 +52,6 @@ public void runOpMode() throws InterruptedException {
5452
else if(power<-0.7){
5553
power = -0.7;
5654
}
57-
5855
Arm.setPower(power);
5956

6057
telemetry.addData("arm", encoderPosition);

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanPIDLOOOOOP.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@
44
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
55
import com.qualcomm.robotcore.hardware.DcMotor;
66

7-
87
//HATE.
98

109
// LET ME TELL YOU HOW MUCH I'VE COME TO HATE YOU SINCE I BEGAN TO LIVE.
1110

12-
// THERE ARE 387.44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX.
11+
// THERE ARE THREE HUNDRED POINT 44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX.
12+
13+
// IF THE WORD HATE,
14+
// WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE HUNDREDS OF MILLIONS OF MILES,
1315

14-
// IF THE WORD HATE WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE HUNDREDS OF MILLIONS OF MILES,
15-
// IT WOULD NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL FOR HUMANS AT THIS MICRO-INSTANT FOR YOU.
16+
// IT WOULD NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL FOR HUMANS AT THIS VERY MICRO-INSTANT FOR YOU.
1617

1718

1819
// HATE.
1920

2021
// HATE.
2122

2223

24+
25+
26+
2327
@Config
2428
@TeleOp
2529
public class TrumanPIDLOOOOOP extends LinearOpMode {
@@ -30,7 +34,6 @@ public class TrumanPIDLOOOOOP extends LinearOpMode {
3034
private double kI = 0.1;
3135
private double kP = 0.1;
3236
private double kD = 0.1;
33-
3437
private DcMotor trumansArm = hardwareMap.get(DcMotor.class, "arm");
3538

3639
public void runOpMode() throws InterruptedException {
@@ -42,8 +45,8 @@ public void runOpMode() throws InterruptedException {
4245
double prevError = error;
4346
error = reference - curPosition;
4447
double diff = error - prevError;
45-
trumansArm.setPower((kP * error) + (kI * error) + (kD * diff));
4648

49+
//trumansArm.setPower((kP * error) + (kI * error) + (kD * diff));
4750
}
4851
}
4952
}

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/tictacs.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)