From d68e091420808baab3edf3997a1d517410ad2878 Mon Sep 17 00:00:00 2001 From: Absozero Date: Mon, 11 Sep 2023 02:33:50 -0700 Subject: [PATCH] feat: Implemented drivetrain control, translated - Code to control the intakes, catapult, drivetrain, and the elevation have been translated in this commit. - The drivetrain code is not working properly at this point. --- README.md | 6 ++++-- TASKS.md | 0 src/main.cpp | 48 +++++++++++++++++++++++++++++++++++++----------- 3 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 TASKS.md diff --git a/README.md b/README.md index f400e5e..8b54f4f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # PROS Version - +== This is the PROS version of the robot, rewritten from the VexCode version. This was done so that we could support a greater feature set and support external libraries. The PROS version will be first rewritten from the VEXCode version and then it will have features added onto it. It is not expected to become production ready as soon as it is complete. -To see the vexcode version, go [here](https://github.com/calhighrobotics/Over-Under-2023-24-teamB) \ No newline at end of file +To see the vexcode version, go [here](https://github.com/calhighrobotics/Over-Under-2023-24-teamB) + + diff --git a/TASKS.md b/TASKS.md new file mode 100644 index 0000000..e69de29 diff --git a/src/main.cpp b/src/main.cpp index 41c32de..9588814 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,13 +75,13 @@ void autonomous() {} */ void opcontrol() { pros::Controller controller (pros::E_CONTROLLER_MASTER); - pros::Motor RightFront (1, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); - pros::Motor LeftFront (2, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); + pros::Motor RightFront (2, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); + pros::Motor LeftFront (1, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); pros::Motor LeftBack (3, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); pros::Motor RightBack (4, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); pros::Motor LeftMid (10, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); pros::Motor Elevation (20, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); - pros::Motor RightMid (6, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); + pros::Motor RightMid (9, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); pros::Motor Catapult (7, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); pros::Motor IntakeLeft (8, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); pros::Motor IntakeRight (9, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES); @@ -89,19 +89,14 @@ void opcontrol() { while (true) { // Read joystick values - int power = controller.get_analog(ANALOG_LEFT_Y); - int turn = controller.get_analog(ANALOG_RIGHT_X); + int power = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y); + int turn = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_X); int left = power + turn; int right = power - turn; - while (true) - { - controller.print(0, 0, power); - controller.print(1, 0, turn); - } - + // EXPERIMENTAL DRIVETRAIN CODE - Not Working currently. RightFront.move(right); RightMid.move(right); RightBack.move(right); @@ -109,10 +104,41 @@ void opcontrol() { LeftFront.move(left); LeftMid.move(left); LeftBack.move(left); + + // Controls Catapult movement - uses A button to cock the catapult back, the Y button to release tension. + if (controller.get_digital(DIGITAL_A)) { + Catapult.move(127); + } + else if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_Y)) { + Catapult.move(-127); + } + else { + Catapult.brake(); + } + // Catapult controller, uses the X button holded down to push the elevation up. + if (controller.get_digital(DIGITAL_X)) { + Elevation.move(127); + } + else { + Elevation.brake(); + } + + // Intake controller, moves the left and right intakes and stops them if nothing is pressed. + if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_B)) { + IntakeRight.move(127); + IntakeLeft.move(127); + } + else { + IntakeRight.brake(); + IntakeLeft.brake(); + } + pros::delay(2); // Small delay to reduce CPU usage } + + }