|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
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.
|
|
#2
|
||||
|
||||
|
Re: Fixed indexes for Target Info VI
Quote:
|
|
#3
|
|||||
|
|||||
|
Re: Fixed indexes for Target Info VI
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.
|
|
#4
|
||||
|
||||
|
Re: Fixed indexes for Target Info VI
Quote:
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... |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
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* Last edited by Pirate programe : 19-02-2012 at 12:35. |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
||||
|
||||
|
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. Last edited by Pirate programe : 19-02-2012 at 13:50. |
|
#9
|
|||
|
|||
|
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 |
|
#10
|
||||
|
||||
|
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... Last edited by Pirate programe : 20-02-2012 at 11:54. |
|
#11
|
||||
|
||||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|