Skip to content

Commit

Permalink
opmodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ieatred40 committed Nov 21, 2024
1 parent 360a1ff commit bd7e37c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.firstinspires.ftc.teamcode.opmode;

import com.acmerobotics.dashboard.config.Config;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;

@TeleOp
@Config
public class OmegaTeleOp extends LinearOpMode {
private DcMotor topLeftMotor;
private DcMotor topRightMotor;
private DcMotor bottomLeftMotor;
private DcMotor bottomRightMotor;

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

@Override

Expand All @@ -21,6 +23,7 @@ public void runOpMode() throws InterruptedException {
bottomRightMotor = hardwareMap.get(DcMotor.class,"BR");
topLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
bottomLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
waitForStart();
while (opModeIsActive()) {
double y = -gamepad1.left_stick_y; // Y stick is reversed!
double x = gamepad1.left_stick_x;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
package org.firstinspires.ftc.teamcode.opmode;
////this loop is for driving forward and backwards////

import com.acmerobotics.dashboard.config.Config;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;


@TeleOp
@Config
public class PIDLOOP extends LinearOpMode {
private double k1 = 0.01;
private double k2 = -0.0002;
private double k3 = 0.0;
private double reference = 300;
private double ierror = 0;
private double diff = 0;
private double prevError = 0;
public void runOpMode() throws InterruptedException {
DcMotor topLeftMotor = hardwareMap.get(DcMotor.class, "FL");
DcMotor topRightMotor = hardwareMap.get(DcMotor.class, "FR");
DcMotor bottomLeftMotor = hardwareMap.get(DcMotor.class, "BL");
DcMotor bottomRightMotor = hardwareMap.get(DcMotor.class, "BR");

topLeftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
topLeftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);



waitForStart();
while (opModeIsActive()) {
telemetry.addData("ticks",topLeftMotor.getCurrentPosition());
double error = reference - topLeftMotor.getCurrentPosition();
ierror = ierror + error;
diff = error - prevError;
prevError = error;
topLeftMotor.setPower(k1*error+k2*ierror+k3*diff);
telemetry.update();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public void runOpMode() throws InterruptedException {
while (opModeIsActive()) {

while (gamepad1.b) {


// obtain the encoder position
encoderPosition = Arm.getCurrentPosition();
// calculate the error
Expand All @@ -54,7 +52,6 @@ public void runOpMode() throws InterruptedException {
else if(power<-0.7){
power = -0.7;
}

Arm.setPower(power);

telemetry.addData("arm", encoderPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;


//HATE.

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

// THERE ARE 387.44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX.
// THERE ARE THREE HUNDRED POINT 44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX.

// IF THE WORD HATE,
// WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE HUNDREDS OF MILLIONS OF MILES,

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


// HATE.

// HATE.





@Config
@TeleOp
public class TrumanPIDLOOOOOP extends LinearOpMode {
Expand All @@ -30,7 +34,6 @@ public class TrumanPIDLOOOOOP extends LinearOpMode {
private double kI = 0.1;
private double kP = 0.1;
private double kD = 0.1;

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

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

//trumansArm.setPower((kP * error) + (kI * error) + (kD * diff));
}
}
}
Expand Down

This file was deleted.

0 comments on commit bd7e37c

Please sign in to comment.