Skip to content

Commit 2481be2

Browse files
Merge remote-tracking branch 'origin/Train' into Train
# Conflicts: # TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/THEONE.java
2 parents bb96ba9 + 7a4a37c commit 2481be2

File tree

8 files changed

+284
-30
lines changed

8 files changed

+284
-30
lines changed

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

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.firstinspires.ftc.teamcode.opmode;
2+
3+
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
4+
import com.qualcomm.robotcore.hardware.DcMotor;
5+
import com.qualcomm.robotcore.hardware.DcMotorSimple;
6+
7+
public class OmegaTeleOp extends LinearOpMode {
8+
private DcMotor topLeftMotor;
9+
private DcMotor topRightMotor;
10+
private DcMotor bottomLeftMotor;
11+
private DcMotor bottomRightMotor;
12+
13+
private DcMotor trumansArm = hardwareMap.get(DcMotor.class, "arm");
14+
15+
@Override
16+
17+
public void runOpMode() throws InterruptedException {
18+
topLeftMotor = hardwareMap.get(DcMotor.class,"FL");
19+
topRightMotor = hardwareMap.get(DcMotor.class,"FR");
20+
bottomLeftMotor = hardwareMap.get(DcMotor.class,"BL");
21+
bottomRightMotor = hardwareMap.get(DcMotor.class,"BR");
22+
topLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
23+
bottomLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
24+
while (opModeIsActive()) {
25+
double y = -gamepad1.left_stick_y; // Y stick is reversed!
26+
double x = gamepad1.left_stick_x;
27+
double rx2 = gamepad1.right_stick_x;
28+
29+
topLeftMotor.setPower(y + x + rx2);
30+
bottomLeftMotor.setPower(y - x + rx2);
31+
topRightMotor.setPower(y - x - rx2);
32+
bottomRightMotor.setPower(y + x - rx2);
33+
}
34+
}
35+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.firstinspires.ftc.teamcode.opmode;
2+
////this loop is for driving forward and backwards////
3+
4+
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
5+
import com.qualcomm.robotcore.hardware.DcMotor;
6+
7+
public class PIDLOOP extends LinearOpMode {
8+
public void runOpMode() throws InterruptedException {
9+
10+
}
11+
}

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

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.acmerobotics.dashboard.config.Config;
44
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
55
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
6+
import com.qualcomm.robotcore.hardware.CRServo;
67
import com.qualcomm.robotcore.hardware.DcMotor;
78
import com.qualcomm.robotcore.hardware.DcMotorSimple;
89

@@ -14,47 +15,74 @@ public class PatrickTeleOP extends LinearOpMode {
1415
private DcMotor front_right;
1516
private DcMotor back_left;
1617
private DcMotor back_right;
18+
private DcMotor arm;
19+
double reference;
20+
1721

1822
@Override
1923
public void runOpMode() throws InterruptedException {
2024
waitForStart();
21-
front_left = hardwareMap.get(DcMotor.class, "left_front_left_dw");
22-
front_right = hardwareMap.get(DcMotor.class, "right_front");
23-
back_left = hardwareMap.get(DcMotor.class, "left_back");
24-
back_right = hardwareMap.get(DcMotor.class, "right_back_right_dw");
25+
front_left = hardwareMap.get(DcMotor.class, "front_left");
26+
front_right = hardwareMap.get(DcMotor.class, "front_right");
27+
back_left = hardwareMap.get(DcMotor.class, "back_right");
28+
back_right = hardwareMap.get(DcMotor.class, "back_right");
29+
arm = hardwareMap.get(DcMotor.class, "arm");
30+
double encoderPosition;
31+
waitForStart();
32+
double error;
33+
error = 1.1;
34+
double power = 0;
35+
2536

2637
while (opModeIsActive()) {
2738
front_left.setDirection(DcMotorSimple.Direction.REVERSE);
2839
back_left.setDirection(DcMotorSimple.Direction.REVERSE);
29-
if (gamepad1.left_stick_y > 0.3) {
30-
front_left.setPower(1);
31-
front_right.setPower(1);
32-
back_left.setPower(1);
33-
back_right.setPower(1);
34-
}
35-
if (gamepad1.left_stick_x < 0.3) {
36-
front_left.setPower(0);
37-
front_right.setPower(0);
38-
back_right.setPower(0);
39-
back_left.setPower(0);
40-
}
40+
double y = -gamepad1.left_stick_y; // Remember, Y stick is reversed!
41+
double x = gamepad1.left_stick_x;
42+
double rx = gamepad1.right_stick_x;
43+
44+
front_left.setPower(y + x + rx);
45+
back_left.setPower(y - x + rx);
46+
front_right.setPower(y - x - rx);
47+
back_right.setPower(y + x - rx);
4148
if (gamepad1.left_bumper) {
4249
front_left.setPower(1);
4350
back_left.setPower(1);
44-
}
45-
else {
51+
} else {
4652
front_left.setPower(0);
4753
back_left.setPower(0);
4854
}
4955
if (gamepad1.right_bumper) {
5056
front_right.setPower(1);
5157
back_right.setPower(1);
52-
}
53-
else {
58+
} else {
5459
front_right.setPower(0);
5560
back_right.setPower(0);
5661
}
62+
reference = 300;
63+
arm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
64+
arm.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
65+
66+
while (gamepad1.b) {
67+
68+
encoderPosition = arm.getCurrentPosition();
69+
error = reference - encoderPosition;
70+
power = (error / 250) * .7;
71+
if (power > 0.7) {
72+
power = 0.7;
73+
} else if (power < -0.7) {
74+
power = -0.7;
75+
}
76+
77+
arm.setPower(power);
78+
79+
telemetry.addData("arm", encoderPosition);
80+
telemetry.addData("error", error);
81+
telemetry.addData("stick", gamepad2.left_stick_y);
82+
telemetry.addData("power", power);
83+
telemetry.update();
5784
}
5885
}
5986
}
87+
}
6088

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.firstinspires.ftc.teamcode.opmode;
2+
import com.acmerobotics.dashboard.config.Config;
3+
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
4+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
5+
import com.qualcomm.robotcore.hardware.DcMotor;
6+
7+
8+
//HATE.
9+
10+
// LET ME TELL YOU HOW MUCH I'VE COME TO HATE YOU SINCE I BEGAN TO LIVE.
11+
12+
// THERE ARE 387.44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX.
13+
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+
17+
18+
// HATE.
19+
20+
// HATE.
21+
22+
23+
@Config
24+
@TeleOp
25+
public class TrumanPIDLOOOOOP extends LinearOpMode {
26+
private double reference = 250;
27+
private double error = 0;
28+
private double power = 0;
29+
private double MAXPOWER = 0.5;
30+
private double kI = 0.1;
31+
private double kP = 0.1;
32+
private double kD = 0.1;
33+
34+
private DcMotor trumansArm = hardwareMap.get(DcMotor.class, "arm");
35+
36+
public void runOpMode() throws InterruptedException {
37+
trumansArm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
38+
trumansArm.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
39+
while (opModeIsActive()) {
40+
while (gamepad1.a) {
41+
double curPosition = trumansArm.getCurrentPosition();
42+
double prevError = error;
43+
error = reference - curPosition;
44+
double diff = error - prevError;
45+
trumansArm.setPower((kP * error) + (kI * error) + (kD * diff));
46+
47+
}
48+
}
49+
}
50+
}

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanLearnsTeleOP.java renamed to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumansSkibidiDriveModes.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
import org.firstinspires.ftc.teamcode.util.Toggle;
1111

1212
@TeleOp
13-
public class TrumanLearnsTeleOP extends LinearOpMode {
14-
13+
public class TrumansSkibidiDriveModes extends LinearOpMode {
1514
private DcMotor topLeftMotor;
1615
private DcMotor topRightMotor;
1716
private DcMotor bottomLeftMotor;
@@ -25,7 +24,7 @@ public void runOpMode() throws InterruptedException {
2524
double rx;
2625
double ry;
2726
boolean leftBumper;
28-
boolean rightBumper; //why? just use if statements
27+
boolean rightBumper; //why? just use if statements /////why not.....
2928
topLeftMotor = hardwareMap.get(DcMotor.class,"FL");
3029
topRightMotor = hardwareMap.get(DcMotor.class,"FR");
3130
bottomLeftMotor = hardwareMap.get(DcMotor.class,"BL");
@@ -68,18 +67,19 @@ public void runOpMode() throws InterruptedException {
6867
telemetry.update();
6968
}
7069
else{
71-
double y = -gamepad1.left_stick_y; // Remember, Y stick is reversed!
70+
double y = -gamepad1.left_stick_y; // Y stick is reversed!
7271
double x = gamepad1.left_stick_x;
7372
double rx2 = gamepad1.right_stick_x;
7473

7574
topLeftMotor.setPower(y+ x + rx2);
7675
bottomLeftMotor.setPower(y - x + rx2);
7776
topRightMotor.setPower(y - x - rx2);
7877
bottomRightMotor.setPower(y + x - rx2);
78+
// remember kids plagiarism is wrong
7979
}
8080

81-
//while(!check){
82-
//put the other stuff that isn't t-bar steering here
81+
// while(!check){
82+
// put the other stuff that isn't t-bar steering here
8383
}
8484
}
8585
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.firstinspires.ftc.teamcode.opmode;
2+
import com.acmerobotics.dashboard.config.Config;
3+
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
4+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
5+
import com.qualcomm.robotcore.hardware.DcMotor;
6+
7+
8+
9+
@Config
10+
@TeleOp
11+
public class nickpidloop extends LinearOpMode {
12+
private double reference = 250;
13+
private double error = 0;
14+
private double power = 0;
15+
private double maxpower = 0.5;
16+
private double kI = 0.1;
17+
private double kP = 0.1;
18+
private double kD = 0.1;
19+
20+
private DcMotor arm = hardwareMap.get(DcMotor.class, "arm");
21+
22+
public void runOpMode() throws InterruptedException {
23+
arm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
24+
arm.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
25+
while (opModeIsActive()) {
26+
while (gamepad1.a) {
27+
//for encoder position
28+
double curPosition = arm.getCurrentPosition();
29+
//the other error + current error
30+
double prevError = error;
31+
//other poop that i don't understand yes
32+
// todo learn the stuff under here
33+
error = reference - curPosition;
34+
double diff = error - prevError;
35+
arm.setPower((kP * error) + (kI * error) + (kD * diff));
36+
37+
}
38+
}
39+
}
40+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package org.firstinspires.ftc.teamcode.opmode;
2+
3+
import com.acmerobotics.dashboard.config.Config;
4+
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
5+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
6+
import com.qualcomm.robotcore.hardware.DcMotor;
7+
import com.qualcomm.robotcore.hardware.DcMotorSimple;
8+
9+
@Config
10+
@TeleOp
11+
public class workingpidloop18284 extends LinearOpMode {
12+
13+
14+
private DcMotor leftFrontMotor;
15+
private DcMotor rightFrontMotor;
16+
private DcMotor leftBackMotor;
17+
private DcMotor rightBackMotor;
18+
private DcMotor Arm;
19+
double reference;
20+
21+
@Override
22+
public void runOpMode() throws InterruptedException {
23+
24+
leftFrontMotor = hardwareMap.get(DcMotor.class, "front_left");
25+
rightFrontMotor = hardwareMap.get(DcMotor.class, "front_right");
26+
leftBackMotor = hardwareMap.get(DcMotor.class, "back_left");
27+
rightBackMotor = hardwareMap.get(DcMotor.class, "back_right");
28+
Arm = hardwareMap.get(DcMotor.class, "arm");
29+
double encoderPosition;
30+
waitForStart();
31+
double error;
32+
error = 1.1;
33+
double power = 0;
34+
35+
36+
reference = 300;
37+
Arm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
38+
Arm.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
39+
40+
while (opModeIsActive()) {
41+
42+
while (gamepad1.b) {
43+
44+
45+
// obtain the encoder position
46+
encoderPosition = Arm.getCurrentPosition();
47+
// calculate the error
48+
error = reference - encoderPosition;
49+
power = (error/250)*.7;
50+
if(power>0.7){
51+
power = 0.7;
52+
}
53+
else if(power<-0.7){
54+
power = -0.7;
55+
}
56+
57+
Arm.setPower(power);
58+
59+
telemetry.addData("arm", encoderPosition);
60+
telemetry.addData("error", error);
61+
telemetry.addData("stick", gamepad2.left_stick_y);
62+
telemetry.addData("power", power);
63+
telemetry.update();
64+
65+
66+
}
67+
Arm.setPower(0);
68+
leftFrontMotor.setDirection(DcMotorSimple.Direction.REVERSE);
69+
leftBackMotor.setDirection(DcMotorSimple.Direction.REVERSE);
70+
double y = -gamepad1.left_stick_y; // Remember, Y stick is reversed!
71+
double x = gamepad1.left_stick_x;
72+
double rx = gamepad1.right_stick_x;
73+
74+
leftFrontMotor.setPower(y + x + rx);
75+
leftBackMotor.setPower(y - x + rx);
76+
rightFrontMotor.setPower(y - x - rx);
77+
rightBackMotor.setPower(y + x - rx);
78+
79+
//oops i didn't push right :P
80+
}
81+
}
82+
}
83+
84+
85+
//3 hours for 1 bracket... always remember to click code->reformat code
86+
87+
88+
89+
90+
91+
92+
93+
94+

0 commit comments

Comments
 (0)