robotics is beautiful
final touches - finish wing logic - get respective driver controls implemented - cry a little bit
This commit is contained in:
parent
75022c46de
commit
c2bcd19ab6
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "main.h"
|
||||
#include "Wings.h"
|
||||
|
||||
@ -7,6 +9,8 @@
|
||||
#define DRIVE_RATIO 0.75
|
||||
#define DRIVE_RPM 450
|
||||
|
||||
|
||||
|
||||
namespace globals {
|
||||
extern pros::Controller master;
|
||||
|
||||
@ -33,6 +37,8 @@ namespace globals {
|
||||
extern pros::ADIDigitalOut left_wing_piston;
|
||||
extern pros::ADIDigitalOut right_wing_piston;
|
||||
|
||||
extern pros::ADIDigitalOut intake_piston;
|
||||
|
||||
extern Wings wings;
|
||||
|
||||
extern lemlib::TrackingWheel vert_tracking_wheel;
|
||||
|
||||
@ -4,6 +4,21 @@
|
||||
#define TURN_SPEED 90
|
||||
#define SWING_SPEED 90
|
||||
|
||||
// Renu's control preferences
|
||||
#define RENU_PTO_TOGGLE DIGITAL_R2
|
||||
#define RENU_CATA_CONTROL DIGITAL_R1
|
||||
#define RENU_INTAKE_CONTROL DIGITAL_L1
|
||||
#define RENU_LEFT_WING_CONTROL DIGITAL_LEFT
|
||||
#define RENU_RIGHT_WING_CONTROL DIGITAL_RIGHT
|
||||
#define RENU_WING_CONTROL DIGITAL_L2
|
||||
|
||||
// Ria's control preferences
|
||||
#define RIA_PTO_TOGGLE DIGITAL_LEFT
|
||||
#define RIA_CATA_CONTROL DIGITAL_A
|
||||
#define RIA_INTAKE_CONTORL DIGITAL_R1
|
||||
#define RIA_WINGS_CONTROL DIGITAL_L1
|
||||
|
||||
|
||||
namespace superstruct {
|
||||
//configs
|
||||
void chassisInit();
|
||||
@ -33,9 +48,15 @@ namespace superstruct {
|
||||
void setSwingScale(double val);
|
||||
|
||||
//- Structure methods
|
||||
void intakeControl(pros::controller_digital_e_t intakeButton);
|
||||
void togglePto();
|
||||
void runCata();
|
||||
void cataControl();
|
||||
void cataControl(pros::controller_digital_e_t ptoToggleButton, pros::controller_digital_e_t cataRunButton);
|
||||
void wingsControl();
|
||||
void wingsControlSingle(pros::controller_digital_e_t wingControlButton);
|
||||
void wingsControlComplex(pros::controller_analog_e_t leftWingButton, pros::controller_analog_e_t rightWingButton, pros::controller_analog_e_t wingButton);
|
||||
|
||||
void renu_control();
|
||||
void ria_control();
|
||||
|
||||
}
|
||||
@ -26,6 +26,8 @@ namespace globals {
|
||||
pros::ADIDigitalOut left_wing_piston('C');
|
||||
pros::ADIDigitalOut right_wing_piston('B');
|
||||
|
||||
pros::ADIDigitalOut intake_piston('D');
|
||||
|
||||
Wings wings;
|
||||
|
||||
lemlib::Drivetrain_t chassis_odom {
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
using namespace globals;
|
||||
using namespace superstruct;
|
||||
|
||||
e_controlsch currentuser = RENU;
|
||||
|
||||
/**
|
||||
* A callback function for LLEMU's center button.
|
||||
*
|
||||
@ -97,8 +99,14 @@ void opcontrol() {
|
||||
|
||||
while (true) {
|
||||
chassis.tank_control();
|
||||
superstruct::cataControl();
|
||||
superstruct::wingsControl();
|
||||
|
||||
if (currentuser == RENU) {
|
||||
renu_control();
|
||||
} else if (currentuser = RIA) {
|
||||
ria_control();
|
||||
} else {
|
||||
renu_control();
|
||||
}
|
||||
|
||||
pros::delay(ary::util::DELAY_TIME);
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@ using namespace ary;
|
||||
using namespace globals;
|
||||
|
||||
bool ptoEnabled = false;
|
||||
bool wingsOpen = false;
|
||||
bool intakeEngaged = false;
|
||||
|
||||
double speedScale = 1.0;
|
||||
double turnScale = 1.0;
|
||||
@ -129,6 +131,17 @@ namespace superstruct {
|
||||
}
|
||||
|
||||
// Structure methods
|
||||
void intakeControl(pros::controller_digital_e_t intakeButton) {
|
||||
if (globals::master.get_digital_new_press(intakeButton)) {
|
||||
if (intakeEngaged == false) {
|
||||
intake_piston.set_value(1);
|
||||
intakeEngaged = true;
|
||||
} else if (intakeEngaged == true) {
|
||||
intake_piston.set_value(0);
|
||||
intakeEngaged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void togglePto(bool toggle) {
|
||||
ptoEnabled = toggle;
|
||||
@ -148,15 +161,15 @@ namespace superstruct {
|
||||
}
|
||||
|
||||
int lock = 0;
|
||||
void cataControl() {
|
||||
if (globals::master.get_digital(DIGITAL_LEFT) && lock == 0) {
|
||||
void cataControl(pros::controller_digital_e_t ptoToggleButton, pros::controller_digital_e_t cataRunButton) {
|
||||
if (globals::master.get_digital(ptoToggleButton) && lock == 0) {
|
||||
togglePto(!ptoEnabled);
|
||||
lock = 1;
|
||||
} else if(!globals::master.get_digital(DIGITAL_LEFT)) {
|
||||
} else if(!globals::master.get_digital(ptoToggleButton)) {
|
||||
lock = 0;
|
||||
}
|
||||
|
||||
if (globals::master.get_digital(DIGITAL_R1)) {
|
||||
if (globals::master.get_digital(cataRunButton)) {
|
||||
runCata(-12000);
|
||||
} else {
|
||||
runCata(0);
|
||||
@ -172,4 +185,30 @@ namespace superstruct {
|
||||
wings.close();
|
||||
}
|
||||
}
|
||||
|
||||
void wingsControlComplex(pros::controller_analog_e_t leftWingButton, pros::controller_analog_e_t rightWingButton, pros::controller_analog_e_t wingButton)
|
||||
{
|
||||
|
||||
}
|
||||
void wingsControlSingle(pros::controller_digital_e_t wingControlButton) {
|
||||
if (globals::master.get_digital_new_press(wingControlButton)) {
|
||||
if (wings.getState() == 0)
|
||||
wings.open();
|
||||
else if (wings.getState() == 3)
|
||||
wings.close();
|
||||
}
|
||||
}
|
||||
|
||||
void renu_control() {
|
||||
cataControl(RENU_PTO_TOGGLE, RENU_CATA_CONTROL);
|
||||
wingsControl();
|
||||
intakeControl(RENU_INTAKE_CONTROL);
|
||||
|
||||
}
|
||||
|
||||
void ria_control() {
|
||||
cataControl(RIA_PTO_TOGGLE, RIA_CATA_CONTROL);
|
||||
wingsControlSingle(RIA_WINGS_CONTROL);
|
||||
intakeControl(RIA_INTAKE_CONTORL);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user