7 steps to autonomous for frc labview programmers

29
7 steps to autonomous for FRC LabVIEW programmers Jim Chastain [email protected]

Upload: oregon-first-robotics

Post on 19-May-2015

4.393 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 7 Steps to Autonomous for FRC LabVIEW Programmers

7 steps to autonomous for FRC LabVIEW programmers

Jim [email protected]

Page 2: 7 Steps to Autonomous for FRC LabVIEW Programmers

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

Page 3: 7 Steps to Autonomous for FRC LabVIEW Programmers

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

Page 4: 7 Steps to Autonomous for FRC LabVIEW Programmers

Step1 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.

Page 5: 7 Steps to Autonomous for FRC LabVIEW Programmers

STEP 2 From list, create indicators on Robot Global DATA

YOU MUST SAVE AFTER UPDATING RGD

Page 6: 7 Steps to Autonomous for FRC LabVIEW Programmers

Step 3 Read all sensors (and joystick) in Periodic tasks.vi

I used the 10 ms loop, but changed it to 20 ms

Page 7: 7 Steps to Autonomous for FRC LabVIEW Programmers

AUTO ENABLE GETS VALUE IN ROBOT MAIN.VI

TRUE IN AUTONOMOUS, FALSE ALL OTHER STATES

Page 8: 7 Steps to Autonomous for FRC LabVIEW Programmers

STEP 4 CREATE CASE TO SWITCH CONTROL SIGNALS

THIS CASE SWITCHES CONTROL FOR MOTOR

AND SOLENOIDFALSE MEANS MANUAL

CONTROL

Page 9: 7 Steps to Autonomous for FRC LabVIEW Programmers

TRUE MEANS AUTONOMOUS IS

CONTROLLING

Page 10: 7 Steps to Autonomous for FRC LabVIEW Programmers

NOTE, WHEN I CONTROL DRIVE MOTORS IN PERIODIC TASK, I MUST DIASABLE CONTROL IN TELEOP.VI

Page 11: 7 Steps to Autonomous for FRC LabVIEW Programmers

STEP 5 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)

Page 12: 7 Steps to Autonomous for FRC LabVIEW Programmers

STATE CHARTSTATE NAME OUTPUTS TRIGGER NEXT STATE NOTES

START L=R=0; RS=true; Close=True

None TWO

TWO L=R=.-4RS = falseClose =false

ENCODERS = 300

THREE TRICKY STEP TO STOP EACH MOTOR SEPARATELY

THREE L=R=0;RS=true 100 ms FOUR

FOUR R=0; L=-.3;RS=f ENCODER=25 FIVE

FIVE L=R=0; RS=t 100 ms delay SIX

SIX L=R=-.4;RS=f ENCODERS =95 SEVEN AGAIN, TRICKY

SEVEN L=R=0;RS=t; Open =true

100 ms delay END

END L=R=0, RS=fOpen = f

100 ms delay END

L = Auto Left; R = Auto Right; RS = encoder reset; Open & Close = Solenoid

Page 13: 7 Steps to Autonomous for FRC LabVIEW Programmers

STEP 6 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

Page 14: 7 Steps to Autonomous for FRC LabVIEW Programmers

BASIC BLOCKS IN AUTONOMOUS

Leave original autonomous code

disabled

OUTPUTS

INPUTSWHILE LOOP

CASE

Page 15: 7 Steps to Autonomous for FRC LabVIEW Programmers

NOW ADD ENUMENUM FROM ‘NUMERIC’ MENU, RIGHT CLICK, EDIT ITEMS, INSERT

STATE NAMES FROM CHART! ENUM GOES OUTSIDE WHILE, ON LEFT

Page 16: 7 Steps to Autonomous for FRC LabVIEW Programmers

COMPLETE FRAMEWORK

CONNECT ENUM TO ? OF CASE; CHANGE

TUNNEL TO SHIFT REG

RIGHT CLICK ON CASE CONTROL BOX, ‘ADD CASE

FOR EVERY VALUE’

Page 17: 7 Steps to Autonomous for FRC LabVIEW Programmers

COMPLETE CONTENTS FOR EACH STATE… FROM CHART

Page 18: 7 Steps to Autonomous for FRC LabVIEW Programmers

State TWO

Page 19: 7 Steps to Autonomous for FRC LabVIEW Programmers

State THREE

Page 20: 7 Steps to Autonomous for FRC LabVIEW Programmers

State FOUR

Page 21: 7 Steps to Autonomous for FRC LabVIEW Programmers

State FIVE

Page 22: 7 Steps to Autonomous for FRC LabVIEW Programmers

State SIX

Page 23: 7 Steps to Autonomous for FRC LabVIEW Programmers

State SEVEN

Page 24: 7 Steps to Autonomous for FRC LabVIEW Programmers

State END

Page 25: 7 Steps to Autonomous for FRC LabVIEW Programmers

STEP 7 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.

Page 26: 7 Steps to Autonomous for FRC LabVIEW Programmers

Create an indicator on the STATE variable line

Then right click on it and ‘find indicator’

Page 27: 7 Steps to Autonomous for FRC LabVIEW Programmers

Then put a copy on front panel of ROBOT GLOBAL DATA

Page 28: 7 Steps to Autonomous for FRC LabVIEW Programmers

Label the Enum, “Current STATE”, Save RGD

Delete the first enum indicatorConnect the RGD to the state variable

line.

Page 29: 7 Steps to Autonomous for FRC LabVIEW Programmers

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!