From 2a8364adae69b052d0dc237bef6b1118a1dbb6f9 Mon Sep 17 00:00:00 2001 From: ary Date: Fri, 29 Sep 2023 22:58:38 -0400 Subject: [PATCH] wings, debugging, and depression --- RELENTLESS/include/globals.hpp | 9 ++-- RELENTLESS/include/superstructure.hpp | 2 +- RELENTLESS/include/wings.h | 4 +- RELENTLESS/src/ary-lib/drive/user_input.cpp | 8 ++++ RELENTLESS/src/globals.cpp | 11 +++-- RELENTLESS/src/main.cpp | 2 +- RELENTLESS/src/wings.cpp | 51 +++++++++++++++++++++ 7 files changed, 77 insertions(+), 10 deletions(-) diff --git a/RELENTLESS/include/globals.hpp b/RELENTLESS/include/globals.hpp index e8a438e..4b924c2 100644 --- a/RELENTLESS/include/globals.hpp +++ b/RELENTLESS/include/globals.hpp @@ -3,14 +3,12 @@ #include "lemlib/api.hpp" #include "ary-lib/drive/drive.hpp" -#define TRACK_WDITH 11.5 +#define TRACK_WIDTH 11.5 #define PLACEHOLDER_TC_OFFSET 2.5 #define WHEEL_SIZE 2.75 #define DRIVE_RATIO 0.75 #define DRIVE_RPM 450 -bool ptoEnabled; - namespace globals { extern pros::Controller master; @@ -32,7 +30,10 @@ namespace globals { extern pros::Rotation rot_horiz; extern pros::Rotation enc_theta; - extern pros::ADIAnalogOut pto_piston; + extern pros::ADIDigitalOut pto_piston; + + extern pros::ADIPort left_wing_piston; + extern pros::ADIPort right_wing_piston; extern lemlib::TrackingWheel vert_tracking_wheel; extern lemlib::TrackingWheel horiz_tracking_wheel; diff --git a/RELENTLESS/include/superstructure.hpp b/RELENTLESS/include/superstructure.hpp index 42b8328..1d845d8 100644 --- a/RELENTLESS/include/superstructure.hpp +++ b/RELENTLESS/include/superstructure.hpp @@ -24,6 +24,6 @@ namespace superstruct { //- Structure methods void togglePto(); void runCata(); - void controlCata(); + void cataControl(); } \ No newline at end of file diff --git a/RELENTLESS/include/wings.h b/RELENTLESS/include/wings.h index 6352c40..e707e13 100644 --- a/RELENTLESS/include/wings.h +++ b/RELENTLESS/include/wings.h @@ -8,8 +8,10 @@ class Wings { Wings(); void open(); void close(); + void toggleLeft(int value); + void toggleRight(int value); void openFor(double duration); - bool getState(); + std::uint8_t getState(); private: std::uint8_t wingsopen; diff --git a/RELENTLESS/src/ary-lib/drive/user_input.cpp b/RELENTLESS/src/ary-lib/drive/user_input.cpp index ee060ca..374cd54 100644 --- a/RELENTLESS/src/ary-lib/drive/user_input.cpp +++ b/RELENTLESS/src/ary-lib/drive/user_input.cpp @@ -5,6 +5,14 @@ double JOYSTICK_TURN_SCALE = 1; double cata_active_brake_kp = 0.1; +void Drive::save_l_curve_sd() { + return; +} + +void Drive::save_r_curve_sd() { + return; +} + // Set curve defaults void Drive::set_curve_default(double left, double right) { left_curve_scale = left; diff --git a/RELENTLESS/src/globals.cpp b/RELENTLESS/src/globals.cpp index 951bd3a..bcfa4c6 100644 --- a/RELENTLESS/src/globals.cpp +++ b/RELENTLESS/src/globals.cpp @@ -20,9 +20,14 @@ namespace globals { // Electronics / Pneumatics / Sensors pros::Rotation rot_vert(0); pros::Rotation rot_horiz(1); - // pros::Rotation enc_right(); - // pros::Rotation enc_theta(); - pros::ADIAnalogOut pto_piston('A'); + + pros::ADIDigitalOut pto_piston('A'); + + // pros::ADIDigitalOut left_wing_piston(2); + // pros::ADIDigitalOut right_wing_piston(3); + + pros::ADIPort left_wing_piston('B', pros::E_ADI_DIGITAL_OUT); + pros::ADIPort right_wing_piston('C', pros::E_ADI_DIGITAL_OUT); lemlib::Drivetrain_t chassis_odom { &left_drive, diff --git a/RELENTLESS/src/main.cpp b/RELENTLESS/src/main.cpp index 39c0fe5..cb241c5 100644 --- a/RELENTLESS/src/main.cpp +++ b/RELENTLESS/src/main.cpp @@ -82,7 +82,7 @@ void autonomous() {} void opcontrol() { while (true) { chassis.tank(); - superstruct::controlCata(); + superstruct::cataControl(); pros::delay(20); } } diff --git a/RELENTLESS/src/wings.cpp b/RELENTLESS/src/wings.cpp index e69de29..b926734 100644 --- a/RELENTLESS/src/wings.cpp +++ b/RELENTLESS/src/wings.cpp @@ -0,0 +1,51 @@ +#include "main.h" +#include "globals.hpp" +#include "superstructure.hpp" +#include "wings.h" + +using namespace globals; + +Wings::Wings() { + close(); + wingsopen = 0; +}; + +void Wings::open() { + left_wing_piston.set_value(1); + right_wing_piston.set_value(1); +} + +void Wings::close() { + left_wing_piston.set_value(0); + right_wing_piston.set_value(0); +} + +void Wings::toggleLeft(int value) { + left_wing_piston.set_value(value); +} + +void Wings::toggleRight(int value) { + right_wing_piston.set_value(value); +} + +void Wings::openFor(double duration) { + open(); + pros::delay(duration * 1000); + close(); +} + + +/* + 0 -> Both wings closed + 1 -> Only right wing opened + 2 -> Only left wing opened + 3-> Both wings open +*/ +std::uint8_t getState() { + // int stateLeft = left_wing_pisto; + // int stateRight = right_wing_piston.get_value(); + return 0; +} + + +