Skip to content

Commit 2ae5b69

Browse files
committed
pid tuner and a bunch of stuff
pid tuner and a bunch of stuff
1 parent 66c58c1 commit 2ae5b69

File tree

10 files changed

+390
-22
lines changed

10 files changed

+390
-22
lines changed

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/config/testers/DemoTeleOp.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
44
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
55
import com.qualcomm.robotcore.hardware.DcMotor;
6+
import com.qualcomm.robotcore.hardware.DcMotorSimple;
7+
8+
import org.firstinspires.ftc.teamcode.config.utils.ButtonToggle;
69

710
@TeleOp
811
public class DemoTeleOp extends LinearOpMode {
@@ -19,20 +22,36 @@ public void runOpMode() throws InterruptedException {
1922
// If your robot moves backwards when commanded to go forwards,
2023
// reverse the left side instead.
2124
// See the note about this earlier on this page.
22-
//frontRightMotor.setDirection(DcMotorSimple.Direction.REVERSE);
23-
//backRightMotor.setDirection(DcMotorSimple.Direction.REVERSE);
24-
25+
frontLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
26+
backLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
27+
backRightMotor.setDirection(DcMotorSimple.Direction.REVERSE);
2528
waitForStart();
26-
29+
ButtonToggle a = new ButtonToggle();
30+
ButtonToggle b = new ButtonToggle();
2731
if (isStopRequested()) return;
2832

2933
while (opModeIsActive()) {
30-
double y = Math.pow(-gamepad1.left_stick_y,3); // Remember, Y stick value is reversed
31-
double x = Math.pow(gamepad1.left_stick_x * 1.1,3); // Counteract imperfect strafing
32-
double rx = Math.pow(gamepad1.right_stick_x,3);
34+
35+
if(a.isClicked(gamepad1.a)) {
36+
frontRightMotor.setDirection(DcMotorSimple.Direction.FORWARD);
37+
backRightMotor.setDirection(DcMotorSimple.Direction.FORWARD);
38+
frontLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
39+
backLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
40+
telemetry.addData("left reverse", 1);
41+
}
42+
if(b.isClicked(gamepad1.b)){
43+
frontRightMotor.setDirection(DcMotorSimple.Direction.REVERSE);
44+
backRightMotor.setDirection(DcMotorSimple.Direction.REVERSE);
45+
frontLeftMotor.setDirection(DcMotorSimple.Direction.FORWARD);
46+
backLeftMotor.setDirection(DcMotorSimple.Direction.FORWARD);
47+
telemetry.addData("right reverse", 2);
48+
}
49+
double y = -gamepad1.left_stick_y; // Remember, Y stick value is reversed
50+
double x = gamepad1.left_stick_x * 1.1; // Counteract imperfect strafing
51+
double rx = gamepad1.right_stick_x;
3352

3453
// Denominator is the largest motor power (absolute value) or 1
35-
// This ensures all the powers maintain the same ratio,x
54+
// This ensures all the powers maintain the same ratio,
3655
// but only if at least one is out of the range [-1, 1]
3756
double denominator = Math.max(Math.abs(y) + Math.abs(x) + Math.abs(rx), 1);
3857
double frontLeftPower = (y + x + rx) / denominator;
@@ -44,6 +63,8 @@ public void runOpMode() throws InterruptedException {
4463
backLeftMotor.setPower(backLeftPower);
4564
frontRightMotor.setPower(frontRightPower);
4665
backRightMotor.setPower(backRightPower);
66+
67+
telemetry.update();
4768
}
4869
}
4970
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.firstinspires.ftc.teamcode.config.testers;
2+
3+
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
4+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
5+
import com.qualcomm.robotcore.hardware.Servo;
6+
7+
@TeleOp(group="Test")
8+
public class ServoTesters extends OpMode {
9+
Servo leftArm;
10+
Servo rightArm;
11+
12+
Servo leftClaw;
13+
Servo rightClaw;
14+
15+
@Override
16+
public void init() {
17+
// Initialize the servos using hardwareMap and ensure they are named correctly in your configuration file
18+
leftArm = hardwareMap.get(Servo.class, "leftArm");
19+
rightArm = hardwareMap.get(Servo.class, "rightArm");
20+
21+
leftClaw = hardwareMap.get(Servo.class, "leftClaw");
22+
rightClaw = hardwareMap.get(Servo.class, "rightClaw");
23+
24+
25+
}
26+
27+
@Override
28+
public void loop() {
29+
// Use the gamepad to control the servos for testing
30+
// Left joystick controls arms
31+
double armPosition = (gamepad1.left_stick_y + 1) / 2; // Normalize joystick value to 0-1 range
32+
leftArm.setPosition(armPosition); // Direct movement
33+
rightArm.setPosition(1 - armPosition);
34+
35+
// Right joystick controls claws
36+
double clawPosition = (gamepad1.right_stick_y + 1) / 2; // Normalize joystick value to 0-1 range
37+
leftClaw.setPosition(clawPosition); // Direct movement
38+
rightClaw.setPosition(1 - clawPosition); // Reverse movement
39+
40+
// Display positions on telemetry for debugging
41+
telemetry.addData("Arm Positions", "Left: %.2f, Right: %.2f", armPosition, 1 - armPosition);
42+
telemetry.addData("Claw Positions", "Left: %.2f, Right: %.2f", clawPosition, 1 - clawPosition);
43+
telemetry.update();
44+
}
45+
}

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/follower/Follower.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public void initialize() {
171171
// TODO: Make sure that this is the direction your motors need to be reversed in.
172172
leftFront.setDirection(DcMotorSimple.Direction.REVERSE);
173173
leftRear.setDirection(DcMotorSimple.Direction.REVERSE);
174+
rightRear.setDirection(DcMotorSimple.Direction.REVERSE);
174175

175176
motors = Arrays.asList(leftFront, leftRear, rightFront, rightRear);
176177

0 commit comments

Comments
 (0)