View Full Version : Multiple programs/autonomous routines
galewind
09-01-2004, 18:52
Being that we're no longer using banked code, is there an easy way to switch between autonomous routines using functions, or is it best to just re-download code after each match (a side-switch, for example) if we're using dead-reckoning?
rwaliany
09-01-2004, 19:07
Personally, I would have a set of functions
//auton check
int program = 0;
//bit shift digital inputs to program var
doAutonomous(program);
//auton check
//misc funcs
#define REGULAR_AUTON 0
void doAutonomous(int program)
{
if (program == REGULAR_AUTON) regular_auton();
else if...
}
void regular_auton()
{
// blah regular auton
}
galewind
09-01-2004, 19:12
Will the RC pick up inputs from the OI prior to the match starting so it knows which autonomous mode to use (if we used a set of digital switches at the OI to determine the autonomous code)
rwaliany
09-01-2004, 19:17
I wouldn't use OI digital inputs, last year they were cleared and autonomous started with no initial communication from OI I believe. Last year, our team put digital switches on our robot and used that and it worked fine.
Programs per switch
1 2 - 0, 1
2 4 00, 01, 10, 11
3 8 000, 001, 010, 011, ...
4 16
Actually, you could use digital inputs on the OI, as there are two variables, one for autonomous, and one for competition. Communication exists between the OI and the RC, although no outputs may be changed. However, inputs can still be received.
It's better to have the controls connected to the OI, because a situation may occur where you may notice a different setup by the opposing robots (especially during finals, when you don't know which 2 robots are selected, or which side they're on), and you can change your own autonomous immediately.
galewind
09-01-2004, 19:34
See, that's what I thought -- I knew that your outputs couldn't be changed, but I thought there was still communication and variables could be changed. that's good news to hear.
Actually, you could use digital inputs on the OI, as there are two variables, one for autonomous, and one for competition. Communication exists between the OI and the RC, although no outputs may be changed. However, inputs can still be received.
It's better to have the controls connected to the OI, because a situation may occur where you may notice a different setup by the opposing robots (especially during finals, when you don't know which 2 robots are selected, or which side they're on), and you can change your own autonomous immediately.
I want to make sure I understand this point. It seems very important to emphasize. I would be interested to hear more view points in particular.
So, PRIOIR TO autonomous mode (i.e. while the robot is disabled), your OI and RC are still communicating and your OI is accepting signals from its inputs and passing those along to the RC?
BUT, the RC can not change its outputs? Right? The disabled mode cancels outputs?
This seems like a critical point and I'd be interested to hear some folks chime in.
Another question, can
Yes, this is true. We did it last year, along with many teams. You can store a variable that is based on inputs from the OI, and that can be used during the autonomous running of the program. We had switches on our control board that were used to tell the robot which autonomous program to run. Many teams got much more complicated than we did, and had analog inputs (pots) to have many different autonomous programs.
I guess I should make references. Page 26 of the Programming Reference Guide explains the competition mode.
When Disabled, all PWM and Relay outputs are disabled, but program execution continues.
It was explained very vividly last year in one of the updates. Just have an
if (competition_mode == 0)
and put your code there.
RoboCoder
09-01-2004, 22:02
This was functionality that FIRST made clear partway through the build season. At the beginning of the year, it was not believed that you could do this. My point? rules change. Especially year to year. Once the rules are released tomorrow, check and see if you can do this, I wouldnt count on it from the beginning without consulting the rules. If it isnt specified, then we'll just have to ask for a clarification :D Good luck all, and let me know if you have any further questions :cool:
Damian Manda
09-01-2004, 22:03
The manual has this to say in the RC Manual is this:
Autonomous Mode means that the RC will ignore all data from the Operator Interface and it will not
require a link with the Operator Interface to execute code. And the OI manual has this:
Operator Interface inputs (joystick, buttons, etc.) are transmitted to the Robot Controller in their
default state(analog inputs at neutral and digital inputs disabled).
• User code is executing.
• User code input, local inputs (switches, pots, etc), including Operator Interface default inputs are
read in by the User processor.
• Robot Controller feedback is transmitted to the Operator Interface.
• For more information on programming Autonomous Mode, see the Programming Reference
Guide.
From this it seems that OI imputs will be ignored as to thier state in autonomous mode, but RC imputs will be read in as they are set. Is it true that an OI switch worked last year, as that would not seem to be that way this time?
--Damian Manda
Rules may change, but this is the way the software works, and FIRST cannot change that mid-season. It is stated in the reference guide that it is functional the same as last year, so unless this is a typo (it has been reworded since last year), you can be quite sure it is still available.
Prior to the game, the auton_mode is set to 0, but competition_mode is also set to 0, and there IS contact between the two. It is only once autonomous has begun that they no longer interact.
The manual has this to say in the RC Manual is this:
And the OI manual has this:
From this it seems that OI imputs will be ignored as to thier state in autonomous mode, but RC imputs will be read in as they are set. Is it true that an OI switch worked last year, as that would not seem to be that way this time?
--Damian Manda
I think there's a point to clarify here...
I'm refering to the time before the autonomous mode when you plug your OI into the driving station and you have live link before the contest begins. I believe that a "disabled" it is set at this time.
This disabled bit keeps the bot from moving before the contest starts, right?
But, if I understand previous posts from last year, that disabled just means no output at the RC. You do however have inputs from the OI that are passed onto the RC.
IF THIS IS TRUE, then you can set an switch to designate an automous program just moments before the game begins as you are setting up your robot at the driver station.
THEN once the contest begins and autonomous mode starts, the "disable" bit becomes false, but the auotonomous bit becomes true.
Can anyone verify the above?
Damian Manda
09-01-2004, 22:25
The manual says that there is transmission during disabled status:
When the Disabled LED is ON solid, the Robot Controller’s PWM and RELAY outputs are disabled.
The following functions are still active when the Disabled LED is solid ON:
• Operator Interface inputs (joystick, buttons, etc.) are transmitted to the Robot Controller.
• User code is executing.
• User code input, including Operator Interface inputs and local inputs (switches, pots, etc) are
read in by the User processor.
• Robot Controller feedback is transmitted to the Operator Interface. If the robot is in disabled before switching to autonomous then I would say that it is correct that you could transmit during that time. This seems to be the logical explanation for how this worked last year, and probably will this year too.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.