01-15-2012 10:18 AM
Can someone share his/her experience in the design pattern used in the FIRST Robotics FRC competition? Will the "producer-consumer" structure work on CRIO with LabVIEW real-time? or are there any advantages of teaching kids the design patterns (knowing we have only six and a half weeks to complete the project)? I have been using LabVIEW at work for a while, but never used CRIO and LabVIEW realtime. This year is my first year of being a mentor of a local high school robotics team. Thanks for your help.
01-15-2012 01:15 PM
Hey IanRen,
There are definitely some design patterns that will be useful to know for use in the FRC competition. Particulary I think state machines are essential for any kind of autonomous (or advanced teleop) code. The producer consumer strucutre will work on the cRIO with LabVIEW real time but for use with robotics (since you usually want to respond to stimuli as quickly as possible) I don't see it used very often. You will however use parrallel loop structures where some loops run slower since you don't need to do everything at the same rate with your robot code. While this is not the traditional producer consumer where you are offloading big chunks of data to the consumer loop it is still a useful structure for FRC and it would definitely be useful to review with your team the proper ways to share data between those parrallel loops.
01-16-2012 11:20 AM
You might be approaching this backwards. Start by figuring out what you want the program to accomplish, then see if it follows a design pattern. Don't start with the design pattern and then try to fit the problem into it. If you teach producer-consumer and then don't use it, you're going to have confused students; or, the students will take that to mean that's the way you should do it and will contort the code to fit that pattern, regardless of whether it's appropriate. Keep the FRC code as simple as possible and use the structure that's provided in the templates. Producer-consumer is generally driven by events and interrupts, none of which occur in the FRC code - all the IO and user interaction is set up for polling, which is simpler for new programmers. What would you see as a producer loop in the FRC system?