|
|
|
![]() |
|
|||||||
|
||||||||
What I learned and used in LabVIEW through FIRST robotics. This includes executable VIs, hints, and papers from others from the FIRST communitythat helped me to make clever Driver Station stuff.
Some helpful URLs for the Driver Station stuff:
http://www.chiefdelphi.com/forums/showpost.php?p=901152&postcount=6
http://decibel.ni.com/content/docs/DOC-8862
Programming in LabVIEW_ Chris Hideg REVISION 1.zip
Programming in LabVIEW_Chris Hideg REVISION 1.pdf
ClassmateSideOfCustomDS.pdf
28-08-2010 13:33
Lucario231Hey I just finished writing his paper. If anyone has any questions you can message me or leave a question here.
28-08-2010 23:17
JogoWow, thanks for this! I haven't seen anything like this before, good stuff. One question: you had mentioned in the intro that you would discuss version control, but I can't find anything in the document discussing this. This is something that would be especially useful for me, think you could add some tips for it?
29-08-2010 10:23
apalrd
There are a couple tricks you missed:
Threading. The ability to run each sub-system in it's own thread gives you two things: Independent loop cycle timing (some things that are higher priority can update at the same rate as the Victors/Jaguars, while lesser things can run slower (flashing lights or Dashboard comm). When running multiple threads, you can pickup and scale user input data in Teleop (e.g. take the distance slider, and scale it to feet) and pass it to the parallel thread using either RT-FIFO or Global variables.
OpenG has a rising/falling edge trigger, among a GIGANTIC list of helpful VI's.
State-machines. These are HUGE. You can describe the process of creating an enum. control and using that to select states in a case structure. Very useful for things like kicker sequencing or multi-position arms.
29-08-2010 11:52
Lucario231@ Jogo
Whoops sorry about that. I will fix that.
Anyway Version control in LabVIEW is hard to do. What I do is at every competition or before it. I Make a copy of the code and save that under a different name. I also make a new executable and label it for that competition. For example, I have "build season code.exe" as a downloadable code for the robot. Then for I make a new exe called, "competition one.exe". Then when ever I make changes to the code I build in the new .exe file. That way if the code doesn't work I can change over to "build season code .exe". I also made a text display on the DS that says what code is running. Us the other papers attached to modify DS screen and other things. This is more of a way to manually handle version control. I don't know of a way to have LabVIEW do this automatically other than using multiple exe codes.
Hope that clears things up.
@ apalrd
Threading is interesting I never used that before. I might try that later. I will add state machines in another revision when I have more time and some code ready.
29-08-2010 12:22
apalrd
About Threading:
You would create a VI for each subsystem (not necessarily each thread)
Then you would call the VI from under the main loop (where Vision and Periodic Tasks is)
Then, in each VI, you would add one or more While loops (for each thread)
Each While loop will run in parallel.
You can then use Wait Ms to time the loop, somewhere between 20ms and 50ms is average (remember: the main loop runs at *around* 50ms ish, and has no exact means of timing.)
If you do not include Wait Ms, then the new thread will consume all of the remaining CPU power, cause possible network lag, and make it impossible to determine actual CPU load. Include the Wait Ms or another source of delay (e.g. wait for occurrence from the comm packet, or a camera wait for image) in every loop.
29-08-2010 15:46
Ether|
Hey I just finished writing his paper. If anyone has any questions you can message me or leave a question here.
![]() |
29-08-2010 16:36
Tom Line|
Couple of suggestions:
If you want to reach a larger audience, get rid of the DOCX files. Replace them with DOC, or better yet, PDF. Threading and state machines (mentioned in an earlier post by apalrd) are two areas which seem to cause a lot of trouble for new FRC LabVIEW programmers. Adding a concise explanation of these would add much value to the paper. ~ |
29-08-2010 17:36
Ether|
I've never understood the difficulty understanding state machines. Perhaps it is conceptualizing the fact that the loop runs constantly but only increments your state machine when a condition is met?
I've always understood that you COULD run parallel threads, but I have a question regarding that. We put a timer in front of our teleop code that passes it's time value into each loop. We use that to run any time-sensitive loops. I have yet to find anything in FRC that requires anything faster than the (approximately) 50ms loop. Can you tell me what type of things you might want to run faster than that? |
29-08-2010 18:05
apalrd
Or you could use the threads to partition your code. Each thread operates a sub-system, allowing a single VI to be written that handles the acquisition of refs from Begin, the code loop, and cleanup at the end (although it actually never gets there), for one subsystem. More complex subsystems contain clearly labeled SubVI's called from this VI, and all WPI lib calls are visible from the main VI.
If you wanted to process images asynchronously from using the target data, you could put a call to process image and a loop to use the image data in the same VI, running as two parallel threads, but under one sub-system VI. If you needed to pass references to both threads at the beginning, they would both be there.
Plus, isolating the robot functions from Teleop allows you to use them much more easily in Autonomous.
29-08-2010 19:03
Tom Line|
Or you could use the threads to partition your code. Each thread operates a sub-system, allowing a single VI to be written that handles the acquisition of refs from Begin, the code loop, and cleanup at the end (although it actually never gets there), for one subsystem. More complex subsystems contain clearly labeled SubVI's called from this VI, and all WPI lib calls are visible from the main VI.
If you wanted to process images asynchronously from using the target data, you could put a call to process image and a loop to use the image data in the same VI, running as two parallel threads, but under one sub-system VI. If you needed to pass references to both threads at the beginning, they would both be there. Plus, isolating the robot functions from Teleop allows you to use them much more easily in Autonomous. |
30-08-2010 14:24
Ether
It's not that state machines are difficult to understand, it's just that many new programmers (new to robotics) don't realize they need to use them (or concurrent processing). They program the robot like they would program a non-realtime app on a PC. This is understandable if they've never been taught the basic concepts of realtime programming.
Teleop runs once every time a DS packet is received. DS packet is sent every 20ms (not 50ms). Any functionality (like a kicker with delays) which can't complete in well under 20ms must be written as a state machine if it's going to be put in the same thread as teleop. Or it can be run in a separate thread, using block waiting for delays. Many hours of confusion and frustration could be avoided if a way could be found to ensure that new programmers are taught these simple concepts.
30-08-2010 20:58
Lucario231I have made the DOC files into PDF versions. That should clear up some viewing issues.