From b66015aaf7695f8fa78c2f22dc1a79759d3b290b Mon Sep 17 00:00:00 2001 From: aHalliday13 Date: Sun, 3 Apr 2022 11:07:06 -0400 Subject: [PATCH 01/14] add auton descriptions to all routines --- src/main.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2147268..3139ed6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -235,6 +235,7 @@ void speedyAuton(void) { } void zach1(){ + // Start on right, grab right neutral with front, grab alliance goal with back, load with rings from field frontHook.set(false); driveIN(47,directionType::fwd,12.0); frontMogo.spinFor(700,rotationUnits::deg,200,velocityUnits::pct,false); @@ -254,31 +255,31 @@ void zach1(){ } void zach2(){ - + // start on right, grab yellow center with front, grab alliance goal with rear, load with rings from field } void zach3(){ - + // start on left, speed for left yellow, back up to alliance on platform, grab, load with match load rings } void zach4(){ - + // start on right, speed for right yellow with front, grab center yellow with back, place center yellow in corner, grab alliance with back, get field rings } void zach5(){ - + // start on right, speed for center, back up to alliance, load with field rings, grab right yellow with front } void zach6(){ - + // same as 5, but fake dash for right goal instead of center } void zach7(){ - + // start on left, fake for left yellow, go for center, bring it back, grab alliance with rear lift, load with match loads } void zach8(){ - + // open slot for future expansion } // now that autons are defined, we can define the auton selection code From d1f17fc395de05f96061fc8f07ab0a05b40579bb Mon Sep 17 00:00:00 2001 From: aHalliday13 Date: Tue, 5 Apr 2022 14:43:17 -0400 Subject: [PATCH 02/14] Continued work on ZACH autons --- src/main.cpp | 70 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3139ed6..5bb82ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,8 +29,8 @@ // RANWP Complete // RAR Complete // SKILL In Progress -// ZACH1 In Progress -// ZACH2 Not Started +// ZACH1 Complete +// ZACH2 In Progress // ZACH3 Not Started // ZACH4 Not Started // ZACH5 Not Started @@ -238,24 +238,35 @@ void zach1(){ // Start on right, grab right neutral with front, grab alliance goal with back, load with rings from field frontHook.set(false); driveIN(47,directionType::fwd,12.0); - frontMogo.spinFor(700,rotationUnits::deg,200,velocityUnits::pct,false); frontHook.set(true); - frontMogo.stop(brakeType::hold); + frontMogo.startSpinTo(800,rotationUnits::deg); driveIN(50,directionType::rev,12.0); InertialLeft(125); - driveIN(15,directionType::rev,7.0); + driveIN(17,directionType::rev,7.0); rearHook.set(true); task::sleep(500); - ringLift.spin(directionType::fwd,100,velocityUnits::pct); - driveIN(4.5,directionType::fwd,12.0); + frontMogo.stop(brakeType::hold); + ringLift.spin(directionType::fwd,50,velocityUnits::pct); + driveIN(4.75,directionType::fwd,12.0); InertialRight(125); - driveIN(55,directionType::fwd,6.75); - driveIN(70,directionType::rev,12.0); + ringLift.setVelocity(200, percentUnits::pct); + driveIN(55,directionType::fwd,5.5); + driveIN(55,directionType::rev,5.5); + InertialLeft(180); ringLift.stop(); } void zach2(){ // start on right, grab yellow center with front, grab alliance goal with rear, load with rings from field + driveIN(60,directionType::fwd,12.0); + frontHook.set(true); + //frontMogo.spinFor(700,rotationUnits::deg,200,velocityUnits::pct,false); + driveIN(43,directionType::rev,12.0); + InertialLeft(40); + driveIN(20,directionType::rev,12.0); + rearHook.set(true); + driveIN(1,directionType::rev,12.0); + InertialRight(90); } void zach3(){ @@ -283,32 +294,63 @@ void zach8(){ } // now that autons are defined, we can define the auton selection code -std::string autonRoutes [13] = {"LANWP","SPEED","RANWP","RAR","SKILL","ZACH1","ZACH2","ZACH3","ZACH4","ZACH5","ZACH6","ZACH7","ZACH8"}; +std::string autonRoutes [13] = {"LANWP","SPEED","RANWP","RARNR","SKILL","ZACH1","ZACH2","ZACH3","ZACH4","ZACH5","ZACH6","ZACH7","ZACH8"}; bool waitForComplete = true; int autonIndex = 0; void autonSelect(){ - printf("%i",autonIndex); while(waitForComplete){ if (Controller1.ButtonUp.pressing()){ autonIndex++; - printf("%i",autonIndex); waitUntil(!Controller1.ButtonUp.pressing()); } else if (Controller1.ButtonDown.pressing()){ autonIndex--; - printf("%i",autonIndex); waitUntil(!Controller1.ButtonDown.pressing()); } else if (Controller1.ButtonX.pressing()) { + Controller1.Screen.setCursor(4, 1); + Controller1.Screen.print("= %s",autonRoutes[autonIndex].c_str()); waitForComplete = false; } + else{ + Controller1.Screen.print("> %s",autonRoutes[autonIndex].c_str()); + Controller1.Screen.setCursor(4, 1); + } // prevent overflow autonIndex = autonIndex < 0 ? autonIndex+13 : autonIndex; autonIndex = autonIndex > 12 ? 0 : autonIndex; } + switch(autonIndex){ + case(0): + Competition.autonomous(leftAutonNoWP); + case(1): + Competition.autonomous(speedyAuton); + case(2): + Competition.autonomous(rightAutonNoWP); + case(3): + Competition.autonomous(rightAutonRight); + case(4): + Competition.autonomous(skillsAuton); + case(5): + Competition.autonomous(zach1); + case(6): + Competition.autonomous(zach2); + case(7): + Competition.autonomous(zach3); + case(8): + Competition.autonomous(zach4); + case(9): + Competition.autonomous(zach5); + case(10): + Competition.autonomous(zach6); + case(11): + Competition.autonomous(zach7); + case(12): + Competition.autonomous(zach8); + } } // define pre-auton routine here @@ -372,7 +414,7 @@ int main() { // run the pre-auton routine pre_auton(); // Manualy select an auton - Competition.autonomous(zach1); + Competition.autonomous(zach2); // Autonomous Selection //autonSelect(); // Set up callbacks for driver control period. From b563a4768a8cb8070338d09e88e3ad324365d8d0 Mon Sep 17 00:00:00 2001 From: aHalliday13 Date: Mon, 11 Apr 2022 07:54:42 -0400 Subject: [PATCH 03/14] Continued work on auton routines --- EdgarProCompetition.v5code | 2 +- include/robot-config.h | 30 ++++++++++++++--- src/main.cpp | 66 +++++++++++++++++++++++++------------- src/robot-config.cpp | 28 ++++++++-------- 4 files changed, 84 insertions(+), 42 deletions(-) diff --git a/EdgarProCompetition.v5code b/EdgarProCompetition.v5code index 4882cc8..68676b7 100644 --- a/EdgarProCompetition.v5code +++ b/EdgarProCompetition.v5code @@ -1 +1 @@ -{"title":"EdgarProCompetition","description":"E.D.G.A.R. (Ergonomicaly Decent Goal-Grabbing Automated Robot)","icon":"USER921x.bmp","version":"21.10.0712","sdk":"20210708_10_00_00","language":"cpp","competition":false,"files":[{"name":"include/robot-config.h","type":"File","specialType":"device_config"},{"name":"include/vex.h","type":"File","specialType":""},{"name":"makefile","type":"File","specialType":""},{"name":"src/main.cpp","type":"File","specialType":""},{"name":"src/robot-config.cpp","type":"File","specialType":"device_config"},{"name":"vex/mkenv.mk","type":"File","specialType":""},{"name":"vex/mkrules.mk","type":"File","specialType":""},{"name":"CODE_OF_CONDUCT.md","type":"File","specialType":""},{"name":"index.md","type":"File","specialType":""},{"name":"include","type":"Directory"},{"name":"src","type":"Directory"},{"name":"vex","type":"Directory"}],"device":{"slot":1,"uid":"276-4810","options":{}},"isExpertMode":true,"isExpertModeRC":true,"isVexFileImport":false,"robotconfig":[],"neverUpdate":null} \ No newline at end of file +{"title":"EdgarProCompetition","description":"E.D.G.A.R. (Ergonomicaly Decent Goal-Grabbing Automated Robot)","icon":"USER921x.bmp","version":"21.10.0712","sdk":"20220215_18_00_00","language":"cpp","competition":false,"files":[{"name":"include/robot-config.h","type":"File","specialType":"device_config"},{"name":"include/vex.h","type":"File","specialType":""},{"name":"makefile","type":"File","specialType":""},{"name":"src/main.cpp","type":"File","specialType":""},{"name":"src/robot-config.cpp","type":"File","specialType":"device_config"},{"name":"vex/mkenv.mk","type":"File","specialType":""},{"name":"vex/mkrules.mk","type":"File","specialType":""},{"name":"CODE_OF_CONDUCT.md","type":"File","specialType":""},{"name":"index.md","type":"File","specialType":""},{"name":"CONTRIBUTING.md","type":"File","specialType":""},{"name":"include","type":"Directory"},{"name":"src","type":"Directory"},{"name":"vex","type":"Directory"}],"device":{"slot":1,"uid":"276-4810","options":{}},"isExpertMode":true,"isExpertModeRC":false,"isVexFileImport":false,"robotconfig":[{"port":[],"name":"Controller1","customName":false,"deviceType":"Controller","setting":{"left":"","leftDir":"false","right":"","rightDir":"false","upDown":"","upDownDir":"false","xB":"","xBDir":"false","drive":"none","id":"primary"}},{"port":[10],"name":"inertialSensor","customName":true,"deviceType":"Inertial","setting":{"id":"partner"}},{"port":[8],"name":"frontHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[7],"name":"frontMogo","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio36_1"}},{"port":[11],"name":"ringLift","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[1],"name":"LeftDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[3],"name":"LeftDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[9],"name":"LeftDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[2],"name":"RightDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[4],"name":"RightDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[6],"name":"RightDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[7],"name":"rearHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[1],"name":"autonHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[17],"name":"frontVision","customName":true,"deviceType":"Vision","setting":{"config":"{\"config\":{\"brightness\":50,\"signatures\":[{\"name\":\"SIG_1\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_1\"},\"range\":2.5},{\"name\":\"SIG_2\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_2\"},\"range\":2.5},{\"name\":\"SIG_3\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_3\"},\"range\":2.5},{\"name\":\"SIG_4\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_4\"},\"range\":2.5},{\"name\":\"SIG_5\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_5\"},\"range\":2.5},{\"name\":\"SIG_6\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_6\"},\"range\":2.5},{\"name\":\"SIG_7\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_7\"},\"range\":2.5}],\"codes\":[]}}","isConfigured":"false","id":"partner"}},{"port":[15],"name":"rearVision","customName":true,"deviceType":"Vision","setting":{"config":"{\"config\":{\"brightness\":50,\"signatures\":[{\"name\":\"SIG_1\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_1\"},\"range\":2.5},{\"name\":\"SIG_2\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_2\"},\"range\":2.5},{\"name\":\"SIG_3\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_3\"},\"range\":2.5},{\"name\":\"SIG_4\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_4\"},\"range\":2.5},{\"name\":\"SIG_5\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_5\"},\"range\":2.5},{\"name\":\"SIG_6\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_6\"},\"range\":2.5},{\"name\":\"SIG_7\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_7\"},\"range\":2.5}],\"codes\":[]}}","isConfigured":"false","id":"partner"}}],"neverUpdate":null} \ No newline at end of file diff --git a/include/robot-config.h b/include/robot-config.h index 5a0a859..2411c08 100644 --- a/include/robot-config.h +++ b/include/robot-config.h @@ -2,16 +2,38 @@ using namespace vex; extern brain Brain; +using signature = vision::signature; + // VEXcode devices -extern digital_out frontHook; +extern controller Controller1; extern inertial inertialSensor; +extern digital_out frontHook; extern motor frontMogo; extern motor ringLift; -extern motor_group LeftDriveSmart; -extern motor_group RightDriveSmart; -extern controller Controller1; +extern motor LeftDriveSmartA; +extern motor LeftDriveSmartB; +extern motor LeftDriveSmartC; +extern motor RightDriveSmartA; +extern motor RightDriveSmartB; +extern motor RightDriveSmartC; extern digital_out rearHook; extern digital_out autonHook; +extern signature frontVision__SIG_1; +extern signature frontVision__SIG_2; +extern signature frontVision__SIG_3; +extern signature frontVision__SIG_4; +extern signature frontVision__SIG_5; +extern signature frontVision__SIG_6; +extern signature frontVision__SIG_7; +extern vision frontVision; +extern signature rearVision__SIG_1; +extern signature rearVision__SIG_2; +extern signature rearVision__SIG_3; +extern signature rearVision__SIG_4; +extern signature rearVision__SIG_5; +extern signature rearVision__SIG_6; +extern signature rearVision__SIG_7; +extern vision rearVision; /** * Used to initialize code/tasks/devices added using tools in VEXcode Pro. diff --git a/src/main.cpp b/src/main.cpp index cc682ff..c963c4b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,19 +9,6 @@ // "It's always the programmer's fault" - Some genius on the vex fourms -// ---- START VEXCODE CONFIGURED DEVICES ---- -// Robot Configuration: -// [Name] [Type] [Port(s)] -// frontHook digital_out H -// rearHook digital_out G -// inertialSensor inertial 10 -// frontMogo motor 7 -// ringLift motor 8 -// LeftDriveSmart motor_group 1, 3, 5 -// RightDriveSmart motor_group 2, 4, 6 -// Controller1 controller -// ---- END VEXCODE CONFIGURED DEVICES ---- - // ---- START SUPPORTED AUTON ROUTES ---- // [Name] [Support Level] // LANWP Incomplete @@ -40,11 +27,34 @@ // ---- END SUPPORTED AUTON ROUTES ---- #include "vex.h" + +// ---- START VEXCODE CONFIGURED DEVICES ---- +// Robot Configuration: +// [Name] [Type] [Port(s)] +// Controller1 controller +// inertialSensor inertial 10 +// frontHook digital_out H +// frontMogo motor 7 +// ringLift motor 11 +// LeftDriveSmartA motor 1 +// LeftDriveSmartB motor 3 +// LeftDriveSmartC motor 9 +// RightDriveSmartA motor 2 +// RightDriveSmartB motor 4 +// RightDriveSmartC motor 6 +// rearHook digital_out G +// autonHook digital_out A +// frontVision vision 17 +// rearVision vision 15 +// ---- END VEXCODE CONFIGURED DEVICES ---- #include "cmath" using namespace vex; competition Competition; +motor_group LeftDriveSmart = motor_group(LeftDriveSmartA, LeftDriveSmartB, LeftDriveSmartC); +motor_group RightDriveSmart = motor_group(RightDriveSmartA, RightDriveSmartB, RightDriveSmartC); + // define variables and macros here int calcVelocity; int prevTurn; @@ -256,21 +266,32 @@ void zach1(){ ringLift.stop(); } +#define MANUAL zach2 + void zach2(){ // start on right, grab yellow center with front, grab alliance goal with rear, load with rings from field driveIN(60,directionType::fwd,12.0); frontHook.set(true); - //frontMogo.spinFor(700,rotationUnits::deg,200,velocityUnits::pct,false); + frontMogo.startSpinTo(400,rotationUnits::deg,200,velocityUnits::pct); driveIN(43,directionType::rev,12.0); - InertialLeft(40); - driveIN(20,directionType::rev,12.0); + task::sleep(500); + InertialLeft(42.5); + driveIN(15,directionType::rev,7.0); rearHook.set(true); - driveIN(1,directionType::rev,12.0); - InertialRight(90); + driveIN(5,directionType::fwd,12.0); + InertialRight(92.5); + //ringLift.spin(fwd,12.0,voltageUnits::volt); + //driveIN(60,directionType::fwd,7.0); + //driveIN(70,directionType::rev,12.0); } void zach3(){ // start on left, speed for left yellow, back up to alliance on platform, grab, load with match load rings + driveIN(47,directionType::fwd,12.0); + LeftDriveSmart.spin(directionType::rev,200,velocityUnits::pct); + RightDriveSmart.spin(directionType::rev,200,velocityUnits::pct); + frontHook.set(true); + frontMogo.spinFor(90,rotationUnits::deg,false); } void zach4(){ @@ -294,7 +315,8 @@ void zach8(){ } // now that autons are defined, we can define the auton selection code -std::string autonRoutes [13] = {"LANWP","SPEED","RANWP","RARNR","SKILL","ZACH1","ZACH2","ZACH3","ZACH4","ZACH5","ZACH6","ZACH7","ZACH8"}; +//autonRoutes [13] = {"LANWP","SPEED","RANWP","RARNR","SKILL","ZACH1","ZACH2","ZACH3","ZACH4","ZACH5","ZACH6","ZACH7","ZACH8"}; + bool waitForComplete = true; int autonIndex = 0; @@ -310,11 +332,11 @@ void autonSelect(){ } else if (Controller1.ButtonX.pressing()) { Controller1.Screen.setCursor(4, 1); - Controller1.Screen.print("= %s",autonRoutes[autonIndex].c_str()); + //Controller1.Screen.print("= %s",autonRoutes[autonIndex].c_str()); waitForComplete = false; } else{ - Controller1.Screen.print("> %s",autonRoutes[autonIndex].c_str()); + //Controller1.Screen.print("> %s",autonRoutes[autonIndex].c_str()); Controller1.Screen.setCursor(4, 1); } @@ -421,7 +443,7 @@ int main() { // run the pre-auton routine pre_auton(); // Manualy select an auton - Competition.autonomous(zach2); + Competition.autonomous(MANUAL); // Autonomous Selection //autonSelect(); // Set up callbacks for driver control period. diff --git a/src/robot-config.cpp b/src/robot-config.cpp index 25f68d4..8be065b 100644 --- a/src/robot-config.cpp +++ b/src/robot-config.cpp @@ -8,27 +8,25 @@ using code = vision::code; brain Brain; // VEXcode device constructors - controller Controller1 = controller(primary); inertial inertialSensor = inertial(PORT10); - digital_out frontHook = digital_out(Brain.ThreeWirePort.H); motor frontMogo = motor(PORT7, ratio36_1, true); - -motor ringLift = motor(PORT11, ratio18_1, false); //FIX GEARS LMAO - -motor LeftDriveSmartMotorA = motor(PORT1, ratio6_1, true); -motor LeftDriveSmartMotorB = motor(PORT3, ratio6_1, false); -motor LeftDriveSmartMotorC = motor(PORT9, ratio6_1, false); -motor_group LeftDriveSmart = motor_group(LeftDriveSmartMotorA, LeftDriveSmartMotorB, LeftDriveSmartMotorC); - -motor RightDriveSmartMotorA = motor(PORT2, ratio6_1, false); -motor RightDriveSmartMotorB = motor(PORT4, ratio6_1, true); -motor RightDriveSmartMotorC = motor(PORT6, ratio6_1, true); -motor_group RightDriveSmart = motor_group(RightDriveSmartMotorA, RightDriveSmartMotorB, RightDriveSmartMotorC); - +motor ringLift = motor(PORT11, ratio6_1, false); +motor LeftDriveSmartA = motor(PORT1, ratio6_1, true); +motor LeftDriveSmartB = motor(PORT3, ratio6_1, false); +motor LeftDriveSmartC = motor(PORT9, ratio6_1, false); +motor RightDriveSmartA = motor(PORT2, ratio6_1, false); +motor RightDriveSmartB = motor(PORT4, ratio6_1, true); +motor RightDriveSmartC = motor(PORT6, ratio6_1, true); digital_out rearHook = digital_out(Brain.ThreeWirePort.G); digital_out autonHook = digital_out(Brain.ThreeWirePort.A); +/*vex-vision-config:begin*/ +vision frontVision = vision (PORT17, 50); +/*vex-vision-config:end*/ +/*vex-vision-config:begin*/ +vision rearVision = vision (PORT15, 50); +/*vex-vision-config:end*/ // VEXcode generated functions // define variable for remote controller enable/disable From 0e5ba3a25a4c65f74ab5fc4d48f3157bb6639249 Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Mon, 11 Apr 2022 18:56:36 -0400 Subject: [PATCH 04/14] Removed vision sensor and worked on zach3 --- EdgarProCompetition.v5code | 2 +- compile_commands.json | 2 +- include/robot-config.h | 18 ------------------ src/main.cpp | 24 ++++++++++++------------ src/robot-config.cpp | 6 ------ 5 files changed, 14 insertions(+), 38 deletions(-) diff --git a/EdgarProCompetition.v5code b/EdgarProCompetition.v5code index 68676b7..e1b0144 100644 --- a/EdgarProCompetition.v5code +++ b/EdgarProCompetition.v5code @@ -1 +1 @@ -{"title":"EdgarProCompetition","description":"E.D.G.A.R. (Ergonomicaly Decent Goal-Grabbing Automated Robot)","icon":"USER921x.bmp","version":"21.10.0712","sdk":"20220215_18_00_00","language":"cpp","competition":false,"files":[{"name":"include/robot-config.h","type":"File","specialType":"device_config"},{"name":"include/vex.h","type":"File","specialType":""},{"name":"makefile","type":"File","specialType":""},{"name":"src/main.cpp","type":"File","specialType":""},{"name":"src/robot-config.cpp","type":"File","specialType":"device_config"},{"name":"vex/mkenv.mk","type":"File","specialType":""},{"name":"vex/mkrules.mk","type":"File","specialType":""},{"name":"CODE_OF_CONDUCT.md","type":"File","specialType":""},{"name":"index.md","type":"File","specialType":""},{"name":"CONTRIBUTING.md","type":"File","specialType":""},{"name":"include","type":"Directory"},{"name":"src","type":"Directory"},{"name":"vex","type":"Directory"}],"device":{"slot":1,"uid":"276-4810","options":{}},"isExpertMode":true,"isExpertModeRC":false,"isVexFileImport":false,"robotconfig":[{"port":[],"name":"Controller1","customName":false,"deviceType":"Controller","setting":{"left":"","leftDir":"false","right":"","rightDir":"false","upDown":"","upDownDir":"false","xB":"","xBDir":"false","drive":"none","id":"primary"}},{"port":[10],"name":"inertialSensor","customName":true,"deviceType":"Inertial","setting":{"id":"partner"}},{"port":[8],"name":"frontHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[7],"name":"frontMogo","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio36_1"}},{"port":[11],"name":"ringLift","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[1],"name":"LeftDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[3],"name":"LeftDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[9],"name":"LeftDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[2],"name":"RightDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[4],"name":"RightDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[6],"name":"RightDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"}},{"port":[7],"name":"rearHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[1],"name":"autonHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[17],"name":"frontVision","customName":true,"deviceType":"Vision","setting":{"config":"{\"config\":{\"brightness\":50,\"signatures\":[{\"name\":\"SIG_1\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_1\"},\"range\":2.5},{\"name\":\"SIG_2\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_2\"},\"range\":2.5},{\"name\":\"SIG_3\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_3\"},\"range\":2.5},{\"name\":\"SIG_4\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_4\"},\"range\":2.5},{\"name\":\"SIG_5\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_5\"},\"range\":2.5},{\"name\":\"SIG_6\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_6\"},\"range\":2.5},{\"name\":\"SIG_7\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_7\"},\"range\":2.5}],\"codes\":[]}}","isConfigured":"false","id":"partner"}},{"port":[15],"name":"rearVision","customName":true,"deviceType":"Vision","setting":{"config":"{\"config\":{\"brightness\":50,\"signatures\":[{\"name\":\"SIG_1\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_1\"},\"range\":2.5},{\"name\":\"SIG_2\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_2\"},\"range\":2.5},{\"name\":\"SIG_3\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_3\"},\"range\":2.5},{\"name\":\"SIG_4\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_4\"},\"range\":2.5},{\"name\":\"SIG_5\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_5\"},\"range\":2.5},{\"name\":\"SIG_6\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_6\"},\"range\":2.5},{\"name\":\"SIG_7\",\"parameters\":{\"uMin\":0,\"uMax\":0,\"uMean\":0,\"vMin\":0,\"vMax\":0,\"vMean\":0,\"rgb\":0,\"type\":0,\"name\":\"SIG_7\"},\"range\":2.5}],\"codes\":[]}}","isConfigured":"false","id":"partner"}}],"neverUpdate":null} \ No newline at end of file +{"title":"EdgarProCompetition","description":"E.D.G.A.R. (Ergonomicaly Decent Goal-Grabbing Automated Robot)","icon":"USER921x.bmp","version":"21.10.0712","sdk":"20210708_10_00_00","language":"cpp","competition":false,"files":[{"name":"include/robot-config.h","type":"File","specialType":"device_config"},{"name":"include/vex.h","type":"File","specialType":""},{"name":"makefile","type":"File","specialType":""},{"name":"src/main.cpp","type":"File","specialType":""},{"name":"src/robot-config.cpp","type":"File","specialType":"device_config"},{"name":"vex/mkenv.mk","type":"File","specialType":""},{"name":"vex/mkrules.mk","type":"File","specialType":""},{"name":"CODE_OF_CONDUCT.md","type":"File","specialType":""},{"name":"index.md","type":"File","specialType":""},{"name":"CONTRIBUTING.md","type":"File","specialType":""},{"name":"include","type":"Directory"},{"name":"src","type":"Directory"},{"name":"vex","type":"Directory"}],"device":{"slot":1,"uid":"276-4810","options":{}},"isExpertMode":true,"isExpertModeRC":false,"isVexFileImport":false,"robotconfig":[{"port":[],"name":"Controller1","customName":false,"deviceType":"Controller","setting":{"left":"","leftDir":"false","right":"","rightDir":"false","upDown":"","upDownDir":"false","xB":"","xBDir":"false","drive":"none","id":"primary"},"triportSourcePort":22},{"port":[10],"name":"inertialSensor","customName":true,"deviceType":"Inertial","setting":{"id":"partner"},"triportSourcePort":22},{"port":[8],"name":"frontHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[7],"name":"frontMogo","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio36_1"},"triportSourcePort":22},{"port":[11],"name":"ringLift","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[1],"name":"LeftDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[3],"name":"LeftDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[9],"name":"LeftDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[2],"name":"RightDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[4],"name":"RightDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[6],"name":"RightDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[7],"name":"rearHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[1],"name":"autonHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22}],"neverUpdate":null} \ No newline at end of file diff --git a/compile_commands.json b/compile_commands.json index b933208..8315247 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -1 +1 @@ -[{"directory":"/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar","file":"include/robot-config.h","arguments":["clang","-xc++","include/robot-config.h","-include","v5_vcs.h","--target=thumbv7-none-eabi","-U","__INT32_TYPE__","-U","__UINT32_TYPE__","-D","__INT32_TYPE__=long","-D","__UINT32_TYPE__=unsigned long","-std=gnu++11","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/clang/8.0.0/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include/c++/4.9.3","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb"]},{"directory":"/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar","file":"include/vex.h","arguments":["clang","-xc++","include/vex.h","-include","v5_vcs.h","--target=thumbv7-none-eabi","-U","__INT32_TYPE__","-U","__UINT32_TYPE__","-D","__INT32_TYPE__=long","-D","__UINT32_TYPE__=unsigned long","-std=gnu++11","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/clang/8.0.0/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include/c++/4.9.3","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb"]},{"directory":"/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar","file":"src/main.cpp","output":"build/src/main.o","arguments":["clang","-xc++","src/main.cpp","--target=thumbv7-none-eabi","-fshort-enums","-Wno-unknown-attributes","-U","__INT32_TYPE__","-U","__UINT32_TYPE__","-D","__INT32_TYPE__=long","-D","__UINT32_TYPE__=unsigned long","-march=armv7-a","-mfpu=neon","-mfloat-abi=softfp","-Os","-Wall","-Werror=return-type","-fno-rtti","-fno-threadsafe-statics","-fno-exceptions","-std=gnu++11","-ffunction-sections","-fdata-sections","-D","VexV5","-I","/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar","-I","/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar/include","-I","/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar/src","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/clang/8.0.0/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include/c++/4.9.3","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb","-c","-o","build/src/main.o","-mlinker-version=409.12","--target=armv7-none--eabi"]},{"directory":"/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar","file":"src/robot-config.cpp","output":"build/src/robot-config.o","arguments":["clang","-xc++","src/robot-config.cpp","--target=thumbv7-none-eabi","-fshort-enums","-Wno-unknown-attributes","-U","__INT32_TYPE__","-U","__UINT32_TYPE__","-D","__INT32_TYPE__=long","-D","__UINT32_TYPE__=unsigned long","-march=armv7-a","-mfpu=neon","-mfloat-abi=softfp","-Os","-Wall","-Werror=return-type","-fno-rtti","-fno-threadsafe-statics","-fno-exceptions","-std=gnu++11","-ffunction-sections","-fdata-sections","-D","VexV5","-I","/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar","-I","/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar/include","-I","/Users/anthonyhalliday/Documents/vexcode-projects/Vex64040Edgar/src","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/clang/8.0.0/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include/c++/4.9.3","-I","/Applications/VEXcode Pro V5.app/Contents/Resources/sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb","-c","-o","build/src/robot-config.o","-mlinker-version=409.12","--target=armv7-none--eabi"]}] \ No newline at end of file +[{"directory":"C:/Users/stroebell/Documents/GitHub/Edgar-Pro","file":"include/robot-config.h","arguments":["clang","-xc++","include/robot-config.h","-include","v5_vcs.h","--target=thumbv7-none-eabi","-U","__INT32_TYPE__","-U","__UINT32_TYPE__","-D","__INT32_TYPE__=long","-D","__UINT32_TYPE__=unsigned long","-std=gnu++11","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/clang/8.0.0/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include/c++/4.9.3","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb"]},{"directory":"C:/Users/stroebell/Documents/GitHub/Edgar-Pro","file":"include/vex.h","arguments":["clang","-xc++","include/vex.h","-include","v5_vcs.h","--target=thumbv7-none-eabi","-U","__INT32_TYPE__","-U","__UINT32_TYPE__","-D","__INT32_TYPE__=long","-D","__UINT32_TYPE__=unsigned long","-std=gnu++11","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/clang/8.0.0/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include/c++/4.9.3","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb"]},{"directory":"C:/Users/stroebell/Documents/GitHub/Edgar-Pro","file":"src/main.cpp","output":"build/src/main.o","arguments":["clang","-xc++","src/main.cpp","--target=thumbv7-none-eabi","-fshort-enums","-Wno-unknown-attributes","-U","__INT32_TYPE__","-U","__UINT32_TYPE__","-D","__INT32_TYPE__=long","-D","__UINT32_TYPE__=unsigned long","-march=armv7-a","-mfpu=neon","-mfloat-abi=softfp","-Os","-Wall","-Werror=return-type","-fno-rtti","-fno-threadsafe-statics","-fno-exceptions","-std=gnu++11","-ffunction-sections","-fdata-sections","-D","VexV5","-I","C:/Users/stroebell/Documents/GitHub/Edgar-Pro","-I","C:/Users/stroebell/Documents/GitHub/Edgar-Pro/include","-I","C:/Users/stroebell/Documents/GitHub/Edgar-Pro/src","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/clang/8.0.0/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include/c++/4.9.3","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb","-c","-o","build/src/main.o","-mlinker-version=409.12","--target=armv7-none--eabi"]},{"directory":"C:/Users/stroebell/Documents/GitHub/Edgar-Pro","file":"src/robot-config.cpp","output":"build/src/robot-config.o","arguments":["clang","-xc++","src/robot-config.cpp","--target=thumbv7-none-eabi","-fshort-enums","-Wno-unknown-attributes","-U","__INT32_TYPE__","-U","__UINT32_TYPE__","-D","__INT32_TYPE__=long","-D","__UINT32_TYPE__=unsigned long","-march=armv7-a","-mfpu=neon","-mfloat-abi=softfp","-Os","-Wall","-Werror=return-type","-fno-rtti","-fno-threadsafe-statics","-fno-exceptions","-std=gnu++11","-ffunction-sections","-fdata-sections","-D","VexV5","-I","C:/Users/stroebell/Documents/GitHub/Edgar-Pro","-I","C:/Users/stroebell/Documents/GitHub/Edgar-Pro/include","-I","C:/Users/stroebell/Documents/GitHub/Edgar-Pro/src","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/clang/8.0.0/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include/c++/4.9.3","-I","C:/Program Files (x86)/VEX Robotics/VEXcode Pro V5/sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb","-c","-o","build/src/robot-config.o","-mlinker-version=409.12","--target=armv7-none--eabi"]}] \ No newline at end of file diff --git a/include/robot-config.h b/include/robot-config.h index 2411c08..7b0bec3 100644 --- a/include/robot-config.h +++ b/include/robot-config.h @@ -2,8 +2,6 @@ using namespace vex; extern brain Brain; -using signature = vision::signature; - // VEXcode devices extern controller Controller1; extern inertial inertialSensor; @@ -18,22 +16,6 @@ extern motor RightDriveSmartB; extern motor RightDriveSmartC; extern digital_out rearHook; extern digital_out autonHook; -extern signature frontVision__SIG_1; -extern signature frontVision__SIG_2; -extern signature frontVision__SIG_3; -extern signature frontVision__SIG_4; -extern signature frontVision__SIG_5; -extern signature frontVision__SIG_6; -extern signature frontVision__SIG_7; -extern vision frontVision; -extern signature rearVision__SIG_1; -extern signature rearVision__SIG_2; -extern signature rearVision__SIG_3; -extern signature rearVision__SIG_4; -extern signature rearVision__SIG_5; -extern signature rearVision__SIG_6; -extern signature rearVision__SIG_7; -extern vision rearVision; /** * Used to initialize code/tasks/devices added using tools in VEXcode Pro. diff --git a/src/main.cpp b/src/main.cpp index c963c4b..fb5e62d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,9 +43,7 @@ // RightDriveSmartB motor 4 // RightDriveSmartC motor 6 // rearHook digital_out G -// autonHook digital_out A -// frontVision vision 17 -// rearVision vision 15 +// autonHook digital_out A // ---- END VEXCODE CONFIGURED DEVICES ---- #include "cmath" @@ -266,8 +264,6 @@ void zach1(){ ringLift.stop(); } -#define MANUAL zach2 - void zach2(){ // start on right, grab yellow center with front, grab alliance goal with rear, load with rings from field driveIN(60,directionType::fwd,12.0); @@ -280,18 +276,22 @@ void zach2(){ rearHook.set(true); driveIN(5,directionType::fwd,12.0); InertialRight(92.5); - //ringLift.spin(fwd,12.0,voltageUnits::volt); - //driveIN(60,directionType::fwd,7.0); - //driveIN(70,directionType::rev,12.0); + ringLift.spin(fwd,12.0,voltageUnits::volt); + driveIN(60,directionType::fwd,7.0); + driveIN(70,directionType::rev,12.0); } +#define MANUAL zach3 + void zach3(){ // start on left, speed for left yellow, back up to alliance on platform, grab, load with match load rings - driveIN(47,directionType::fwd,12.0); - LeftDriveSmart.spin(directionType::rev,200,velocityUnits::pct); - RightDriveSmart.spin(directionType::rev,200,velocityUnits::pct); + driveIN(47,directionType::fwd,6.0); frontHook.set(true); - frontMogo.spinFor(90,rotationUnits::deg,false); + frontMogo.startSpinTo(800,rotationUnits::deg); + driveIN(50,directionType::rev,6.0); + InertialLeft(130); + drive2obs(directionType::fwd); + driveIN(48,directionType::rev,12.0); } void zach4(){ diff --git a/src/robot-config.cpp b/src/robot-config.cpp index 8be065b..72c9cbc 100644 --- a/src/robot-config.cpp +++ b/src/robot-config.cpp @@ -21,12 +21,6 @@ motor RightDriveSmartB = motor(PORT4, ratio6_1, true); motor RightDriveSmartC = motor(PORT6, ratio6_1, true); digital_out rearHook = digital_out(Brain.ThreeWirePort.G); digital_out autonHook = digital_out(Brain.ThreeWirePort.A); -/*vex-vision-config:begin*/ -vision frontVision = vision (PORT17, 50); -/*vex-vision-config:end*/ -/*vex-vision-config:begin*/ -vision rearVision = vision (PORT15, 50); -/*vex-vision-config:end*/ // VEXcode generated functions // define variable for remote controller enable/disable From 194b85ceedc72c23c9e734a9925e2b4905d460ec Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Wed, 13 Apr 2022 07:52:25 -0400 Subject: [PATCH 05/14] Continued work on zach3 and auton selector --- src/main.cpp | 94 +++++++++++++++++++--------------------------------- 1 file changed, 34 insertions(+), 60 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fb5e62d..9d68ab6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,23 +9,6 @@ // "It's always the programmer's fault" - Some genius on the vex fourms -// ---- START SUPPORTED AUTON ROUTES ---- -// [Name] [Support Level] -// LANWP Incomplete -// SPEED Complete -// RANWP Complete -// RAR Complete -// SKILL In Progress -// ZACH1 Complete -// ZACH2 In Progress -// ZACH3 Not Started -// ZACH4 Not Started -// ZACH5 Not Started -// ZACH6 Not Started -// ZACH7 Not Started -// ZACH8 Not Started -// ---- END SUPPORTED AUTON ROUTES ---- - #include "vex.h" // ---- START VEXCODE CONFIGURED DEVICES ---- @@ -46,7 +29,6 @@ // autonHook digital_out A // ---- END VEXCODE CONFIGURED DEVICES ---- #include "cmath" - using namespace vex; competition Competition; @@ -70,8 +52,8 @@ void drive2obs(directionType dir){ waitUntil(LeftDriveSmart.velocity(percentUnits::pct)<5 && RightDriveSmart.velocity(percentUnits::pct)<5); } else{ - waitUntil(LeftDriveSmart.velocity(percentUnits::pct)<5 && RightDriveSmart.velocity(percentUnits::pct)<5); - waitUntil(LeftDriveSmart.velocity(percentUnits::pct)>5 && RightDriveSmart.velocity(percentUnits::pct)>5); + waitUntil(LeftDriveSmart.velocity(percentUnits::pct)<-5 || RightDriveSmart.velocity(percentUnits::pct)<-5); + waitUntil(LeftDriveSmart.velocity(percentUnits::pct)>-5 || RightDriveSmart.velocity(percentUnits::pct)>-5); } LeftDriveSmart.stop(); RightDriveSmart.stop(); @@ -284,14 +266,23 @@ void zach2(){ #define MANUAL zach3 void zach3(){ + // this routine is still very much a work in progress, so don't be supprised if it doesn't perform as expected // start on left, speed for left yellow, back up to alliance on platform, grab, load with match load rings - driveIN(47,directionType::fwd,6.0); + driveIN(48,directionType::fwd,12.0); frontHook.set(true); frontMogo.startSpinTo(800,rotationUnits::deg); - driveIN(50,directionType::rev,6.0); - InertialLeft(130); - drive2obs(directionType::fwd); - driveIN(48,directionType::rev,12.0); + driveIN(24,directionType::rev,12.0); + InertialRight(10); + driveIN(25,directionType::rev,7.0); + InertialLeft(115); + //drive2obs(directionType::fwd); + driveIN(1,directionType::rev,6.0); + drive2obs(directionType::rev); + rearHook.set(true); + driveIN(20,directionType::fwd,7.0); + InertialLeft(90); + driveIN(24,directionType::rev,12.0); + driveIN(24,directionType::fwd,7.0); } void zach4(){ @@ -315,12 +306,15 @@ void zach8(){ } // now that autons are defined, we can define the auton selection code -//autonRoutes [13] = {"LANWP","SPEED","RANWP","RARNR","SKILL","ZACH1","ZACH2","ZACH3","ZACH4","ZACH5","ZACH6","ZACH7","ZACH8"}; +/* This code is REALLY messed up, don't uncomment it unless you are some sort of wizzard who magicaly fixes code +std::function autonSelect(){ -bool waitForComplete = true; -int autonIndex = 0; + bool waitForComplete = true; + int autonIndex = 0; -void autonSelect(){ + std::string autonRoutes [13] = {"LANWP","SPEED","RANWP","RARNR","SKILL","ZACH1","ZACH2","ZACH3","ZACH4","ZACH5","ZACH6","ZACH7","ZACH8"}; + void (*functptr[])() = {&leftAutonNoWP,&speedyAuton,&rightAutonNoWP,&rightAutonRight,&skillsAuton,&zach1,&zach2,&zach3,&zach4,&zach5,&zach6,&zach7,&zach8}; + while(waitForComplete){ if (Controller1.ButtonUp.pressing()){ autonIndex++; @@ -332,11 +326,11 @@ void autonSelect(){ } else if (Controller1.ButtonX.pressing()) { Controller1.Screen.setCursor(4, 1); - //Controller1.Screen.print("= %s",autonRoutes[autonIndex].c_str()); + Controller1.Screen.print("= %s",autonRoutes[autonIndex].c_str()); waitForComplete = false; } else{ - //Controller1.Screen.print("> %s",autonRoutes[autonIndex].c_str()); + Controller1.Screen.print("> %s",autonRoutes[autonIndex].c_str()); Controller1.Screen.setCursor(4, 1); } @@ -345,35 +339,10 @@ void autonSelect(){ autonIndex = autonIndex > 12 ? 0 : autonIndex; } - switch(autonIndex){ - case(0): - Competition.autonomous(leftAutonNoWP); - case(1): - Competition.autonomous(speedyAuton); - case(2): - Competition.autonomous(rightAutonNoWP); - case(3): - Competition.autonomous(rightAutonRight); - case(4): - Competition.autonomous(skillsAuton); - case(5): - Competition.autonomous(zach1); - case(6): - Competition.autonomous(zach2); - case(7): - Competition.autonomous(zach3); - case(8): - Competition.autonomous(zach4); - case(9): - Competition.autonomous(zach5); - case(10): - Competition.autonomous(zach6); - case(11): - Competition.autonomous(zach7); - case(12): - Competition.autonomous(zach8); - } + Controller1.Screen.setCursor(4, 1); + return zach3; } +*/ // define pre-auton routine here void pre_auton(void) { @@ -408,6 +377,10 @@ void usercontrol(void) { // Spin drivetrain motors LeftDriveSmart.spin(vex::directionType::undefined, (2*abs(Controller1.Axis3.position()+Controller1.Axis4.position()) >= DEADBAND) ? 0-(Controller1.Axis3.position()+Controller1.Axis4.position()) : 0, velocityUnits::pct); RightDriveSmart.spin(vex::directionType::undefined, (2*abs(Controller1.Axis3.position()-Controller1.Axis4.position()) >= DEADBAND) ? 0-(Controller1.Axis3.position()-Controller1.Axis4.position()) : 0, velocityUnits::pct); + // Test code, don't uncomment unless you know what you're doing + //RightDriveSmart.spin(directionType::undefined,Controller1.Axis3.position(),velocityUnits::pct); + //LeftDriveSmart.spin(directionType::undefined,Controller1.Axis3.position(),velocityUnits::pct); + // Rear Lift up/down if(Controller1.ButtonL1.pressing()) { rearHook.set(true); @@ -445,12 +418,13 @@ int main() { // Manualy select an auton Competition.autonomous(MANUAL); // Autonomous Selection - //autonSelect(); + //Competition.autonomous(pls help!); // Set up callbacks for driver control period. Competition.drivercontrol(usercontrol); // Prevent main from exiting with an infinite loop. while(true) { task::sleep(100); + printf("LEFT: %f RIGHT: %f\n",LeftDriveSmart.velocity(percentUnits::pct),RightDriveSmart.velocity(percentUnits::pct)); } } From 171360ba718e6917a6b60b3c57077553e630e226 Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Thu, 14 Apr 2022 15:15:44 -0400 Subject: [PATCH 06/14] finalize many auton routes --- EdgarProCompetition.v5code | 2 +- src/main.cpp | 215 +++++++++++++++++++++++-------------- src/robot-config.cpp | 2 +- 3 files changed, 139 insertions(+), 80 deletions(-) diff --git a/EdgarProCompetition.v5code b/EdgarProCompetition.v5code index e1b0144..0b0e8b4 100644 --- a/EdgarProCompetition.v5code +++ b/EdgarProCompetition.v5code @@ -1 +1 @@ -{"title":"EdgarProCompetition","description":"E.D.G.A.R. (Ergonomicaly Decent Goal-Grabbing Automated Robot)","icon":"USER921x.bmp","version":"21.10.0712","sdk":"20210708_10_00_00","language":"cpp","competition":false,"files":[{"name":"include/robot-config.h","type":"File","specialType":"device_config"},{"name":"include/vex.h","type":"File","specialType":""},{"name":"makefile","type":"File","specialType":""},{"name":"src/main.cpp","type":"File","specialType":""},{"name":"src/robot-config.cpp","type":"File","specialType":"device_config"},{"name":"vex/mkenv.mk","type":"File","specialType":""},{"name":"vex/mkrules.mk","type":"File","specialType":""},{"name":"CODE_OF_CONDUCT.md","type":"File","specialType":""},{"name":"index.md","type":"File","specialType":""},{"name":"CONTRIBUTING.md","type":"File","specialType":""},{"name":"include","type":"Directory"},{"name":"src","type":"Directory"},{"name":"vex","type":"Directory"}],"device":{"slot":1,"uid":"276-4810","options":{}},"isExpertMode":true,"isExpertModeRC":false,"isVexFileImport":false,"robotconfig":[{"port":[],"name":"Controller1","customName":false,"deviceType":"Controller","setting":{"left":"","leftDir":"false","right":"","rightDir":"false","upDown":"","upDownDir":"false","xB":"","xBDir":"false","drive":"none","id":"primary"},"triportSourcePort":22},{"port":[10],"name":"inertialSensor","customName":true,"deviceType":"Inertial","setting":{"id":"partner"},"triportSourcePort":22},{"port":[8],"name":"frontHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[7],"name":"frontMogo","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio36_1"},"triportSourcePort":22},{"port":[11],"name":"ringLift","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[1],"name":"LeftDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[3],"name":"LeftDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[9],"name":"LeftDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[2],"name":"RightDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[4],"name":"RightDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[6],"name":"RightDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[7],"name":"rearHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[1],"name":"autonHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22}],"neverUpdate":null} \ No newline at end of file +{"title":"EdgarProCompetition","description":"E.D.G.A.R. (Ergonomicaly Decent Goal-Grabbing Automated Robot)","icon":"USER921x.bmp","version":"21.10.0712","sdk":"20210708_10_00_00","language":"cpp","competition":false,"files":[{"name":"include/robot-config.h","type":"File","specialType":"device_config"},{"name":"include/vex.h","type":"File","specialType":""},{"name":"makefile","type":"File","specialType":""},{"name":"src/main.cpp","type":"File","specialType":""},{"name":"src/robot-config.cpp","type":"File","specialType":"device_config"},{"name":"vex/mkenv.mk","type":"File","specialType":""},{"name":"vex/mkrules.mk","type":"File","specialType":""},{"name":"CODE_OF_CONDUCT.md","type":"File","specialType":""},{"name":"index.md","type":"File","specialType":""},{"name":"CONTRIBUTING.md","type":"File","specialType":""},{"name":"include","type":"Directory"},{"name":"src","type":"Directory"},{"name":"vex","type":"Directory"}],"device":{"slot":1,"uid":"276-4810","options":{}},"isExpertMode":true,"isExpertModeRC":false,"isVexFileImport":false,"robotconfig":[{"port":[],"name":"Controller1","customName":false,"deviceType":"Controller","setting":{"left":"","leftDir":"false","right":"","rightDir":"false","upDown":"","upDownDir":"false","xB":"","xBDir":"false","drive":"none","id":"primary"},"triportSourcePort":22},{"port":[10],"name":"inertialSensor","customName":true,"deviceType":"Inertial","setting":{"id":"partner"},"triportSourcePort":22},{"port":[8],"name":"frontHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[20],"name":"frontMogo","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio36_1"},"triportSourcePort":22},{"port":[11],"name":"ringLift","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[1],"name":"LeftDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[3],"name":"LeftDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[9],"name":"LeftDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[2],"name":"RightDriveSmartA","customName":true,"deviceType":"Motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[4],"name":"RightDriveSmartB","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[6],"name":"RightDriveSmartC","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio6_1"},"triportSourcePort":22},{"port":[7],"name":"rearHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22},{"port":[1],"name":"autonHook","customName":true,"deviceType":"DigitalOut","setting":{"id":"partner"},"triportSourcePort":22}],"neverUpdate":null} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 9d68ab6..091a3e0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,25 +10,8 @@ // "It's always the programmer's fault" - Some genius on the vex fourms #include "vex.h" - -// ---- START VEXCODE CONFIGURED DEVICES ---- -// Robot Configuration: -// [Name] [Type] [Port(s)] -// Controller1 controller -// inertialSensor inertial 10 -// frontHook digital_out H -// frontMogo motor 7 -// ringLift motor 11 -// LeftDriveSmartA motor 1 -// LeftDriveSmartB motor 3 -// LeftDriveSmartC motor 9 -// RightDriveSmartA motor 2 -// RightDriveSmartB motor 4 -// RightDriveSmartC motor 6 -// rearHook digital_out G -// autonHook digital_out A -// ---- END VEXCODE CONFIGURED DEVICES ---- #include "cmath" + using namespace vex; competition Competition; @@ -45,14 +28,14 @@ float heading; // define functions here void drive2obs(directionType dir){ - LeftDriveSmart.spin(dir,200,velocityUnits::pct); - RightDriveSmart.spin(dir,200,velocityUnits::pct); + LeftDriveSmart.spin(dir,12.0,voltageUnits::volt); + RightDriveSmart.spin(dir,12.0,voltageUnits::volt); if(dir==directionType::fwd){ waitUntil(LeftDriveSmart.velocity(percentUnits::pct)>5 && RightDriveSmart.velocity(percentUnits::pct)>5); waitUntil(LeftDriveSmart.velocity(percentUnits::pct)<5 && RightDriveSmart.velocity(percentUnits::pct)<5); } else{ - waitUntil(LeftDriveSmart.velocity(percentUnits::pct)<-5 || RightDriveSmart.velocity(percentUnits::pct)<-5); + waitUntil(LeftDriveSmart.velocity(percentUnits::pct)<-5 && RightDriveSmart.velocity(percentUnits::pct)<-5); waitUntil(LeftDriveSmart.velocity(percentUnits::pct)>-5 || RightDriveSmart.velocity(percentUnits::pct)>-5); } LeftDriveSmart.stop(); @@ -142,8 +125,7 @@ void driveIN(float dist, directionType dir,float volt) { } // define auton routines here -void rightAutonRight(void) { - // right auton code goes here +void RARNR(void) { // open claw, drive forward to neutral mogo, latch on and lift frontHook.set(false); driveIN(47,directionType::fwd,12.0); @@ -156,10 +138,9 @@ void rightAutonRight(void) { ringLift.spinFor(3,timeUnits::sec,100,velocityUnits::pct); } -void skillsAuton(void) { +void SKILL(void) { frontHook.set(false); driveIN(10,directionType::fwd,55); - //rearMogo.spinTo(-700,rotationUnits::deg); // Depreciated [DELETE] driveIN(11,directionType::rev,55); rearHook.set(true); ringLift.spinFor(2,timeUnits::sec,100,velocityUnits::pct); @@ -187,8 +168,7 @@ void skillsAuton(void) { } -void leftAutonNoWP(void){ - //rearMogo.spinTo(-650,rotationUnits::deg,200, velocityUnits::pct,false); //Depreciated [DELETE] +void LANWP(void){ driveIN(47,directionType::fwd,12.0); frontHook.set(true); frontMogo.spinTo(110,rotationUnits::deg); @@ -201,21 +181,21 @@ void leftAutonNoWP(void){ driveIN(30,directionType::rev,70); } -void rightAutonNoWP(void){ +void RANWP(void){ // open claw, drive forward to neutral mogo, latch on and lift driveIN(55,directionType::fwd,150); frontHook.set(true); - frontMogo.spinFor(150,rotationUnits::deg,false); - InertialRight(45); - driveIN(15,directionType::rev,12.0); - InertialRight(50); - driveIN(20,directionType::rev,12.0); + frontMogo.setBrake(brakeType::hold); + frontMogo.startSpinTo(800,rotationUnits::deg); + InertialRight(35); + driveIN(25,directionType::rev,12.0); + InertialRight(65); + driveIN(20,directionType::rev,7.0); rearHook.set(true); - InertialRight(45); driveIN(50,directionType::fwd,12.0); } -void speedyAuton(void) { +void SPEED(void) { Controller1.Screen.print(" PRANKD LOL"); driveIN(47,directionType::fwd,12.0); LeftDriveSmart.spin(directionType::rev,200,velocityUnits::pct); @@ -224,12 +204,13 @@ void speedyAuton(void) { frontMogo.spinFor(90,rotationUnits::deg,false); } -void zach1(){ +void RARWR(){ // Start on right, grab right neutral with front, grab alliance goal with back, load with rings from field frontHook.set(false); driveIN(47,directionType::fwd,12.0); frontHook.set(true); - frontMogo.startSpinTo(800,rotationUnits::deg); + frontMogo.setBrake(brakeType::hold); + frontMogo.startSpinTo(800,rotationUnits::deg,200,velocityUnits::pct); driveIN(50,directionType::rev,12.0); InertialLeft(125); driveIN(17,directionType::rev,7.0); @@ -243,41 +224,39 @@ void zach1(){ driveIN(55,directionType::fwd,5.5); driveIN(55,directionType::rev,5.5); InertialLeft(180); - ringLift.stop(); } -void zach2(){ +void RACWR(){ // start on right, grab yellow center with front, grab alliance goal with rear, load with rings from field driveIN(60,directionType::fwd,12.0); frontHook.set(true); - frontMogo.startSpinTo(400,rotationUnits::deg,200,velocityUnits::pct); + frontMogo.setBrake(brakeType::hold); + frontMogo.startSpinTo(800,rotationUnits::deg,200,velocityUnits::pct); driveIN(43,directionType::rev,12.0); task::sleep(500); InertialLeft(42.5); driveIN(15,directionType::rev,7.0); rearHook.set(true); driveIN(5,directionType::fwd,12.0); - InertialRight(92.5); - ringLift.spin(fwd,12.0,voltageUnits::volt); - driveIN(60,directionType::fwd,7.0); + InertialRight(95); + ringLift.spin(directionType::fwd,12.0,voltageUnits::volt); + driveIN(55,directionType::fwd,7.0); driveIN(70,directionType::rev,12.0); } -#define MANUAL zach3 - -void zach3(){ +void LALWR(){ // this routine is still very much a work in progress, so don't be supprised if it doesn't perform as expected // start on left, speed for left yellow, back up to alliance on platform, grab, load with match load rings driveIN(48,directionType::fwd,12.0); frontHook.set(true); frontMogo.startSpinTo(800,rotationUnits::deg); - driveIN(24,directionType::rev,12.0); + driveIN(34,directionType::rev,12.0); InertialRight(10); - driveIN(25,directionType::rev,7.0); - InertialLeft(115); - //drive2obs(directionType::fwd); - driveIN(1,directionType::rev,6.0); - drive2obs(directionType::rev); + driveIN(15,directionType::rev,6.0); + InertialLeft(120); + drive2obs(directionType::fwd); + driveIN(26,directionType::rev,6.0); + task::sleep(500); rearHook.set(true); driveIN(20,directionType::fwd,7.0); InertialLeft(90); @@ -285,35 +264,78 @@ void zach3(){ driveIN(24,directionType::fwd,7.0); } -void zach4(){ +void RADWA(){ // start on right, speed for right yellow with front, grab center yellow with back, place center yellow in corner, grab alliance with back, get field rings -} + driveIN(55,directionType::fwd,150); + frontHook.set(true); + frontMogo.setBrake(brakeType::hold); + frontMogo.startSpinTo(800,rotationUnits::deg); + InertialRight(35); + driveIN(25,directionType::rev,12.0); + InertialRight(65); + driveIN(18,directionType::rev,7.0); -void zach5(){ - // start on right, speed for center, back up to alliance, load with field rings, grab right yellow with front + LeftDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); + RightDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); + LeftDriveSmart.resetPosition(); + RightDriveSmart.resetPosition(); + // 5.75 in/rot + + waitUntil(LeftDriveSmart.position(rotationUnits::rev)<2.875 && RightDriveSmart.position(rotationUnits::rev)<2.875); + rearHook.set(true); + waitUntil(LeftDriveSmart.position(rotationUnits::rev)<3.5 && RightDriveSmart.position(rotationUnits::rev)<3.5); + + driveIN(32,directionType::fwd,12.0); + InertialLeft(110); + driveIN(12,directionType::rev,7.0); + rearHook.set(false); + task::sleep(1000); + InertialLeft(85); + drive2obs(directionType::rev); + rearHook.set(true); + ringLift.spin(directionType::fwd,12.0,voltageUnits::volt); } -void zach6(){ - // same as 5, but fake dash for right goal instead of center -} +void RACRF(){ + // same as 2, but fake for right goal instead of center + InertialLeft(30); + driveIN(60,directionType::fwd,12.0); + frontHook.set(true); + frontMogo.setBrake(brakeType::hold); + frontMogo.startSpinTo(800,rotationUnits::deg,200,velocityUnits::pct); + driveIN(43,directionType::rev,12.0); + task::sleep(500); + InertialLeft(42.5); -void zach7(){ - // start on left, fake for left yellow, go for center, bring it back, grab alliance with rear lift, load with match loads + LeftDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); + RightDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); + task::sleep(100); + LeftDriveSmart.spin(directionType::rev,8.0,voltageUnits::volt); + RightDriveSmart.spin(directionType::rev,8.0,voltageUnits::volt); + task::sleep(100); + LeftDriveSmart.spin(directionType::rev,10.0,voltageUnits::volt); + RightDriveSmart.spin(directionType::rev,10.0,voltageUnits::volt); + task::sleep(100); + drive2obs(directionType::rev); + + rearHook.set(true); + driveIN(5,directionType::fwd,12.0); + InertialRight(100); + ringLift.spin(fwd,12.0,voltageUnits::volt); + driveIN(50,directionType::fwd,7.0); + driveIN(60,directionType::rev,12.0); } -void zach8(){ - // open slot for future expansion +void LACFR(){ + // start on left, fake for left yellow, go for center, bring it back, grab alliance with rear lift, load with match loads } -// now that autons are defined, we can define the auton selection code -/* This code is REALLY messed up, don't uncomment it unless you are some sort of wizzard who magicaly fixes code -std::function autonSelect(){ +int autonSelect(){ bool waitForComplete = true; int autonIndex = 0; - std::string autonRoutes [13] = {"LANWP","SPEED","RANWP","RARNR","SKILL","ZACH1","ZACH2","ZACH3","ZACH4","ZACH5","ZACH6","ZACH7","ZACH8"}; - void (*functptr[])() = {&leftAutonNoWP,&speedyAuton,&rightAutonNoWP,&rightAutonRight,&skillsAuton,&zach1,&zach2,&zach3,&zach4,&zach5,&zach6,&zach7,&zach8}; + std::string autonRoutes [11] = {"LANWP","SPEED","RANWP","RARNR","SKILL","RARWR","RACWR","LALWR","RADWA","RACRF","LACFR"}; while(waitForComplete){ if (Controller1.ButtonUp.pressing()){ @@ -335,14 +357,14 @@ std::function autonSelect(){ } // prevent overflow - autonIndex = autonIndex < 0 ? autonIndex+13 : autonIndex; - autonIndex = autonIndex > 12 ? 0 : autonIndex; + autonIndex = autonIndex < 0 ? autonIndex+11 : autonIndex; + autonIndex = autonIndex > 10 ? 0 : autonIndex; } - Controller1.Screen.setCursor(4, 1); - return zach3; + return autonIndex; } -*/ + +#define MANUAL RACRF // define pre-auton routine here void pre_auton(void) { @@ -415,16 +437,53 @@ void usercontrol(void) { int main() { // run the pre-auton routine pre_auton(); - // Manualy select an auton - Competition.autonomous(MANUAL); - // Autonomous Selection - //Competition.autonomous(pls help!); + // Select an auton + //Competition.autonomous(MANUAL); + int testfoo =autonSelect(); + printf("%i",testfoo); + switch(testfoo){ + case 0: + Competition.autonomous(LANWP); + break; + case 1: + Competition.autonomous(SPEED); + break; + case 2: + Competition.autonomous(RANWP); + break; + case 3: + Competition.autonomous(RARNR); + break; + case 4: + Competition.autonomous(SKILL); + break; + case 5: + Competition.autonomous(RARWR); + break; + case 6: + Competition.autonomous(RACWR); + break; + case 7: + Competition.autonomous(LALWR); + break; + case 8: + Competition.autonomous(RADWA); + break; + case 9: + Competition.autonomous(RACRF); + break; + case 10: + Competition.autonomous(LACFR); + break; + default: + Competition.autonomous(RARWR); + } + // Set up callbacks for driver control period. Competition.drivercontrol(usercontrol); // Prevent main from exiting with an infinite loop. while(true) { task::sleep(100); - printf("LEFT: %f RIGHT: %f\n",LeftDriveSmart.velocity(percentUnits::pct),RightDriveSmart.velocity(percentUnits::pct)); } } diff --git a/src/robot-config.cpp b/src/robot-config.cpp index 72c9cbc..5151862 100644 --- a/src/robot-config.cpp +++ b/src/robot-config.cpp @@ -11,7 +11,7 @@ brain Brain; controller Controller1 = controller(primary); inertial inertialSensor = inertial(PORT10); digital_out frontHook = digital_out(Brain.ThreeWirePort.H); -motor frontMogo = motor(PORT7, ratio36_1, true); +motor frontMogo = motor(PORT20, ratio36_1, true); motor ringLift = motor(PORT11, ratio6_1, false); motor LeftDriveSmartA = motor(PORT1, ratio6_1, true); motor LeftDriveSmartB = motor(PORT3, ratio6_1, false); From 62f815943c024f22bd12b81f6b1ac3ab586f376c Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Mon, 25 Apr 2022 15:44:14 -0400 Subject: [PATCH 07/14] Finalize some auton routines Z3 and Z6 need work still --- src/main.cpp | 59 ++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 091a3e0..5cbb595 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -139,33 +139,7 @@ void RARNR(void) { } void SKILL(void) { - frontHook.set(false); - driveIN(10,directionType::fwd,55); - driveIN(11,directionType::rev,55); - rearHook.set(true); - ringLift.spinFor(2,timeUnits::sec,100,velocityUnits::pct); - driveIN(10,directionType::fwd,55); - InertialRight(95); - driveIN(50,directionType::fwd,55); - frontHook.set(true); - frontMogo.spinFor(300,rotationUnits::deg); - InertialRight(10); - driveIN(30,directionType::fwd,55); - frontMogo.spinFor(-300,rotationUnits::deg); - frontHook.set(false); - InertialLeft(90); - rearHook.set(false); - driveIN(10,directionType::fwd,55); - InertialRight(180); - driveIN(13,directionType::rev,55); - rearHook.set(true); - InertialRight(11); - driveIN(45,directionType::fwd,55); - frontHook.set(true); - driveIN(35,directionType::fwd,55); - InertialRight(45); - drive2obs(directionType::fwd); - + // insert camden code here } void LANWP(void){ @@ -320,7 +294,7 @@ void RACRF(){ rearHook.set(true); driveIN(5,directionType::fwd,12.0); - InertialRight(100); + InertialRight(115); ringLift.spin(fwd,12.0,voltageUnits::volt); driveIN(50,directionType::fwd,7.0); driveIN(60,directionType::rev,12.0); @@ -328,6 +302,22 @@ void RACRF(){ void LACFR(){ // start on left, fake for left yellow, go for center, bring it back, grab alliance with rear lift, load with match loads + InertialRight(25); + + ringLift.spin(directionType::fwd,12.0,voltageUnits::volt); + frontMogo.startSpinTo(200, rotationUnits::deg, 200, velocityUnits::pct); + driveIN(30,directionType::fwd,12.0); + driveIN(30,directionType::fwd,3.0); + frontMogo.startSpinTo(0, rotationUnits::deg, 200, velocityUnits::pct); + driveIN(15,directionType::fwd,6.0); + frontHook.set(true); + frontMogo.startSpinTo(300, rotationUnits::deg, 200, velocityUnits::pct); + + driveIN(70,directionType::rev,12.0); + InertialLeft(100); + + drive2obs(directionType::rev); + rearHook.set(true); } int autonSelect(){ @@ -364,8 +354,6 @@ int autonSelect(){ return autonIndex; } -#define MANUAL RACRF - // define pre-auton routine here void pre_auton(void) { // Initializing Robot Configuration. DO NOT REMOVE! @@ -433,12 +421,19 @@ void usercontrol(void) { } } +#define ROUTE RARNR + +#ifndef ROUTE +#define ROUTE autonSelect +#endif + // main() called on program start int main() { // run the pre-auton routine pre_auton(); // Select an auton - //Competition.autonomous(MANUAL); + Competition.autonomous(ROUTE); + /* int testfoo =autonSelect(); printf("%i",testfoo); switch(testfoo){ @@ -478,7 +473,7 @@ int main() { default: Competition.autonomous(RARWR); } - + */ // Set up callbacks for driver control period. Competition.drivercontrol(usercontrol); // Prevent main from exiting with an infinite loop. From c1d8d87932bfa78441f6abc3cd20758ce05e1cdc Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:14:29 -0400 Subject: [PATCH 08/14] Continue to work on auton selector. I'm getting somewhere, but it just isn't working quite right. --- src/main.cpp | 97 +++++++++++++++++----------------------------------- 1 file changed, 31 insertions(+), 66 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5cbb595..e58899e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -320,14 +320,29 @@ void LACFR(){ rearHook.set(true); } -int autonSelect(){ +// define pre-auton routine here +void pre_auton(void) { + // Initializing Robot Configuration. DO NOT REMOVE! + vexcodeInit(); + // Reset important encoders, close the front claw, and open the back + frontHook.set(false); + rearHook.set(false); + frontMogo.resetPosition(); + // Calibrate Inertial and wait until complete + inertialSensor.startCalibration(); + waitUntil(!inertialSensor.isCalibrating()); +} - bool waitForComplete = true; - int autonIndex = 0; +/* Super Fancy Auton Selector (C) Anthony Halliday, 2022, Under the license "pls dont steal my code, thx" */ - std::string autonRoutes [11] = {"LANWP","SPEED","RANWP","RARNR","SKILL","RARWR","RACWR","LALWR","RADWA","RACRF","LACFR"}; - - while(waitForComplete){ +std::string autonRoutes [11] = {"LANWP","SPEED","RANWP","RARNR","SKILL","RARWR","RACWR","LALWR","RADWA","RACRF","LACFR"}; +int autonIndex = 0; + +typedef void (*autonPointer)(); +autonPointer autonPointers [11] = {LANWP,SPEED,RANWP,RARNR,SKILL,RARWR,RACWR,LALWR,RADWA,RACRF,LACFR}; + +autonPointer autonSelect(){ + while(true){ if (Controller1.ButtonUp.pressing()){ autonIndex++; waitUntil(!Controller1.ButtonUp.pressing()); @@ -339,7 +354,7 @@ int autonSelect(){ else if (Controller1.ButtonX.pressing()) { Controller1.Screen.setCursor(4, 1); Controller1.Screen.print("= %s",autonRoutes[autonIndex].c_str()); - waitForComplete = false; + goto escape; } else{ Controller1.Screen.print("> %s",autonRoutes[autonIndex].c_str()); @@ -351,21 +366,12 @@ int autonSelect(){ autonIndex = autonIndex > 10 ? 0 : autonIndex; } - return autonIndex; + escape: + Brain.Screen.print("%x",autonIndex); + return autonPointers[autonIndex]; } -// define pre-auton routine here -void pre_auton(void) { - // Initializing Robot Configuration. DO NOT REMOVE! - vexcodeInit(); - // Reset important encoders, close the front claw, and open the back - frontHook.set(false); - rearHook.set(false); - frontMogo.resetPosition(); - // Calibrate Inertial and wait until complete - inertialSensor.startCalibration(); - waitUntil(!inertialSensor.isCalibrating()); -} +/* End Super Fancy auton selector */ // define user control code here void pneumaticSwitchFront(void) { @@ -423,57 +429,16 @@ void usercontrol(void) { #define ROUTE RARNR -#ifndef ROUTE -#define ROUTE autonSelect -#endif - // main() called on program start int main() { // run the pre-auton routine pre_auton(); // Select an auton - Competition.autonomous(ROUTE); - /* - int testfoo =autonSelect(); - printf("%i",testfoo); - switch(testfoo){ - case 0: - Competition.autonomous(LANWP); - break; - case 1: - Competition.autonomous(SPEED); - break; - case 2: - Competition.autonomous(RANWP); - break; - case 3: - Competition.autonomous(RARNR); - break; - case 4: - Competition.autonomous(SKILL); - break; - case 5: - Competition.autonomous(RARWR); - break; - case 6: - Competition.autonomous(RACWR); - break; - case 7: - Competition.autonomous(LALWR); - break; - case 8: - Competition.autonomous(RADWA); - break; - case 9: - Competition.autonomous(RACRF); - break; - case 10: - Competition.autonomous(LACFR); - break; - default: - Competition.autonomous(RARWR); - } - */ + autonPointer route = autonSelect(); + Competition.autonomous(route); + Brain.Screen.print("Done! (hopefully)"); + // The auton selector is being held together by chewing gum and a shoestring, so if it breaks, not my fault + // Set up callbacks for driver control period. Competition.drivercontrol(usercontrol); // Prevent main from exiting with an infinite loop. From 56d2d278ea42511a3722040eaf374c75440135bd Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Wed, 27 Apr 2022 15:51:45 -0400 Subject: [PATCH 09/14] Cleaned up code Got rid of some unused routines and tried working on auton selector to no avail. Also added temperature alerts --- src/main.cpp | 261 ++++++++++++++++++++++----------------------------- 1 file changed, 111 insertions(+), 150 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e58899e..ca344bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,7 @@ using namespace vex; competition Competition; +// Manualy create a motor group because the vex config wizzard can't have more than two motors for some reason motor_group LeftDriveSmart = motor_group(LeftDriveSmartA, LeftDriveSmartB, LeftDriveSmartC); motor_group RightDriveSmart = motor_group(RightDriveSmartA, RightDriveSmartB, RightDriveSmartC); @@ -26,7 +27,7 @@ float heading; #define MAXVELOCITY 40 #define MINVELOCITY 10 -// define functions here +// Essential driving functions void drive2obs(directionType dir){ LeftDriveSmart.spin(dir,12.0,voltageUnits::volt); RightDriveSmart.spin(dir,12.0,voltageUnits::volt); @@ -125,37 +126,21 @@ void driveIN(float dist, directionType dir,float volt) { } // define auton routines here -void RARNR(void) { - // open claw, drive forward to neutral mogo, latch on and lift - frontHook.set(false); - driveIN(47,directionType::fwd,12.0); - frontMogo.spinFor(150,rotationUnits::deg,false); - frontHook.set(true); - driveIN(15,directionType::rev,12.0); - InertialLeft(40); - driveIN(20,directionType::rev,12.0); - rearHook.set(true); - ringLift.spinFor(3,timeUnits::sec,100,velocityUnits::pct); -} - -void SKILL(void) { +void SKILL() { // insert camden code here } -void LANWP(void){ +void SPEED() { + Controller1.Screen.print(" PRANKD LOL"); driveIN(47,directionType::fwd,12.0); + LeftDriveSmart.spin(directionType::rev,200,velocityUnits::pct); + RightDriveSmart.spin(directionType::rev,200,velocityUnits::pct); frontHook.set(true); - frontMogo.spinTo(110,rotationUnits::deg); - InertialLeft(95); - driveIN(27,directionType::rev,30); - rearHook.set(true); - InertialLeft(45); - driveIN(30,directionType::fwd,70); - InertialRight(180); - driveIN(30,directionType::rev,70); + frontMogo.spinFor(90,rotationUnits::deg,false); } -void RANWP(void){ +// Right Side +void RANWP(){ // open claw, drive forward to neutral mogo, latch on and lift driveIN(55,directionType::fwd,150); frontHook.set(true); @@ -169,13 +154,49 @@ void RANWP(void){ driveIN(50,directionType::fwd,12.0); } -void SPEED(void) { - Controller1.Screen.print(" PRANKD LOL"); +void RADWA(){ + // start on right, speed for right yellow with front, grab center yellow with back, place center yellow in corner, grab alliance with back, get field rings + driveIN(55,directionType::fwd,150); + frontHook.set(true); + frontMogo.setBrake(brakeType::hold); + frontMogo.startSpinTo(800,rotationUnits::deg); + InertialRight(35); + driveIN(25,directionType::rev,12.0); + InertialRight(65); + driveIN(18,directionType::rev,7.0); + + LeftDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); + RightDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); + LeftDriveSmart.resetPosition(); + RightDriveSmart.resetPosition(); + // 5.75 in/rot + + waitUntil(LeftDriveSmart.position(rotationUnits::rev)<2.875 && RightDriveSmart.position(rotationUnits::rev)<2.875); + rearHook.set(true); + waitUntil(LeftDriveSmart.position(rotationUnits::rev)<3.5 && RightDriveSmart.position(rotationUnits::rev)<3.5); + + driveIN(32,directionType::fwd,12.0); + InertialLeft(110); + driveIN(12,directionType::rev,7.0); + rearHook.set(false); + task::sleep(1000); + InertialLeft(85); + drive2obs(directionType::rev); + rearHook.set(true); + ringLift.spin(directionType::fwd,12.0,voltageUnits::volt); +} + +void RARNR() { + // open claw, drive forward to neutral mogo, latch on and lift + frontHook.set(false); driveIN(47,directionType::fwd,12.0); - LeftDriveSmart.spin(directionType::rev,200,velocityUnits::pct); - RightDriveSmart.spin(directionType::rev,200,velocityUnits::pct); + frontMogo.spinFor(150,rotationUnits::deg,false); frontHook.set(true); - frontMogo.spinFor(90,rotationUnits::deg,false); + driveIN(15,directionType::rev,12.0); + InertialLeft(40); + driveIN(20,directionType::rev,12.0); + rearHook.set(true); + ringLift.spinFor(3,timeUnits::sec,100,velocityUnits::pct); } void RARWR(){ @@ -218,60 +239,8 @@ void RACWR(){ driveIN(70,directionType::rev,12.0); } -void LALWR(){ - // this routine is still very much a work in progress, so don't be supprised if it doesn't perform as expected - // start on left, speed for left yellow, back up to alliance on platform, grab, load with match load rings - driveIN(48,directionType::fwd,12.0); - frontHook.set(true); - frontMogo.startSpinTo(800,rotationUnits::deg); - driveIN(34,directionType::rev,12.0); - InertialRight(10); - driveIN(15,directionType::rev,6.0); - InertialLeft(120); - drive2obs(directionType::fwd); - driveIN(26,directionType::rev,6.0); - task::sleep(500); - rearHook.set(true); - driveIN(20,directionType::fwd,7.0); - InertialLeft(90); - driveIN(24,directionType::rev,12.0); - driveIN(24,directionType::fwd,7.0); -} - -void RADWA(){ - // start on right, speed for right yellow with front, grab center yellow with back, place center yellow in corner, grab alliance with back, get field rings - driveIN(55,directionType::fwd,150); - frontHook.set(true); - frontMogo.setBrake(brakeType::hold); - frontMogo.startSpinTo(800,rotationUnits::deg); - InertialRight(35); - driveIN(25,directionType::rev,12.0); - InertialRight(65); - driveIN(18,directionType::rev,7.0); - - LeftDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); - RightDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); - LeftDriveSmart.resetPosition(); - RightDriveSmart.resetPosition(); - // 5.75 in/rot - - waitUntil(LeftDriveSmart.position(rotationUnits::rev)<2.875 && RightDriveSmart.position(rotationUnits::rev)<2.875); - rearHook.set(true); - waitUntil(LeftDriveSmart.position(rotationUnits::rev)<3.5 && RightDriveSmart.position(rotationUnits::rev)<3.5); - - driveIN(32,directionType::fwd,12.0); - InertialLeft(110); - driveIN(12,directionType::rev,7.0); - rearHook.set(false); - task::sleep(1000); - InertialLeft(85); - drive2obs(directionType::rev); - rearHook.set(true); - ringLift.spin(directionType::fwd,12.0,voltageUnits::volt); -} - void RACRF(){ - // same as 2, but fake for right goal instead of center + // same as RACWR, but fake for right goal instead of center InertialLeft(30); driveIN(60,directionType::fwd,12.0); frontHook.set(true); @@ -300,7 +269,41 @@ void RACRF(){ driveIN(60,directionType::rev,12.0); } -void LACFR(){ +// Left side +void LANWP(){ + driveIN(47,directionType::fwd,12.0); + frontHook.set(true); + frontMogo.spinTo(110,rotationUnits::deg); + InertialLeft(95); + driveIN(27,directionType::rev,30); + rearHook.set(true); + InertialLeft(45); + driveIN(30,directionType::fwd,70); + InertialRight(180); + driveIN(30,directionType::rev,70); +} + +void LALWR(){ + // this routine is still very much a work in progress, so don't be supprised if it doesn't perform as expected + // start on left, speed for left yellow, back up to alliance on platform, grab, load with match load rings + driveIN(48,directionType::fwd,12.0); + frontHook.set(true); + frontMogo.startSpinTo(800,rotationUnits::deg); + driveIN(34,directionType::rev,12.0); + InertialRight(10); + driveIN(15,directionType::rev,6.0); + InertialLeft(120); + drive2obs(directionType::fwd); + driveIN(26,directionType::rev,6.0); + task::sleep(500); + rearHook.set(true); + driveIN(20,directionType::fwd,7.0); + InertialLeft(90); + driveIN(24,directionType::rev,12.0); + driveIN(24,directionType::fwd,7.0); +} + +void LACRF(){ // start on left, fake for left yellow, go for center, bring it back, grab alliance with rear lift, load with match loads InertialRight(25); @@ -320,61 +323,8 @@ void LACFR(){ rearHook.set(true); } -// define pre-auton routine here -void pre_auton(void) { - // Initializing Robot Configuration. DO NOT REMOVE! - vexcodeInit(); - // Reset important encoders, close the front claw, and open the back - frontHook.set(false); - rearHook.set(false); - frontMogo.resetPosition(); - // Calibrate Inertial and wait until complete - inertialSensor.startCalibration(); - waitUntil(!inertialSensor.isCalibrating()); -} - -/* Super Fancy Auton Selector (C) Anthony Halliday, 2022, Under the license "pls dont steal my code, thx" */ - -std::string autonRoutes [11] = {"LANWP","SPEED","RANWP","RARNR","SKILL","RARWR","RACWR","LALWR","RADWA","RACRF","LACFR"}; -int autonIndex = 0; - -typedef void (*autonPointer)(); -autonPointer autonPointers [11] = {LANWP,SPEED,RANWP,RARNR,SKILL,RARWR,RACWR,LALWR,RADWA,RACRF,LACFR}; - -autonPointer autonSelect(){ - while(true){ - if (Controller1.ButtonUp.pressing()){ - autonIndex++; - waitUntil(!Controller1.ButtonUp.pressing()); - } - else if (Controller1.ButtonDown.pressing()){ - autonIndex--; - waitUntil(!Controller1.ButtonDown.pressing()); - } - else if (Controller1.ButtonX.pressing()) { - Controller1.Screen.setCursor(4, 1); - Controller1.Screen.print("= %s",autonRoutes[autonIndex].c_str()); - goto escape; - } - else{ - Controller1.Screen.print("> %s",autonRoutes[autonIndex].c_str()); - Controller1.Screen.setCursor(4, 1); - } - - // prevent overflow - autonIndex = autonIndex < 0 ? autonIndex+11 : autonIndex; - autonIndex = autonIndex > 10 ? 0 : autonIndex; - - } - escape: - Brain.Screen.print("%x",autonIndex); - return autonPointers[autonIndex]; -} - -/* End Super Fancy auton selector */ - // define user control code here -void pneumaticSwitchFront(void) { +void pneumaticSwitchFront() { // on button press, check if driver control is active, then if front hook is pressurized, depresurize, otherwise, pressurize if(competition().isDriverControl()){ if(frontHook.value()) { @@ -386,7 +336,7 @@ void pneumaticSwitchFront(void) { } } -void usercontrol(void) { +void usercontrol() { // Bind button x to front hook Controller1.ButtonX.pressed(pneumaticSwitchFront); while(true) { @@ -427,23 +377,34 @@ void usercontrol(void) { } } -#define ROUTE RARNR - // main() called on program start int main() { - // run the pre-auton routine - pre_auton(); - // Select an auton - autonPointer route = autonSelect(); - Competition.autonomous(route); - Brain.Screen.print("Done! (hopefully)"); - // The auton selector is being held together by chewing gum and a shoestring, so if it breaks, not my fault + // Initializing Robot Configuration. DO NOT REMOVE! + vexcodeInit(); + + // BIG FONT so everyone can read my debug status + Brain.Screen.setFont(fontType::mono60); + + // Reset important encoders, open the front claw, and close the back claw + frontHook.set(false); + rearHook.set(true); + frontMogo.resetPosition(); + + // Calibrate Inertial and wait until complete + inertialSensor.startCalibration(); + waitUntil(!inertialSensor.isCalibrating()); + + // Super Fancy Auton Selector (C) Anthony Halliday, 2022, Under the license "pls dont steal my code, thx" + // jk lol, its just completley broken, welcome to vex! - // Set up callbacks for driver control period. + // Set up driver control period. Competition.drivercontrol(usercontrol); + // Prevent main from exiting with an infinite loop. while(true) { - task::sleep(100); + if (LeftDriveSmart.temperature(temperatureUnits::celsius)>50 || RightDriveSmart.temperature(temperatureUnits::celsius)>50){ + Controller1.rumble(".. .. .. "); + } } } From 0c3f453c19d86535e84b2f026add9997cbc15876 Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Thu, 28 Apr 2022 15:19:37 -0400 Subject: [PATCH 10/14] Continued work on autons All autons except skills and left side routes are done --- src/main.cpp | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ca344bc..8f3aee6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -127,10 +127,12 @@ void driveIN(float dist, directionType dir,float volt) { // define auton routines here void SKILL() { + rearHook.set(false); // insert camden code here } void SPEED() { + rearHook.set(false); Controller1.Screen.print(" PRANKD LOL"); driveIN(47,directionType::fwd,12.0); LeftDriveSmart.spin(directionType::rev,200,velocityUnits::pct); @@ -141,6 +143,7 @@ void SPEED() { // Right Side void RANWP(){ + rearHook.set(false); // open claw, drive forward to neutral mogo, latch on and lift driveIN(55,directionType::fwd,150); frontHook.set(true); @@ -155,6 +158,7 @@ void RANWP(){ } void RADWA(){ + rearHook.set(false); // start on right, speed for right yellow with front, grab center yellow with back, place center yellow in corner, grab alliance with back, get field rings driveIN(55,directionType::fwd,150); frontHook.set(true); @@ -187,6 +191,7 @@ void RADWA(){ } void RARNR() { + rearHook.set(false); // open claw, drive forward to neutral mogo, latch on and lift frontHook.set(false); driveIN(47,directionType::fwd,12.0); @@ -196,10 +201,12 @@ void RARNR() { InertialLeft(40); driveIN(20,directionType::rev,12.0); rearHook.set(true); + InertialRight(10); ringLift.spinFor(3,timeUnits::sec,100,velocityUnits::pct); } void RARWR(){ + rearHook.set(false); // Start on right, grab right neutral with front, grab alliance goal with back, load with rings from field frontHook.set(false); driveIN(47,directionType::fwd,12.0); @@ -218,10 +225,11 @@ void RARWR(){ ringLift.setVelocity(200, percentUnits::pct); driveIN(55,directionType::fwd,5.5); driveIN(55,directionType::rev,5.5); - InertialLeft(180); + InertialLeft(200); } void RACWR(){ + rearHook.set(false); // start on right, grab yellow center with front, grab alliance goal with rear, load with rings from field driveIN(60,directionType::fwd,12.0); frontHook.set(true); @@ -240,15 +248,16 @@ void RACWR(){ } void RACRF(){ + rearHook.set(false); // same as RACWR, but fake for right goal instead of center InertialLeft(30); - driveIN(60,directionType::fwd,12.0); + driveIN(65,directionType::fwd,7.0); frontHook.set(true); frontMogo.setBrake(brakeType::hold); frontMogo.startSpinTo(800,rotationUnits::deg,200,velocityUnits::pct); - driveIN(43,directionType::rev,12.0); + driveIN(42,directionType::rev,12.0); task::sleep(500); - InertialLeft(42.5); + InertialLeft(40); LeftDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); RightDriveSmart.spin(directionType::rev,6.0,voltageUnits::volt); @@ -261,9 +270,10 @@ void RACRF(){ task::sleep(100); drive2obs(directionType::rev); + task::sleep(500); rearHook.set(true); driveIN(5,directionType::fwd,12.0); - InertialRight(115); + InertialRight(95); ringLift.spin(fwd,12.0,voltageUnits::volt); driveIN(50,directionType::fwd,7.0); driveIN(60,directionType::rev,12.0); @@ -271,19 +281,25 @@ void RACRF(){ // Left side void LANWP(){ + rearHook.set(false); driveIN(47,directionType::fwd,12.0); frontHook.set(true); - frontMogo.spinTo(110,rotationUnits::deg); - InertialLeft(95); - driveIN(27,directionType::rev,30); + frontMogo.startSpinTo(110,rotationUnits::deg); + + InertialLeft(35); + driveIN(25,directionType::rev,12.0); + InertialLeft(110); + driveIN(30,directionType::rev,7.0); + rearHook.set(true); - InertialLeft(45); + InertialRight(15); driveIN(30,directionType::fwd,70); InertialRight(180); driveIN(30,directionType::rev,70); } void LALWR(){ + rearHook.set(false); // this routine is still very much a work in progress, so don't be supprised if it doesn't perform as expected // start on left, speed for left yellow, back up to alliance on platform, grab, load with match load rings driveIN(48,directionType::fwd,12.0); @@ -304,6 +320,7 @@ void LALWR(){ } void LACRF(){ + rearHook.set(false); // start on left, fake for left yellow, go for center, bring it back, grab alliance with rear lift, load with match loads InertialRight(25); @@ -384,6 +401,7 @@ int main() { // BIG FONT so everyone can read my debug status Brain.Screen.setFont(fontType::mono60); + Brain.Screen.setFillColor("red"); // Reset important encoders, open the front claw, and close the back claw frontHook.set(false); @@ -395,6 +413,7 @@ int main() { waitUntil(!inertialSensor.isCalibrating()); // Super Fancy Auton Selector (C) Anthony Halliday, 2022, Under the license "pls dont steal my code, thx" + Competition.autonomous(LANWP); // jk lol, its just completley broken, welcome to vex! // Set up driver control period. @@ -402,9 +421,15 @@ int main() { // Prevent main from exiting with an infinite loop. while(true) { - if (LeftDriveSmart.temperature(temperatureUnits::celsius)>50 || RightDriveSmart.temperature(temperatureUnits::celsius)>50){ - Controller1.rumble(".. .. .. "); + if (LeftDriveSmart.temperature(temperatureUnits::celsius)>50 || RightDriveSmart.temperature(temperatureUnits::celsius)>50,true){ + Controller1.rumble("---"); + Controller1.Screen.clearLine(4); + Controller1.Screen.print(" OVERHEAT "); + Brain.Screen.drawRectangle(0, 0, 480, 240); + //x=120, y=100 + Brain.Screen.printAt(120,100,"OVERHEAT"); } + task::sleep(1000); } } From 46f3472cf64e45286c1809dbe4290ede62cf243a Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Fri, 29 Apr 2022 15:38:21 -0400 Subject: [PATCH 11/14] Finish auton selector and overheat alarm --- src/main.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8f3aee6..26c0d84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -133,12 +133,15 @@ void SKILL() { void SPEED() { rearHook.set(false); - Controller1.Screen.print(" PRANKD LOL"); + Brain.Screen.setFont(fontType::mono60); + Brain.Screen.printAt(75,100,"prankd, lol"); driveIN(47,directionType::fwd,12.0); LeftDriveSmart.spin(directionType::rev,200,velocityUnits::pct); RightDriveSmart.spin(directionType::rev,200,velocityUnits::pct); frontHook.set(true); frontMogo.spinFor(90,rotationUnits::deg,false); + task::sleep(10000); + Brain.Screen.clearScreen(); } // Right Side @@ -399,9 +402,9 @@ int main() { // Initializing Robot Configuration. DO NOT REMOVE! vexcodeInit(); - // BIG FONT so everyone can read my debug status + // Set color and font for screen Brain.Screen.setFont(fontType::mono60); - Brain.Screen.setFillColor("red"); + Brain.Screen.setFillColor(red); // Reset important encoders, open the front claw, and close the back claw frontHook.set(false); @@ -413,23 +416,72 @@ int main() { waitUntil(!inertialSensor.isCalibrating()); // Super Fancy Auton Selector (C) Anthony Halliday, 2022, Under the license "pls dont steal my code, thx" - Competition.autonomous(LANWP); + select: + if (Controller1.ButtonUp.pressing()){ + Competition.autonomous(SPEED); + Controller1.Screen.print("SPEED"); + } + else if (Controller1.ButtonDown.pressing()){ + Competition.autonomous(LANWP); + Controller1.Screen.print("LANWP"); + } + else if (Controller1.ButtonLeft.pressing()){ + Competition.autonomous(LALWR); + Controller1.Screen.print("LALWR"); + } + else if (Controller1.ButtonRight.pressing()){ + Competition.autonomous(LACRF); + Controller1.Screen.print("LACRF"); + } + else if (Controller1.ButtonX.pressing()){ + Competition.autonomous(RANWP); + Controller1.Screen.print("RANWP"); + } + else if (Controller1.ButtonY.pressing()){ + Competition.autonomous(RACRF); + Controller1.Screen.print("RACRF"); + } + else if (Controller1.ButtonA.pressing()){ + Competition.autonomous(RACWR); + Controller1.Screen.print("RACWR"); + } + else if (Controller1.ButtonB.pressing()){ + Competition.autonomous(RADWA); + Controller1.Screen.print("RADWA"); + } + else if (Controller1.ButtonL1.pressing()){ + Competition.autonomous(SKILL); + Controller1.Screen.print("SKILL"); + } + else if (Controller1.ButtonR1.pressing()){ + Competition.autonomous(RARNR); + Controller1.Screen.print("RARNR"); + } + else if (Controller1.ButtonR2.pressing()){ + Competition.autonomous(RARWR); + Controller1.Screen.print("RARWR"); + } + else{ + goto select; + } // jk lol, its just completley broken, welcome to vex! - + task::sleep(2000); + Controller1.Screen.clearLine(4); // Set up driver control period. Competition.drivercontrol(usercontrol); // Prevent main from exiting with an infinite loop. while(true) { - if (LeftDriveSmart.temperature(temperatureUnits::celsius)>50 || RightDriveSmart.temperature(temperatureUnits::celsius)>50,true){ - Controller1.rumble("---"); - Controller1.Screen.clearLine(4); - Controller1.Screen.print(" OVERHEAT "); - Brain.Screen.drawRectangle(0, 0, 480, 240); - //x=120, y=100 + if (LeftDriveSmart.temperature(temperatureUnits::celsius)>50 || RightDriveSmart.temperature(temperatureUnits::celsius)>50){ + //Brain.Screen.drawRectangle(0, 0, 480, 240); Brain.Screen.printAt(120,100,"OVERHEAT"); + + while (LeftDriveSmart.temperature(temperatureUnits::celsius)>50 || RightDriveSmart.temperature(temperatureUnits::celsius)>50){ + Controller1.rumble("---"); + } } task::sleep(1000); + } } From b2374bea0547f95e9ba46a4d87684d9122bcd2a8 Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Mon, 2 May 2022 15:31:19 -0400 Subject: [PATCH 12/14] Fix LANWP --- src/main.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 26c0d84..dde2dcf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -290,15 +290,13 @@ void LANWP(){ frontMogo.startSpinTo(110,rotationUnits::deg); InertialLeft(35); - driveIN(25,directionType::rev,12.0); - InertialLeft(110); - driveIN(30,directionType::rev,7.0); + driveIN(20,directionType::rev,12.0); + InertialLeft(115); + driveIN(35,directionType::rev,7.0); rearHook.set(true); - InertialRight(15); - driveIN(30,directionType::fwd,70); - InertialRight(180); - driveIN(30,directionType::rev,70); + InertialLeft(15); + driveIN(60,directionType::fwd,70); } void LALWR(){ From 66a50dc3ff0b54c82651395899bb8936f1670d1c Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Mon, 2 May 2022 15:50:04 -0400 Subject: [PATCH 13/14] Somewhat fixed LALWR --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index dde2dcf..08d2583 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -311,11 +311,11 @@ void LALWR(){ driveIN(15,directionType::rev,6.0); InertialLeft(120); drive2obs(directionType::fwd); - driveIN(26,directionType::rev,6.0); - task::sleep(500); + driveIN(30,directionType::rev,6.0); rearHook.set(true); driveIN(20,directionType::fwd,7.0); InertialLeft(90); + ringLift.spin(directionType::fwd, 12.0, voltageUnits::volt); driveIN(24,directionType::rev,12.0); driveIN(24,directionType::fwd,7.0); } From 81a3aff3a5aed9f14fb97620ae85b0b85f65aad3 Mon Sep 17 00:00:00 2001 From: Anthony Halliday <94485192+aHalliday13@users.noreply.github.com> Date: Mon, 2 May 2022 16:58:24 -0400 Subject: [PATCH 14/14] Worked on LACRF Unfortunatley the routine is just too unstable and sometimes will work amazing, and other times fails miserably. Do not use this routine in competition unless you know that we are going to win and don't want to use any other routines for some reason. --- src/main.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 08d2583..2f0e2f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -332,13 +332,20 @@ void LACRF(){ frontMogo.startSpinTo(0, rotationUnits::deg, 200, velocityUnits::pct); driveIN(15,directionType::fwd,6.0); frontHook.set(true); - frontMogo.startSpinTo(300, rotationUnits::deg, 200, velocityUnits::pct); + frontMogo.startSpinTo(800, rotationUnits::deg, 200, velocityUnits::pct); - driveIN(70,directionType::rev,12.0); - InertialLeft(100); + driveIN(10,directionType::rev,12.0); + driveIN(60,directionType::rev,5.0); + frontMogo.spin(directionType::fwd); + InertialLeft(160); - drive2obs(directionType::rev); + drive2obs(directionType::fwd); + driveIN(40,directionType::rev,5.0); rearHook.set(true); + driveIN(25,directionType::fwd,4.0); + InertialLeft(90); + driveIN(30,directionType::rev,5.0); + driveIN(60,directionType::fwd,5.0); } // define user control code here