Would an auton selector using controller buttons work at a competion?

Hello, this is my first year at vex and I’m trying to code an auton selector by printing to a controller and refreshing when pressing the left or right button. The code works but my main concern is if this will work at a competition since I believe anything relating to controller button presses will not work once you plug it in. I don’t see how I could run the code before plugging it in, as that would start the auton before the match. The auton selection runs before the competition function, I just hope to know if this would work, otherwise I am open to suggestions. I do not have a competition switch so I cannot test it.

If the robot is disabled, the controller is disabled.

2 Likes

How are you starting the program? Because my team ( I’m pretty sure I’m not the coder though) starts the program as under run not competition drive or any of those other options and has the auton code under when autonomous that way it doesn’t run as soon as we start the program. Also, why would you make an autonomous selector instead of just different programs for different starting positions on the field?

  • Easier to maintain one code base
  • Allows for more granularity with enabling/disabling robot features (back in Turning Point this was useful)
6 Likes

Sorry for the late reply, but could I run the program and select the auton before plugging the controller in, which will be detected and run the program during auton?

This is what my team does and we have not had any issues so far.

This is how our team goes about it (I know copy-paste might not be best for learning, so I’ll explain how we use it as well). I am also a PROS user, so if you don’t use that you might just have to infer from the code.

while(!autonSelected){
			// Adjust which auton program we have selected
			if(master.get_digital_new_press(DIGITAL_RIGHT)) selectionIndex++;
			if(master.get_digital_new_press(DIGITAL_LEFT)) selectionIndex--;
			if(selectionIndex > 3) selectionIndex = 0;
			if(selectionIndex < 0) selectionIndex = 3;

			// Print selected auton
			switch(selectionIndex){
				case 0: master.print(1, 0, "        None        "); auton = 'N'; break;
				case 1: master.print(1, 0, "     Full Auton     "); auton = 'A'; break;
				case 2: master.print(1, 0, "    Experimental    "); auton = 'E'; break;
				case 3: master.print(1, 0, "   Red Ball Auton   "); auton = 'L'; break;
				default: master.print(1, 0,"ERROR: Invalid auton"); break;
			}

			// Break when done
			if(master.get_digital_new_press(DIGITAL_A)){
				autonSelected = true;
			}else if(master.get_digital_new_press(DIGITAL_X)){
				autonomous();
			}

			// Delay to prevent the controller from ignoring commands
			pros::delay(60);
		}

This is part of the code runs in our main.cpp file in the opcontrol section. It uses the left and right arrows to change the appearance of the controller, and when the user selects an auton with the a-button, it stores a global character that corresponds to a specific auton. Then, when fieldcontrol calls auton, the auton section of the code checks for which character is being used using if-statements, and runs the auton that corresponds to the code like shown.

void autonomous(){

	if(auton == 'A'){
		// auton sequence
	}

We run the program before plugging in to field control because the actual auton code is not triggered until fieldcontrol runs autonomous.

3 Likes