Autonomous Mode Selection

I want to be able to tell the Robot which Team it’s in (Blue or *Red *) and which side it’s on (Left or *Right *) before every match. That way I can get the robot to move accordingly during its Autonomous period.

Is there, by any chance, a way to get the Joystick Buttons to tell the robot it’s Team/Position?

If so, should it be in the Pre-Auton function? Will the values be *recorded * or *erased * once the Pre-Auton period ends? Also, what does it mean to return from the function?

Thank you!

PS. Competition is in two days so I’d like a reply soon. Again, thank you!

The best and only way that I know about is using the LCD as an autonomous selection interface. I’m still working on my teams code for it so there is really no code for me to share but robotC has a good test LCD code chooser program in its sample code

@whatwhat1 Thank you for your response. Unfortunately for me, I don’t have the Serial Y-Cable, which means that the LCD that I currently have is rendered useless. Is it possible to have the Joystick control the robot’s variables? Or does it have to be On-The-Robot?

You won’t be able to receive signals from the joystick until the driver control period. If you don’t have a LCD screen, another good method is to use a potentiometer or a couple potentiometers on the robot which you can turn to different positions before the match to select an autonomous.

The cheapest way to select autons is the potentiometer. I’ve seen a fair amount of teams run this with success. The LCD is also a good option, but if you are running low on time, pot is the way to go

Use a potentiometer dial if you’re on a time crunch. It’s quite simple to use. This is an image of the dial I used on my robot last year. The “needle” of the dial is a standoff coupler that I put into a shaft collar. I had a HS 12-tooth gear (the small metal gear) between the shaft collars as a grip, which is not shown in the picture. The potentiometer’s axle insert should be tight enough that you don’t need to use shaft collars on the other side of the dial.

I do not know if it’s legal to use a decoration as labeling like shown below, but you can have a template that you place on the dial while you’re preparing the robot for a match to help put the dial in the correct setting, after which you remove the template and put it in your pocket or something.

Pot dial rotated.jpg

How to set a potentiometer dial up:

Since a potentiometer is an analog sensor, it sends out one number out of a range of values as opposed to just 0s and 1s. You can thus set a certain range on the pot to correspond to an autonomous, and the very first thing your robot should do when the autonomous period begins is to read the potentiometer, and match the reading to the desired autonomous. Here’s pseudocode for it.

Assume that you have 4 autonomous routines (or 4 starting positions, for that matter). You thus have set 4 ranges to correspond to each routine or position. This code should be placed in the autonomous task of your program, rather than the pre-auton function.

if( pot_reading > lower_end_of_range_1 && pot_reading < upper_end_of_range_1)
   //run autonomous routine #1
else if( pot_reading > lower_end_of_range_2 && pot_reading < upper_end_of_range_2)
   //run autonomous routine #2
else if( pot_reading > lower_end_of_range_3 && pot_reading < upper_end_of_range_3)
   //run autonomous routine #3
else if( pot_reading > lower_end_of_range_4 && pot_reading < upper_end_of_range_4)
   //run autonomous routine #4
The following statement is optional, if you somehow want the robot to not run at all during autonomous)
else if( pot_reading > lower_end_of_range_5 && pot_reading < upper_end_of_range_5)
   //run nothing

This pseudocode is “fire-and-forget”, i.e. once the routine is matched and begins to run, the robot will never refer to the potentiometer dial again for the remainder of the match, even if some impact during autonomous changes the setting on the dial.

Would you be able to use a sprocket to display, too?