|
If you are doing autonomous for the first time you might want to just add some simple movements to your regular Main program.
Helping other teams at regionals I've found they understand the concepts more easily and get up and running faster if you simply add the autonomous as an override of the regular user controls. You only need to expand into multi-bank code if you need more space. We use an autonomous meta or scripting language, so a sample of our code would be counter productive if you're new to this.
The example below is for a single joystick than does 3 moves. Add or subtract moves to fit your need. The code is in the old 1.33 style in case you're modifying last years robot code.
'----------Put these in your declaration section
'These are the # of program loops that completes the movement
FIRST_LEG CON 40 '~ 1 second assuming delta_t=0
SECOND_LEG CON 200 '~5.2 seconds
THIRD_LEG CON 250 '~6.5 seconds
'The last leg you define here should not be > 577 (15 sec.)
auto_counter VAR WORD
'------------Put this before your main loop
auto_counter = 0
'-----------Put this immediately after your Serin command
' We are just overriding the joystick values as if the driver were moving the joystick
IF auto_mode = 0 then NoAuto
auto_counter = auto_counter + 1
'Can also do: auto_counter = auto_counter + 1 + delta_t
If auto_counter >= FIRST_LEG then LEG2
'These values should be what your driver would normally do with the joystick to accomplish what you want to do
p1_x = 254
p1_y = 0
Goto NoAuto
LEG2:
If auto_counter >= SECOND_LEG then LEG3
p1_x = 254
p1_y = 0
Goto NoAuto
LEG3:
If auto_counter >= THIRD_LEG then NoAuto
'Make sure you come to a stop as the last LEG
p1_x = 127
p1_y = 127
Goto NoAuto
NoAuto:
'------------The rest of your regular code
(BTW: This was indented for readability when I typed it in)
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Last edited by Mark McLeod : 28-03-2003 at 08:40.
|