properly implement pto (untested)

rtft
This commit is contained in:
ary 2023-09-29 08:23:23 -04:00
parent f114e91092
commit e06a116982
5 changed files with 40 additions and 23 deletions

View File

@ -38,4 +38,7 @@ namespace globals {
extern lemlib::TrackingWheel horiz_tracking_wheel; extern lemlib::TrackingWheel horiz_tracking_wheel;
extern Drive chassis; extern Drive chassis;
extern pros::Motor& cata_left;
extern pros::Motor& cata_right;
} }

View File

@ -23,6 +23,7 @@ namespace superstruct {
//- Structure methods //- Structure methods
void togglePto(); void togglePto();
bool getPtoState(); void runCata();
void controlCata();
} }

View File

@ -22,7 +22,7 @@ namespace globals {
pros::Rotation rot_horiz(1); pros::Rotation rot_horiz(1);
// pros::Rotation enc_right(); // pros::Rotation enc_right();
// pros::Rotation enc_theta(); // pros::Rotation enc_theta();
pros::ADIAnalogOut pto_piston(1); pros::ADIAnalogOut pto_piston('A');
lemlib::Drivetrain_t chassis_odom { lemlib::Drivetrain_t chassis_odom {
&left_drive, &left_drive,
@ -44,6 +44,6 @@ namespace globals {
DRIVE_RATIO DRIVE_RATIO
); );
// Misc pros::Motor& cata_left = chassis.left_motors[3];
pros::Motor& cata_right = chassis.right_motors[3];
} }

View File

@ -81,19 +81,8 @@ void autonomous() {}
*/ */
void opcontrol() { void opcontrol() {
while (true) { while (true) {
//chassis.arcade_standard(ary::SPLIT, e_curve_type::DEFAULT); chassis.tank();
if (globals::master.get_digital(DIGITAL_R1)) { superstruct::controlCata();
motor_tlb.move_voltage(-12000);
motor_trb.move_voltage(12000);
} else {
motor_tlb.move_voltage(0);
motor_trb.move_voltage(0);
}
if (globals::master.get_digital_new_press(DIGITAL_LEFT)) {
togglePto();
}
pros::delay(20); pros::delay(20);
} }
} }

View File

@ -57,12 +57,36 @@ namespace superstruct {
// Structure methods // Structure methods
void togglePto() { void togglePto(bool toggle) {
int state = (ptoEnabled) ? 1 : 0; ptoEnabled = toggle;
pto_piston.set_value(state); chassis.pto_toggle({cata_left, cata_right}, toggle);
pto_piston.set_value(toggle);
if (toggle) {
cata_left.set_brake_mode(MOTOR_BRAKE_COAST);
cata_right.set_brake_mode(MOTOR_BRAKE_COAST);
}
} }
// bool getPtoState() { void runCata(double inpt) {
// return (pto_piston.get_value() == 1) ? true : false; if (!ptoEnabled) return;
// } cata_left = inpt;
cata_right = inpt;
}
int lock = 0;
void cataControl() {
if (globals::master.get_digital(DIGITAL_LEFT) && lock == 0) {
togglePto(!ptoEnabled);
lock = 1;
} else if(!globals::master.get_digital(DIGITAL_LEFT)) {
lock = 0;
}
if (globals::master.get_digital(DIGITAL_R1)) {
runCata(12000);
} else {
runCata(0);
}
}
} }