View Single Post
  #10   Spotlight this post!  
Unread 15-02-2010, 15:52
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: sample code to move robot autonomously

If you have LEGO programmers who worked in Robolab, there is another way they might appreciate.

Create a VI for each main action - Drive X Distance, Turn X degrees, etc. It will be a blocking VI that is called once and expected to perform an action. It contains its own while loop and runs until it has reached its destination.
Then, create a "Flow" control and indicator on each one. Make the control and indicator inputs and outputs by right-clicking on the icon on the front panel, clicking "Show Connector". Click the position in the grid where you want the input to show up, then click the input. It will now appear the color of the data type. Do the same for the indicator (output). It dosen't matter what data type it is, I use Double because I like orange, but anything works.
In Autonomous Independent, place the blocks in the order of what you want to do. E.G. Drive_Straight for 18 inches, Turn -90 degrees, Drive_Straight 36 inches, etc.
Wire the Flow from one VI to the next in the order you would like them to execute. Since data must move from one VI to the next (Whatever data is on the Flow wire), LabVIEW will make the VI's execute sequentially.
Done. You might want to put common actions, such as wait x time or set kicker to kick in VI's too, just so you have a flow wire to wire between them.

I have a picture of an example. I don't have icons on my VI's since the graphics team is still making them, but I did label them in comments. I also put my VI's in a palatte, but that is more advanced and not really necessary.

I also posted my Drive Straight Vi.

If you prefer the loop-based method shown in previous posts, you can put it in Autonomous Iterative and it will be called at 50hz. You will need to replace the shift register with either a front panel control (local variable) or global variable.
Attached Thumbnails
Click image for larger version

Name:	auton_example.png
Views:	162
Size:	45.6 KB
ID:	8685  
Attached Files
File Type: vi drive_straight.vi (16.0 KB, 22 views)
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack

Last edited by apalrd : 15-02-2010 at 15:56.
Reply With Quote