Go to Post I had a fight with my robot once during competition. I felt bad about it and apologized. - Tommy F. [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 16-12-2008, 20:37
sparrowkc sparrowkc is offline
Registered User
AKA: Mark
FRC #1986 (Team Titanium)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Lees Summit
Posts: 114
sparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to behold
I'm trying not to hate labview but...

I'm getting really frustrated trying to modify the default code. I have no interest in using a pre made 2 wheel drive code block; I want to control motors individualy. Do I really have to add a motordevref block to the robotdata control for every motor I want to control? I'm thinking there has to be a way to create a bundle without specifying default values, but I cannot figure it out. I have labview with the first update installed, is the current code template necessarily the last one?
Reply With Quote
  #2   Spotlight this post!  
Unread 16-12-2008, 21:01
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,513
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: I'm trying not to hate labview but...

It's funny - my first year with the team (their second year) was the first year we really got into the coding. I kept saying the same thing about the ifi code. "Boy, this is a silly way to do it." "Boy, that makes no sense!"

By the second year though, we had figured out why they did things the way they did. We were also able to reuse and improve modules we had written the year before.

Now, I find myself and our team members going through the same learning process all over again. I'm reasonably sure that while I'm saying "why the heck do I have to do THAT" right now, in a year or two once I've figured it out it will all make far more sense... and I won't "hate" it quite so much.
Reply With Quote
  #3   Spotlight this post!  
Unread 16-12-2008, 22:17
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: I'm trying not to hate labview but...

I agree with Tom. At first, code doesn't always make sense, but as you work with it you begin to delve into it more and it becomes more understandable.

Also, if you want a different approach to code, there's always C++. Once you get past the initial syntax barrier, it's not as hard as you would think. There's great tutorials like www.leancpp.com and the default code is fairly easy to understand.
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 16-12-2008, 22:27
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,617
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: I'm trying not to hate labview but...

In the Advanced framework, yes you do have to add a motordevref to the RobotData cluster for every motor you want to control. This is by design so you can initialize it in the Begin.vi, use it in the various other VIs, and close it in the Finish.vi. Adding the controls to the cluster isn't too complicated, though. Especially once they're already there anyways. If you really can't be bothered, you can add an array of motordevrefs and initialize that array and keep track of where you've put each motor ref, instead of using the nice labels in the cluster. In any case, you shouldn't need to set up default values for any of the data elements you add to the RobotData cluster. Leave them all at their default values, then initialize them in Begin.vi. Creating devref constants or otherwise avoiding calling ???? Open.vi for things can muck things up by not properly reserving resources.

That said, if you're having difficulties with the Advanced template, try switching to the Basic template. More or less everything is in the same VI, so there's no RobotData cluster to configure and carry around.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #5   Spotlight this post!  
Unread 16-12-2008, 22:31
Woodie Flowers Award
JDNovak JDNovak is offline
Mentor
AKA: John Novak
FRC #0016 (Bomb Squad)
Team Role: Engineer
 
Join Date: Jan 2005
Rookie Year: 1996
Location: Mountain Home, AR
Posts: 52
JDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond reputeJDNovak has a reputation beyond repute
Re: I'm trying not to hate labview but...

I agree that the default drive base doesn't work for any of our robots. Three independantly steered wheels require independant control of speed and direction. The default code is only useful as an example of what we need. Our students just finished recreating the Labview code in the release framework this evening and this is what they came up with.

In the Begin .vi they replaced the robotbase open with a PWM open for each motor (8 in all). They also opened the joysticks, analog inputs, etc. Then they bundled all the DevRefs and passed them through to the mode case statement in RobotMain. It sure makes a big mess in the TypeDefs panel and all the front panels but it looks like the only way.

Then they unbundled the DefRefs in the Teleop .vi and inserted all the steering code before setting the speed of each motor. This is their second attempt to control the entire robot and it is beginning to make sense enough to be able to understand the layout even though teleop is over two screens high.

I hope to post the code soon but they took it with them tonight to clean up. If you are interested I'll try to clarify some of this when I see the code again.

The short answer is there is no shortcut. I was able to write the equivelant code in the C++ iterative example a lot faster but it isn't as impressive and the kids really get more excited seeing the Labview code work. I still relate to assembly language better than object oriented languages.
Reply With Quote
  #6   Spotlight this post!  
Unread 16-12-2008, 22:50
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: I'm trying not to hate labview but...

Quote:
Originally Posted by sparrowkc View Post
I'm getting really frustrated trying to modify the default code. I have no interest in using a pre made 2 wheel drive code block; I want to control motors individualy. Do I really have to add a motordevref block to the robotdata control for every motor I want to control? I'm thinking there has to be a way to create a bundle without specifying default values, but I cannot figure it out. I have labview with the first update installed, is the current code template necessarily the last one?
If you open up the pre made 2 wheel drive subVI, it creates two motor dev refs and builds an array from them. You can follow this lead and have a single array entry in the robotdata which holds all of your motor refs. The slight downside to using an array is remembering what slot in the array is for what motor. There are plenty of ways for handling that, or you could build a cluster -- similar to a struct or record in other languages -- and there you can give the elements of the cluster descriptive names. The default value as the controls are dropped should be fine as their value will really be defined by the Open. All LV controls except refnums support a default value, and it is quite useful, but not always necessary.

Greg McKaskle
Reply With Quote
  #7   Spotlight this post!  
Unread 17-12-2008, 23:11
sparrowkc sparrowkc is offline
Registered User
AKA: Mark
FRC #1986 (Team Titanium)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Lees Summit
Posts: 114
sparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to behold
Re: I'm trying not to hate labview but...

Yup, arrays are the way to go. Create an array in begin.vi with all your motordevrefs wired into it, right click on the output terminal, and create a constant. Copy paste the constant into the robotdata global type def. The array can be grown and shrunk in begin.vi by creating more inputs on the build array block, and the constant won't need to be changed and won't take up three screens worth of space when you use all 20 pwm ports.

Why isn't there a way to create clusters like this? I keep wishing for a build cluster block that simply builds a cluster with n number of named elements from n number of inputs, instead of one that replaces elements in a constant.
Reply With Quote
  #8   Spotlight this post!  
Unread 19-12-2008, 09:19
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: I'm trying not to hate labview but...

Quote:
Originally Posted by sparrowkc View Post
Why isn't there a way to create clusters like this? I keep wishing for a build cluster block that simply builds a cluster with n number of named elements from n number of inputs, instead of one that replaces elements in a constant.
Good question. I suppose one reason is that when you look at a cluster of identical elements, and an array of the same elements, they are very similar, and can in fact be converted back and forth pretty easily.

I'm not sure if it is done in the dashboard, but it is pretty common to take an array datatype, cast to a cluster of say eight elements, and display in a cluster arranged in an octagon or something. The math on the diagram can now work on the array, often more easily than the cluster, but the user sees the discrete elements arranged in a meaningful way. If you decide to do this, beware that the LV node to convert from array to cluster has no way of knowing how many elements may be in the array or how big to make the cluster, so there is a popup menu item for setting the size of the cluster.

Also, rereading your question, maybe you are looking for the old fashioned bundle node rather then the newer bundle by name. The bundle does work like the build array, you grow it and wire stuff up. It has a middle terminal in case you are simply replacing elements, but doesn't require it as the bundle by name does. The advantages to the named node are that it is more verbose and somewhat more documented code, and when the cluster changes, it does a better job of using the names to match up the elements. The replace mode of the bundle only works well when adding to the end of your cluster type.

Greg McKaskle
Reply With Quote
  #9   Spotlight this post!  
Unread 19-12-2008, 14:04
Luke Pike's Avatar
Luke Pike Luke Pike is offline
Programmer
FRC #1501 (THRUST)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Huntington
Posts: 114
Luke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to all
Re: I'm trying not to hate labview but...

Quote:
Originally Posted by Kevin Sevcik View Post
That said, if you're having difficulties with the Advanced template, try switching to the Basic template. More or less everything is in the same VI, so there's no RobotData cluster to configure and carry around.
Uh, is it a problem that I've been using the basic framework all along? I saw it as an option, but when I started, I used the basic framework and never tried the advanced. Guess I better take a look at it.
Reply With Quote
  #10   Spotlight this post!  
Unread 19-12-2008, 16:18
PhilBot's Avatar
PhilBot PhilBot is offline
Get a life? This IS my life!
AKA: Phil Malone
FRC #1629 (GaCo: The Garrett Coalition)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Maryland
Posts: 744
PhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond repute
Re: I'm trying not to hate labview but...

Quote:
Originally Posted by Luke Pike View Post
Uh, is it a problem that I've been using the basic framework all along? I saw it as an option, but when I started, I used the basic framework and never tried the advanced. Guess I better take a look at it.

It's funny. I actually find the "advanced" template easier to understand, because all the stuff isn't crammed on one page. The use of sub-vis heps to compartmentalize my understanding of the process.

However, back to SparrowKC's original question...

I think everyone is missing the easy way to do this.

How many wheel's you got? 4 probably.. so start out by changing the "Open 2 Wheels" VI to "Open 4 wheels".
You can do this simply by right clicking on the VI and selecting "Replace".
Go ahead and specify the other 2 PWM channels and wheel directions.

OK, now your device reference cluster holds references for 4 wheels.

You want to roll your own drive code.... no problem. Just don't use the standard Drive VIs.
You can access the refs in the cluster and do your own motor control.... how?
Just look inside the canned drive VI's (eg: Drive:ArcadeDrive) by double clicking them, and pulling up the Block Diagrams.
There's lots of flexibility built into them, so you may have to go a couple of levels deep to see the basic wheel control code, but a really good sample is found in RobotDrive:Motors.vi

Basically you use Drive:GetPwmRef, and then pass the ref to Motor:SetSpeed.

Now you have total freedom to roll your own code, with very little hacking of existing globals.
__________________
Phil Malone
Garrett Engineering And Robotics Society (GEARS) founder.
http://www.GEARSinc.org

FRC1629 Mentor, FTC2818 Coach, FTC4240 Mentor, FLL NeXTGEN Mentor

Last edited by PhilBot : 19-12-2008 at 16:21.
Reply With Quote
  #11   Spotlight this post!  
Unread 19-12-2008, 17:30
Luke Pike's Avatar
Luke Pike Luke Pike is offline
Programmer
FRC #1501 (THRUST)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Huntington
Posts: 114
Luke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to all
Re: I'm trying not to hate labview but...

Quote:
Originally Posted by PhilBot View Post
It's funny. I actually find the "advanced" template easier to understand, because all the stuff isn't crammed on one page. The use of sub-vis heps to compartmentalize my understanding of the process.
I took a look at the advanced template, your absolutely right. Much better layout.

As to the topic at hand, you just gotta experiment and try stuff. If what PhilBot suggested does not work for you, then you're gonna have to have a motor ref for every motor in the global vi. I think you can put them in a cluster like the robot data so it's all in one package, then unbundle by name the different motors when you need them.
Reply With Quote
  #12   Spotlight this post!  
Unread 19-12-2008, 19:48
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: I'm trying not to hate labview but...

Characterizing the two templates, the advanced template was actually developed first. If your team is interested in writing very much code, I think this is a better place to begin.

Based upon feedback from the beta, we then built the basic template with an eye towards eliminating SW concepts and getting results in the shortest amount of time. This resulted in code that is a bit flat and will be harder to maintain throughout a season, but it seems to fit the bill.

There are many possible variations, and I expect that many teams will develop their own framework. I hope they are shared, and I hope to incorporate the good ideas into the templates in coming years.

Greg McKaskle
Reply With Quote
  #13   Spotlight this post!  
Unread 21-12-2008, 23:45
PhilBot's Avatar
PhilBot PhilBot is offline
Get a life? This IS my life!
AKA: Phil Malone
FRC #1629 (GaCo: The Garrett Coalition)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Maryland
Posts: 744
PhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond repute
Re: I'm trying not to hate labview but...

Quote:
Originally Posted by JDNovak View Post
Then they unbundled the DefRefs in the Teleop .vi and inserted all the steering code before setting the speed of each motor. This is their second attempt to control the entire robot and it is beginning to make sense enough to be able to understand the layout even though teleop is over two screens high.
If your code is expanding past a reasonable screen size, then you probably need to start creating your own sub-vi's.

Look at your code and see where you have duplicated code that just varies by a specific parameter (eg a pair of motor drives).

Take that code, select the common parts and then use EDIT/Create SubVI.

The code will cet condensed out into a sepparate file and all the wires that passed into the selected area will become connections on the new VI. Double click it and you will see the extracted code. DO a "Save as" and give it a good name. On the Front panel, double click the icon (top right corner) and edit you own graphic.

Now, go back to the main block diagram and replace the other instances of that code with your own VI. Once you build your own VI, you'll never look back
__________________
Phil Malone
Garrett Engineering And Robotics Society (GEARS) founder.
http://www.GEARSinc.org

FRC1629 Mentor, FTC2818 Coach, FTC4240 Mentor, FLL NeXTGEN Mentor
Reply With Quote
  #14   Spotlight this post!  
Unread 22-12-2008, 02:09
keen101's Avatar
keen101 keen101 is offline
Ubuntu Linux User
no team
Team Role: College Student
 
Join Date: Dec 2007
Rookie Year: 2005
Location: Loveland, CO
Posts: 228
keen101 is a jewel in the roughkeen101 is a jewel in the roughkeen101 is a jewel in the roughkeen101 is a jewel in the rough
Re: I'm trying not to hate labview but...

Yeah, sounds like sub vi's can be very handy.

check out these video's for some tutorial on creating custom sub vi's.

http://www.lvmastery.com/files/FIRST..._Part1(2).html

(^^this one starts out boring, but has some useful info for part2,
and is still much less boring than the official NI video's)

---------------------------------------------------------------------

http://www.lvmastery.com/files/First...c12_Part2.html


---------------------------------------------------------------------

http://www.lvmastery.com/files/First...12_Part3b.html
Reply With Quote
  #15   Spotlight this post!  
Unread 22-12-2008, 22:41
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Re: I'm trying not to hate labview but...

Quote:
Originally Posted by Greg McKaskle View Post
If you open up the pre made 2 wheel drive subVI, it creates two motor dev refs and builds an array from them. You can follow this lead and have a single array entry in the robotdata which holds all of your motor refs. The slight downside to using an array is remembering what slot in the array is for what motor. There are plenty of ways for handling that, or you could build a cluster -- similar to a struct or record in other languages -- and there you can give the elements of the cluster descriptive names. The default value as the controls are dropped should be fine as their value will really be defined by the Open. All LV controls except refnums support a default value, and it is quite useful, but not always necessary.

Greg McKaskle
To cause less mistakes in the implementation of the array of Motor TypeDefs, you can create a ring terminal TypeDef (Strict), and use it as a constant on the block diagram. It's effectively the same as unbundling a cluster by name on the block diagram, but it's much neater on the Front Panel.
__________________
-- Marshal Horn
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm Trying to Mirror a Rig Popper99 3D Animation and Competition 3 09-02-2008 20:17
pic: i'm on the loose, but.. thatphotochick Extra Discussion 4 22-05-2006 17:31
frc_camera not working but labview does Issues Programming 7 18-01-2006 19:23
Some things i'm trying to understand on Kevin's Accelerometer Code Squall Programming 2 03-02-2005 12:01
I'm trying to contact Teams 234 and 269... archiver 2001 1 24-06-2002 03:23


All times are GMT -5. The time now is 19:16.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi