View Single Post
  #7   Spotlight this post!  
Unread 06-02-2012, 20:24
JohnGilb JohnGilb is offline
Programming Mentor, Drive Mentor
FRC #0488
 
Join Date: Mar 2011
Rookie Year: 2003
Location: Redmond, WA
Posts: 116
JohnGilb has a spectacular aura aboutJohnGilb has a spectacular aura aboutJohnGilb has a spectacular aura about
Re: "Squaring" robot

Attached are some simplified examples (didn't create the sensors, just made some variables for distance) that show what I mean.

Each case structure can "interrupt" the one before it, with the last one having priority. In this example, the last case structure is the "In Range" detection that keeps you from moving if you're centered enough.


*Some other small notes:
-It's better to get the references to motors/sensors once outside the loop and use them many times inside the loop. Calling into the refnum registry can be expensive if you're doing it all the time.
-Where does this code live? You said it's inside some other VI.
Attached Thumbnails
Click image for larger version

Name:	TrueCases.png
Views:	27
Size:	21.5 KB
ID:	11769  Click image for larger version

Name:	FalseCases.png
Views:	14
Size:	20.8 KB
ID:	11770  
Reply With Quote