View Single Post
  #13   Spotlight this post!  
Unread 27-10-2011, 01:25
SuperS_5's Avatar
SuperS_5 SuperS_5 is offline
[Certified LabVIEW Developer]
FRC #1219
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Canada
Posts: 140
SuperS_5 will become famous soon enoughSuperS_5 will become famous soon enough
Re: Advanced LabVIEW programming?

Hi,
I ended up getting really busy after posting on this thread, and then totally forgot about it. The recent bump brought it back into my attention.

Quote:
Also, I've been trying to apply classes to FRC robotics programming, but I never got particularly far. What exactly would you encapsulate?
At the the of my first reply, I didn't realize that OOP was not supported for the cRIO. This years update will fix that though.
One of the principles of OOP in LabVIEW is to make nearly everything a subVI. If you need data out of the OOP wire, you use a specialized subVI. (Accessor) All methods can be made into subVIs. I especially force this when working with specialized code like database calls, or any kind of math algorithm. These can change often, so if they are subVIs, it makes it to modify later.

Different "Objects" would each be a separate class. For example, the vision system would have it's own class. Acquiring test images, might come from a web camera on your laptop. The testing web camera, and the robot camera would each be a child class of the vision class. (This is starting to get into dynamic dispatching, which should be in a different thread.)
In particular the various physical devices that you are controlling would each be a different class. For Example:
  • Drive Train
  • Compressor
  • Arm System
  • Grabber System
    -- The solenoids and sensors would each be a separate class. (But not children of the above 2 systems.)


Quote:
Can you explain why you'd use functional globals instead of the actual Global that we use in the FRC framework? Is there a performance/readability/usability benefit?
I use functional globals a default over LabVIEW globals. The LabVIEW global is great for beginners, but, it can be limiting. (Just like using a boolean instead of a TypeDef'd Enum as an action.) The functional global allows for init code, calculations, and other interesting code to be done directly on the data before/after the stack. This allows for modification of the data globally for specific actions. This makes it a precursor to OOP. I generally make the functional global as part of the class that owns that data.


Quote:
However, compile/build time has been an issue
The newer versions of LabVIEW have improved on this a bit. LabVIEW 2011 has made significant improvements in the area. For FPGA coding, I have seen single wire edits take up to a minute or more in LabVIEW 2009 and below.
Unfortunately the only solution for this year is to get faster computers. I didn't actually see much a problem in this area for FRC on my laptop, even though I was using a virtual machine to code in. (I have an i5 at 2.4GHz and at the time 4GB of RAM)
  • System memory is the single biggest factor in LabVIEW performance up to 3GB of RAM. After that, other system resources become bottle necks for code development.

Quote:
Some things that helped us were to avoid organizing code in subvis and avoiding while loops in teleop and autonomous
I would highly recommend not avoiding subVIs. This is a very basic coding practice in LabVIEW. If you are having troubles with the compile time, maybe we can help you out in another thread. The alternative to the file reading is using FP controls, either directly on the subVI or the Driver Station control panel. (The former being easier, but requires running from the development system.)

Nested Loops, except in very distinct cases, are usually very bad practice. Unfortunately it is way too easy to do. Generally junior programmers will do this when they don't know about the framework that they are working within. This applies to FRC and the professional world.
__________________
Mike B

Last edited by SuperS_5 : 27-10-2011 at 09:06.
Reply With Quote