im very new to trying to select an auton, as in previous years weve only had one and were able to stick to it. this year we have two seperate autons, for each alliance color. (have to spin the roller a different direction dependent on alliance color) my idea is to use 2 limit switches, one to select alliance color, and one to select auton routine. theoretically i could put them both on one switch and just have it loop instead, but i would like it better this way. i have no idea where to start regarding this and need a ton of help.
What you can do is have a variable for the auton program you want to run, and then change the value of the variable when the limit switch is pressed. You can then run a different function when auto starts based on the variable
Example using VexCode C++:
// Device and competition control setup removed for simplicity
int auto_program = 1;
void switch1_pressed() {
auto_program = 1;
}
void switch2_pressed() {
auto_program = 2;
}
void autonomous() {
if (auto_program == 1) {
// Run program 1
}
else if (auto_program == 2) {
// Run program 2
}
}
int main() {
switch1.pressed(switch1_pressed);
switch2.pressed(switch2_pressed);
Competition.autonomous(autonomous);
}
You wouldn’t actually need to do this, because the roller orientation changes based on which alliance you are on (i.e. If you are blue the blue side starts facing in, if you are red the red side starts facing in)
wont this rely on the switch being pressed after the program starts though? if it starts pressed will it recognized it started pressed? or would it have to be pressed after auton starts essentially.
All this seems well and good, I just wanted to comment that you may want to use a potentiometer that you set at the start of the match. This is partially because of the reason @ginger5842Z gave, and partially because it gives you more options for routines. For several years in a row my team has done this by splitting the potentiometer into sections and using a marker to lay out where it should point for each auton routine. At the start of the auton section you would lay out a big if statement that defines where it is pointing to each different subroutine. Just something to consider. There’s no real reason why you couldn’t do it your way. Also, important to note: don’t forget to change your switch. It’s something you only do once, especially after getting dq’d in auton because of it.
What you would do is turn on the program on the brain, press the switch, then plug your controller into the competition control tower and disabling your code. I would recommend testing out selecting a program and running it as if you are at a competition with a Competition Switch so you know it works.
this was my initial idea, and i kid you not it was exactly like this, im just worried about forgetting to spin it back to zero degrees before i turn the robot on again. but now that i think about it, i guess if im so violently stressed about forgetting to turn it. i think ill remember lol
You could also try and select your program digitally using your brain. Here’s a link from my org that explains how to do it in Vexcode pro. V5 GUI for Auton Selector | Rolling Robots
this is also fair, hmm, i guess i have options now. i appreciate it
we are straying away from this type of selector as its just a little complicated for myself ( i program lol)
Another idea that takes less work is to simply create 2 different programs (each with a different color) right before your competition.
Yeah, I was going to say something like this, members of my team used to be on a team that did this. They just have two programs with identical everything, except for the auton, and you select left or right before you run it. Seems to work fairly well, and can be easy to remember if you label them. Not exactly what the op post described, but it works around the problem.