7 steps to autonomous for FRC    LabVIEW programmers           Jim Chastain       jimc2550@gmail.com
PingPong BunnyBot•   WE HAVE ENCODERS ON OUR WHEELS•   We want Arcade manual control (single joystick)•   In autonomous we...
7 steps to Autonomous• 1    Create list of all variables needed for autonomous   – All inputs (encoders)   – All outputs (...
set up list of auto variables• Autonomous inputs   – Right and left encoders• Autonomous outputs   –   Auto drive right   ...
From list, create indicators on                 Robot Global DATAYOU MUST SAVE AFTER   UPDATING RGD
Read all sensors (and joystick)  in Periodic tasks.vi               I used the 10 ms loop, but                   changed i...
AUTO ENABLE GETS VALUE IN ROBOT         MAIN.VI         TRUE IN AUTONOMOUS,         FALSE ALL OTHER STATES
CREATE CASE TO SWITCHCONTROL SIGNALS               THIS CASE SWITCHES              CONTROL FOR MOTOR                 AND S...
TRUE MEANSAUTONOMOUS IS CONTROLLING
NOTE, WHEN I CONTROL DRIVE MOTORS IN PERIODIC TASK, I MUST DIASABLE CONTROL IN                                 TELEOP.VI
LIST OF STEPS FOR                        AUTONOMOUS•   1 START WITH WHEELS STOPPED, CLAW CLOSED; RESET ENCODERS•   2 GO FO...
L = Auto Left; R = Auto Right; RS =  encoder reset; Open & Close = Solenoid    STATE CHARTSTATE NAME      OUTPUTS         ...
BUILD LV STATE MACHINE• IN AUTONOMOUS  – PUT LARGE WHILE LOOP  – IN CENTER PUT MEDIUM SIZE CASE STRUCT  – PUT GLOBAL OUTPU...
BASIC BLOCKS IN AUTONOMOUS     Leave original   autonomous code       disabled                       OUTPUTS   INPUTS  WHI...
NOW ADD ENUM        ENUM FROM ‘NUMERIC’ MENU,        RIGHT CLICK, EDIT ITEMS, INSERT          STATE NAMES FROM CHART!     ...
COMPLETE FRAMEWORKCONNECT ENUM TO ?       RIGHT CLICK ON CASE OF CASE; CHANGE      CONTROL BOX, ‘ADD CASETUNNEL TO SHIFT R...
COMPLETE CONTENTS FOR EACH    STATE… FROM CHART
State TWO
State THREE
State FOUR
State FIVE
State SIX
State SEVEN
State END
DEBUG USING RGD• Robot Global Data can be very useful in debug  if you include a STATE indicator (here is how)   –   Put a...
Create an indicator on the STATE                  variable lineThen right click on it and    ‘find indicator’
Then put a copy on front panel of ROBOT GLOBAL                      DATA
Label the Enum, “Current STATE”,              Save RGD   Delete the first enum indicatorConnect the RGD to the state varia...
NOTES• I used 100 ms as a time delay just to let  everything rest before going to next state  (where there is a delay)• Sh...
Upcoming SlideShare
Loading in …5
×

7 Steps to Autonomous for FRC LabVIEW Programmers

7,225 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
7,225
On SlideShare
0
From Embeds
0
Number of Embeds
26
Actions
Shares
0
Downloads
81
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

7 Steps to Autonomous for FRC LabVIEW Programmers

  1. 1. 7 steps to autonomous for FRC LabVIEW programmers Jim Chastain jimc2550@gmail.com
  2. 2. PingPong BunnyBot• WE HAVE ENCODERS ON OUR WHEELS• We want Arcade manual control (single joystick)• In autonomous we want to use TANK control• AND A SOLENOID “CLAW” TO HOLD OUR BUNNY• IN AUTONOMOUS, WE WANT TO DESIGN A STATE MACHINE WHICH WILL : – MOVE FORWARD 10 FEET – TURN RIGHT – GO FORWARD 3 FEET – OPEN CLAW TO DROP BUNNYBOT – THEN STOP AND WAIT FOR TELEOP
  3. 3. 7 steps to Autonomous• 1 Create list of all variables needed for autonomous – All inputs (encoders) – All outputs (drive motor signals, solenoid controls, encoder reset) – Add a Boolean “Auto Enable”• 2 From this list, set up an indicator in Robot Global Data for each one ( In Robot Main.vi assign value to “Auto Enable”)• 3 In “Timed Tasks.vi” read all sensors including joystick.• 4 Create a CASE struct in Timed Tasks.vi and use “Auto Enable” to switch controls between signals from “Autonomous” and “manual” control• 5 Make a list of all steps needed in autonomous, include steps to reset encoders; put steps in STATE CHART (4 columns)• 6 Build LABVIEW STATE MACHINE in Autonomous• 7 Use Robot Global Data to Debug
  4. 4. set up list of auto variables• Autonomous inputs – Right and left encoders• Autonomous outputs – Auto drive right – Auto drive left – Auto sol Close (close solenoid) – Auto sol Open (open solenoid) – Auto enc reset (reset both encoders every time)• We also want a signal “Auto Enable” to be on Robot Global Data• THIS GIVES US A SINGLE CONTROL SIGNAL WHICH CAN BE USED to switch manual to auto.
  5. 5. From list, create indicators on Robot Global DATAYOU MUST SAVE AFTER UPDATING RGD
  6. 6. Read all sensors (and joystick) in Periodic tasks.vi I used the 10 ms loop, but changed it to 20 ms
  7. 7. AUTO ENABLE GETS VALUE IN ROBOT MAIN.VI TRUE IN AUTONOMOUS, FALSE ALL OTHER STATES
  8. 8. CREATE CASE TO SWITCHCONTROL SIGNALS THIS CASE SWITCHES CONTROL FOR MOTOR AND SOLENOID FALSE MEANS MANUAL CONTROL
  9. 9. TRUE MEANSAUTONOMOUS IS CONTROLLING
  10. 10. NOTE, WHEN I CONTROL DRIVE MOTORS IN PERIODIC TASK, I MUST DIASABLE CONTROL IN TELEOP.VI
  11. 11. LIST OF STEPS FOR AUTONOMOUS• 1 START WITH WHEELS STOPPED, CLAW CLOSED; RESET ENCODERS• 2 GO FORWARD 300 REVOLUTIONS ON BOTH ENCODERS• 3 STOP, RESET BOTH ENCODERS, (wait 20 ms)• 4 RIGHT WHEEL STOPPED, LEFT WHEEL FORWARD 25 REVOLUTIONS (HALF SPEED)• 5 STOP, RESET BOTH ENCODERS (wait 20 ms)• 6 GO FORWARD 95 REVOLUTIONS ON BOTH ENCODERS• 7 STOP, RESET ENCODERS, OPEN CLAW (wait 20 ms)• 8 WAIT FOR MANUAL CONTROL• NOW PUT IN STATE CHART WITH 4 COLUMNS – LEFT COLUMN IS STATE NAME – NEXT IS STATE OUTPUT – NEXT IS TRIGGER TO GO TO NEXT STATE – FINAL COLUMN IS NEXT STATE (if you do not count notes)
  12. 12. L = Auto Left; R = Auto Right; RS = encoder reset; Open & Close = Solenoid STATE CHARTSTATE NAME OUTPUTS TRIGGER NEXT STATE NOTESSTART L=R=0; None TWO RS=true; Close=TrueTWO L=R=.-4 ENCODERS = THREE TRICKY STEP TO RS = false 300 STOP EACH Close =false MOTOR SEPARATELYTHREE L=R=0;RS=true 100 ms FOURFOUR R=0; L=-.3;RS=f ENCODER=25 FIVEFIVE L=R=0; RS=t 100 ms delay SIXSIX L=R=-.4;RS=f ENCODERS =95 SEVEN AGAIN, TRICKYSEVEN L=R=0;RS=t; 100 ms delay END Open =trueEND L=R=0, RS=f 100 ms delay END Open = f
  13. 13. BUILD LV STATE MACHINE• IN AUTONOMOUS – PUT LARGE WHILE LOOP – IN CENTER PUT MEDIUM SIZE CASE STRUCT – PUT GLOBAL OUTPUT VARIABLE ON RIGHT – PUT GLOBAL INPUTS ON LEFT – CREATE ENUM (numeric pallet) • Edit items to enter all STATE NAMES – CONNECT ENUM TO “?” OF CASE – CHANGE TUNNEL THRU WALL TO SHIFT REGISTER
  14. 14. BASIC BLOCKS IN AUTONOMOUS Leave original autonomous code disabled OUTPUTS INPUTS WHILE LOOP CASE
  15. 15. NOW ADD ENUM ENUM FROM ‘NUMERIC’ MENU, RIGHT CLICK, EDIT ITEMS, INSERT STATE NAMES FROM CHART! ENUM GOES OUTSIDE WHILE, ON LEFT
  16. 16. COMPLETE FRAMEWORKCONNECT ENUM TO ? RIGHT CLICK ON CASE OF CASE; CHANGE CONTROL BOX, ‘ADD CASETUNNEL TO SHIFT REG FOR EVERY VALUE’
  17. 17. COMPLETE CONTENTS FOR EACH STATE… FROM CHART
  18. 18. State TWO
  19. 19. State THREE
  20. 20. State FOUR
  21. 21. State FIVE
  22. 22. State SIX
  23. 23. State SEVEN
  24. 24. State END
  25. 25. DEBUG USING RGD• Robot Global Data can be very useful in debug if you include a STATE indicator (here is how) – Put an indicator on the STATE line (right side of while loop) – Right click on it (find) to locate it on front panel of Autonomous.vi – Then copy it to Robot Global Data , call “current State” – Delete it from the Block Diagram and replace it with Robot Global Data.. See next three slides.• Now when you run the robot in Autonomous mode, you can watch Robot Global Data and see if things run in the correct order.
  26. 26. Create an indicator on the STATE variable lineThen right click on it and ‘find indicator’
  27. 27. Then put a copy on front panel of ROBOT GLOBAL DATA
  28. 28. Label the Enum, “Current STATE”, Save RGD Delete the first enum indicatorConnect the RGD to the state variable line.
  29. 29. NOTES• I used 100 ms as a time delay just to let everything rest before going to next state (where there is a delay)• Shoot me an email if you have questions• Good luck!

×