From cc2e38062d10ac8a8e1fd2cda73855b8ca94f50d Mon Sep 17 00:00:00 2001 From: ary Date: Fri, 17 Nov 2023 08:26:48 -0500 Subject: [PATCH] a motorized intake --- HVN-ON-EARTH/include/globals.hpp | 4 +- HVN-ON-EARTH/include/superstructure.hpp | 7 +-- HVN-ON-EARTH/src/globals.cpp | 4 +- HVN-ON-EARTH/src/superstructure.cpp | 61 ++++++++++++------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/HVN-ON-EARTH/include/globals.hpp b/HVN-ON-EARTH/include/globals.hpp index d1ee514..1de948b 100644 --- a/HVN-ON-EARTH/include/globals.hpp +++ b/HVN-ON-EARTH/include/globals.hpp @@ -57,8 +57,8 @@ namespace globals { extern Drive chassis; - extern pros::Motor& cata_left; - extern pros::Motor& cata_right; + extern pros::Motor& intake_mtr; + extern pros::Motor& cata_mtr; enum e_controlsch { RENU, diff --git a/HVN-ON-EARTH/include/superstructure.hpp b/HVN-ON-EARTH/include/superstructure.hpp index 3ec68d1..45fe915 100644 --- a/HVN-ON-EARTH/include/superstructure.hpp +++ b/HVN-ON-EARTH/include/superstructure.hpp @@ -7,7 +7,8 @@ // Renu's control preferences #define RENU_PTO_TOGGLE DIGITAL_R2 #define RENU_CATA_CONTROL DIGITAL_R1 -#define RENU_INTAKE_CONTROL DIGITAL_L1 +#define RENU_INTAKE_CONTROL_INTAKE DIGITAL_L1 +#define RENU_INTAKE_CONTROL_OUTTAKE DIGITAL_B #define RENU_LEFT_WING_CONTROL DIGITAL_LEFT #define RENU_RIGHT_WING_CONTROL DIGITAL_RIGHT #define RENU_WING_CONTROL DIGITAL_L2 @@ -50,11 +51,11 @@ namespace superstruct { void setSwingScale(double val); //- Structure methods - void intakeControl(pros::controller_digital_e_t intakeButton); + //void intakeControl(pros::controller_digital_e_t intakeButton); void togglePto(bool toggle); void runCata(double inpt); void runAntiBlock(double inpt); - void subsysControl(pros::controller_digital_e_t ptoToggleButton, pros::controller_digital_e_t cataRunButton); + void subsysControl(pros::controller_digital_e_t ptoToggleButton, pros::controller_digital_e_t cataRunButton, pros::controller_digital_e_t intakeButton, pros::controller_digital_e_t outtakeButton); void wingsControl(); void wingsControlSingle(pros::controller_digital_e_t wingControlButton); void wingsControlComplex(pros::controller_analog_e_t leftWingButton, pros::controller_analog_e_t rightWingButton, pros::controller_analog_e_t wingButton); diff --git a/HVN-ON-EARTH/src/globals.cpp b/HVN-ON-EARTH/src/globals.cpp index 9257dda..81bc38b 100644 --- a/HVN-ON-EARTH/src/globals.cpp +++ b/HVN-ON-EARTH/src/globals.cpp @@ -91,6 +91,6 @@ namespace globals { lemlib::Chassis chassis_odom(dt_odom, latController, angController, chassis_sensors); - pros::Motor& cata_left = chassis.left_motors[3]; - pros::Motor& cata_right = chassis.right_motors[3]; + pros::Motor& intake_mtr = chassis.left_motors[3]; + pros::Motor& cata_mtr = chassis.right_motors[3]; } \ No newline at end of file diff --git a/HVN-ON-EARTH/src/superstructure.cpp b/HVN-ON-EARTH/src/superstructure.cpp index b19be36..796c30e 100644 --- a/HVN-ON-EARTH/src/superstructure.cpp +++ b/HVN-ON-EARTH/src/superstructure.cpp @@ -165,38 +165,37 @@ namespace superstruct { } // Structure methods - void intakeControl(pros::controller_digital_e_t intakeButton) { - if (globals::master.get_digital_new_press(intakeButton)) { - if (intakeEngaged == false) { - intake_piston.set_value(1); - intakeEngaged = true; - } else if (intakeEngaged == true) { - intake_piston.set_value(0); - intakeEngaged = false; - } - } - } + // void intakeControl(pros::controller_digital_e_t intakeButton) { + // if (globals::master.get_digital_new_press(intakeButton)) { + // if (intakeEngaged == false) { + // intake_piston.set_value(1); + // intakeEngaged = true; + // } else if (intakeEngaged == true) { + // intake_piston.set_value(0); + // intakeEngaged = false; + // } + // } + // } void togglePto(bool toggle) { ptoEnabled = toggle; - chassis.pto_toggle({cata_left, cata_right}, toggle); // Configure the listed PTO motors to whatever value toggle is. + chassis.pto_toggle({intake_mtr, cata_mtr}, toggle); // Configure the listed PTO motors to whatever value toggle is. pto_piston.set_value(toggle); if (toggle) { - cata_left.set_brake_mode(MOTOR_BRAKE_COAST); - cata_right.set_brake_mode(MOTOR_BRAKE_COAST); + intake_mtr.set_brake_mode(MOTOR_BRAKE_COAST); + cata_mtr.set_brake_mode(MOTOR_BRAKE_COAST); } } void runCata(double inpt) { if (!ptoEnabled) return; - //cata_left = inpt; - cata_right = inpt; + cata_mtr = inpt; } - void runAntiBlock(double inpt) { + void runIntake(double inpt) { if (!ptoEnabled) return; - cata_left = inpt; + intake_mtr = inpt; } /* @@ -205,7 +204,7 @@ namespace superstruct { */ int lock = 0; - void subsysControl(pros::controller_digital_e_t ptoToggleButton, pros::controller_digital_e_t cataRunButton) { + void subsysControl(pros::controller_digital_e_t ptoToggleButton, pros::controller_digital_e_t cataRunButton, pros::controller_digital_e_t intakeButton, pros::controller_digital_e_t outtakeButton) { if (globals::master.get_digital(ptoToggleButton) && lock == 0) { // If the PTO button has been pressed and the PTO is not engaged togglePto(!ptoEnabled); // Toggle the PTO so that cataput is useable lock = 1; @@ -219,12 +218,12 @@ namespace superstruct { runCata(0); } - if (globals::master.get_digital(DIGITAL_UP)) { - runAntiBlock(-12000); - } else if (globals::master.get_digital(DIGITAL_LEFT)) { - runAntiBlock(12000); + if (globals::master.get_digital(intakeButton)) { + runIntake(-12000); + } else if (globals::master.get_digital(outtakeButton)) { + runIntake(12000); } else { - runAntiBlock(0); + runIntake(-1000); } } @@ -265,21 +264,21 @@ namespace superstruct { */ void renu_control() { - subsysControl(RENU_PTO_TOGGLE, RENU_CATA_CONTROL); + subsysControl(RENU_PTO_TOGGLE, RENU_CATA_CONTROL, RENU_INTAKE_CONTROL_INTAKE, RENU_INTAKE_CONTROL_OUTTAKE); wingsControlSingle(RENU_WING_CONTROL); - intakeControl(RENU_INTAKE_CONTROL); + //intakeControl(RENU_INTAKE_CONTROL); climbControl(RENU_CLIMB_CONTROL); } void ria_control() { - subsysControl(RIA_PTO_TOGGLE, RIA_CATA_CONTROL); - wingsControlSingle(RIA_WINGS_CONTROL); - intakeControl(RIA_INTAKE_CONTROL); + // subsysControl(RIA_PTO_TOGGLE, RIA_CATA_CONTROL); + // wingsControlSingle(RIA_WINGS_CONTROL); + //intakeControl(RIA_INTAKE_CONTROL); } void chris_control() { - subsysControl(RENU_PTO_TOGGLE, RENU_CATA_CONTROL); + subsysControl(RENU_PTO_TOGGLE, RENU_CATA_CONTROL, RENU_INTAKE_CONTROL_INTAKE, RENU_INTAKE_CONTROL_OUTTAKE); wingsControlSingle(RENU_WING_CONTROL); - intakeControl(RENU_INTAKE_CONTROL); + //intakeControl(RENU_INTAKE_CONTROL); } } \ No newline at end of file