Go to Post One team at the UTC regional scored over 2100 points in autonomous alone. I was highly impressed. - Greg Marra [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-02-2012, 16:26
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Fixed indexes for Target Info VI

We have the Rectangular Target Processing VI imported into the code, but here's the problem: The Target info array is built in the order that they're seen. This means that, if something obstructs the camera on the field, the Target Info VI could potentially be reordered, making it hard to pick a certain target to aim at reliably. So, we'd like to be able to make sure that a target is assigned to a specific index depending on its information, instead.

I have some idea of how to accomplish this: Since the targets are cross-shaped, you can expect them to have close X and Y values; the top and bottom targets will have close X values, and the left/right ones will have similar Ys. From there you could compare certain values to see if they're one of the groups you want, and place them in an array accordingly.

I think the logic is sound (feel free to correct me if I'm wrong), but I'm having trouble with the nuts-and-bolts implementation of it, in LabVIEW code.
Reply With Quote
  #2   Spotlight this post!  
Unread 17-02-2012, 21:53
CRLS97 CRLS97 is offline
Registered User
FRC #0097
 
Join Date: Jan 2011
Location: Cambridge
Posts: 28
CRLS97 is an unknown quantity at this point
Re: Fixed indexes for Target Info VI

Quote:
Originally Posted by Pirate programe View Post
We have the Rectangular Target Processing VI imported into the code, but here's the problem: The Target info array is built in the order that they're seen. This means that, if something obstructs the camera on the field, the Target Info VI could potentially be reordered, making it hard to pick a certain target to aim at reliably. So, we'd like to be able to make sure that a target is assigned to a specific index depending on its information, instead.

I have some idea of how to accomplish this: Since the targets are cross-shaped, you can expect them to have close X and Y values; the top and bottom targets will have close X values, and the left/right ones will have similar Ys. From there you could compare certain values to see if they're one of the groups you want, and place them in an array accordingly.

I think the logic is sound (feel free to correct me if I'm wrong), but I'm having trouble with the nuts-and-bolts implementation of it, in LabVIEW code.
From what I recall, and someone correct me if I'm wrong, the targets are in order by the calculated distance. It doesn't matter which target the camera sees first, but whichever target is closest according to the calculations done in the Vision VI.

Also you could go about doing what you just mentioned but also note that since it's in a cross shape and the x returns a value from -1 to 1 and y from -1 to 1, you could also find the maximum and minimum values of x for the horizontal ones and max/min of y for the vertical and use the index # returned and use the information you need from there..
Reply With Quote
  #3   Spotlight this post!  
Unread 18-02-2012, 00:54
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Fixed indexes for Target Info VI

Our target selection code loops through the target info array looking for the maximum or minimum x or y, depending on which hoop the gunner wants it to track. The result is a single target cluster of x, y, and distance. The x value gets used to rotate the turret; y and distance control shot angle and strength.
Reply With Quote
  #4   Spotlight this post!  
Unread 18-02-2012, 12:29
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Fixed indexes for Target Info VI

Quote:
Our target selection code loops through the target info array looking for the maximum or minimum x or y, depending on which hoop the gunner wants it to track. The result is a single target cluster of x, y, and distance. The x value gets used to rotate the turret; y and distance control shot angle and strength.
Yeah, come to think of it, looping through the array to select a target would be what I'd have done. I'm not sure how to loop through an array in LabVIEW, though...
Reply With Quote
  #5   Spotlight this post!  
Unread 19-02-2012, 09:27
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Fixed indexes for Target Info VI

Quote:
Originally Posted by Pirate programe View Post
I'm not sure how to loop through an array in LabVIEW, though...
Use a For loop and wire an array into it. I think the tunnel will be set to auto-index by default. What gets passed into the loop is the individual elements of the array, one at a time for each iteration of the loop.
Reply With Quote
  #6   Spotlight this post!  
Unread 19-02-2012, 11:01
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Fixed indexes for Target Info VI

Quote:
Originally Posted by Alan Anderson View Post
Use a For loop and wire an array into it. I think the tunnel will be set to auto-index by default. What gets passed into the loop is the individual elements of the array, one at a time for each iteration of the loop.
Ah, I see. So then we compare the max/min x or y values to the Position cluster in the Target Info array?

I tried using the Search 1D Array function for this, but it seems that it requires a full cluster of inputs, instead of just one value...
Reply With Quote
  #7   Spotlight this post!  
Unread 19-02-2012, 11:55
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,751
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: Fixed indexes for Target Info VI

Yes, Search 1D doesn't have a wildcard ability, so what you do instead is to loop through and compare just the elements you compare about. It is really pretty easy once you do it.

Greg McKaskle
Reply With Quote
  #8   Spotlight this post!  
Unread 19-02-2012, 12:24
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Fixed indexes for Target Info VI

Actually, do I need the For loop at all? I already have the Max and Min values, so I think I can just send those to the turret depending on the button being pressed.

...no, i can't because then I'd be moving a turret with a Y value *facepalm*
Attached Thumbnails
Click image for larger version

Name:	scrncap.png
Views:	29
Size:	30.9 KB
ID:	11989  

Last edited by Pirate programe : 19-02-2012 at 12:35.
Reply With Quote
  #9   Spotlight this post!  
Unread 19-02-2012, 12:37
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,751
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: Fixed indexes for Target Info VI

Well, you are correct, with enough cascading code you don't need a loop. I can't see the rest of the diagram, but I assume you have a four element index, and you have written code that sorts four elements. When you have time, you may want to play with looping to generalize it since adding a few more elements quickly adds code.

Greg McKaskle
Reply With Quote
  #10   Spotlight this post!  
Unread 19-02-2012, 12:47
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Fixed indexes for Target Info VI

The rest of the diagram is merely gathering all the values I need for the core logic (the Index Array function opening up the Target Info arra, the Joystick Get retrieving joystick buttons).

Yeah, four-element array is correct, since at the most we'll only really be seeing four targets at one time, right?

EDIT: The For loop doesn't seem to be iterating over the array.

I suppose that might be because of the Boolean checking- it's supposed to iterate over the array until it finds a value for which the checking is true.
Attached Thumbnails
Click image for larger version

Name:	scrncap.png
Views:	21
Size:	28.8 KB
ID:	11992  

Last edited by Pirate programe : 19-02-2012 at 13:50.
Reply With Quote
  #11   Spotlight this post!  
Unread 19-02-2012, 18:03
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,751
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: Fixed indexes for Target Info VI

If you breakpoint and turn on the execution hilighting when you get to the loop, I think I'll see that it really is iterating and that it is likely a logic issue.

For what you are doing, the flat sort is fine. I was just encouraging you to work on the general one sometime. It is also trivial to do this in a new VI that doesn't even run on the robot. Then you type numbers into the array and run your subVI until you KNOW that it works. Then you replace the flat code with the subVI. This is called refactoring and is a great technique to practice.

Greg McKaskle
Reply With Quote
  #12   Spotlight this post!  
Unread 20-02-2012, 11:49
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Fixed indexes for Target Info VI

Here's the basic program.

I probed the cluster value that's coming out of the auto-indexed tunnel, and it doens't seem to be changing from the 0th index, namely the first target.

EDIT: actually, no, I used a breakpoint, and it does seem to be changing...
Attached Files
File Type: vi Untitled 1.vi (13.2 KB, 9 views)

Last edited by Pirate programe : 20-02-2012 at 11:54.
Reply With Quote
  #13   Spotlight this post!  
Unread 20-02-2012, 19:54
propionate's Avatar
propionate propionate is offline
Team co-lead and LabVIEW programmer
AKA: Stephen
FRC #1732 (Hilltopper Robotics)
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Milwaukee
Posts: 93
propionate is on a distinguished road
Re: Fixed indexes for Target Info VI

Sorry to resurrect a (possibly?) dead thread, but I couldn't figure out the code that was posted here. I am trying to isolate the X value of the target with the highest Y value (aka the 3rd level hoop). I've attached the code that I made, could someone let me know if this will work?

EDIT: The input to the case structure determines which X value is output'ed
Attached Thumbnails
Click image for larger version

Name:	camera.PNG
Views:	14
Size:	27.0 KB
ID:	12021  
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


All times are GMT -5. The time now is 11: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