Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
outtake functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cowsed committed Feb 28, 2024
1 parent a97ccff commit 55b2ce0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions include/robot-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ extern vex::motor_group intake_motors;
extern OdometryTank odom;
extern TankDrive drive_sys;

extern const double intake_volts;

void intake(double volts);
void intake();
void outtake(double volts);
void outtake();

// ================ UTILS ================

void robot_init();
13 changes: 9 additions & 4 deletions src/competition/opcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ const vex::controller::button &right_wing_button = con.ButtonB;
/**
* Main entrypoint for the driver control period
*/
const double intake_volts = 10.0;

const double fold_out_time = 0.5;
void opcontrol() {
vex::timer drop_timer;
outtake();

// ================ INIT ================
// Wings
left_wing_button.pressed([]() { left_wing.set(!left_wing); });
right_wing_button.pressed([]() { right_wing.set(!right_wing); });

// Intake
intake_button.pressed([]() { intake_motors.spin(vex::fwd, intake_volts, vex::volt); });
outtake_button.pressed([]() { intake_motors.spin(vex::reverse, intake_volts, vex::volt); });
intake_button.pressed([]() { intake(intake_volts); });
outtake_button.pressed([]() { outtake(intake_volts); });

// Misc
drive_mode_button.pressed([]() { tank = !tank; });
con.ButtonLeft.pressed([]() { screen::prev_page(); });
Expand All @@ -34,7 +39,7 @@ void opcontrol() {
// ================ PERIODIC ================
while (true) {
// intake motors
if (!intake_button.pressing() && !outtake_button.pressing()) {
if (!intake_button.pressing() && !outtake_button.pressing() && drop_timer.value() > fold_out_time) {
intake_motors.stop(vex::brakeType::hold);
}

Expand Down
6 changes: 6 additions & 0 deletions src/robot-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ OdometryTank odom(left_motors, right_motors, robot_cfg, &imu);
TankDrive drive_sys(left_motors, right_motors, robot_cfg, &odom);

// ======== SUBSYSTEMS ========
const double intake_volts = 10.0;
void intake(double volts) { intake_motors.spin(vex::fwd, volts, vex::volt); };
void intake() { intake_motors.spin(vex::fwd, intake_volts, vex::volt); };

void outtake(double volts) { intake_motors.spin(vex::reverse, volts, vex::volt); };
void outtake() { intake_motors.spin(vex::reverse, intake_volts, vex::volt); };

// ================ UTILS ================

Expand Down

0 comments on commit 55b2ce0

Please sign in to comment.