|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
Rectangle (Target Info) Overlaying on the Dashboard?
Disclaimer: I know little of LabVIEW, I use C++ with the rest of 2200.
So I've got rectangle identification working quite smoothly in C++ but I'd like to see some target info on the LabVIEW Dashboard. Right now I'm just using the smart dashboard to print coordinates of the target. The 2010 Vision Demonstration project in WindRiver contains code to send an arbitrarily sized array of vision targets to the dashboard using the high priority dashboard packer. I want to duplicate this for rectangles. I know the following:
I've stripped down the dashboard to what I want and looked through some of the documentation in LabVIEW, but I'm missing a few concepts:
Code:
void RectangleTracker::SendVisionData() {
Dashboard &d = DriverStation::GetInstance()->GetHighPriorityDashboardPacker();
int n = matches.size();
n = (n <= 10) ? n : 10;
d.AddCluster(); {
for (int i = 0; i < n; i++) {
d.AddCluster(); {
d.AddI32((INT32)matches[i].corner[0].y);
d.AddI32((INT32)matches[i].corner[0].x);
d.AddI32((INT32)matches[i].corner[2].y);
d.AddI32((INT32)matches[i].corner[2].x);
}
d.FinalizeCluster();
}
}
d.FinalizeCluster();
d.Finalize();
}
Last edited by basicxman : 25-01-2012 at 22:58. |
|
#2
|
||||
|
||||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
My C++ skills are very rusty. Do you mind posting whatever you have attempted in LabVIEW so far? Could you post sample data from the string output of the high priority packet.
|
|
#3
|
||||
|
||||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
From what I read in this PDF (I have no idea if this PDF is even remotely on target.) I think I understand your structure. Essentially, you have to create a type-definition in LabVIEW to match the C++ code. (A custom control, with the typedef attribute set.) I believe that you have created a cluster with an array of clusters of box coordinates. If you do not wish to put anything else in that packet, the wrapping cluster is probably not needed.
I think below is what you want. The image is a snippet of the dashboard VI. The zip file, contains the typedef'd control. Apparently, CD doesn't allow uploading of ctl files. Dashboard TypeDef for basicxman.zip Disclaimer: I am very rusty in C++, and don't have any sample data to test this. |
|
#4
|
|||
|
|||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
Laptop battery is about to die so I'll post what I have so far tomorrow (I think what I have will be successful). But I found this:
http://code.google.com/p/team178firs...hboard+Main.vi |
|
#5
|
||||
|
||||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
I had to checkout the whole dashboard project, I ended up with a few cross-linked files when trying to open it in a standard project. After opening your whole Dashboard project I have noticed a few things.
|
|
#6
|
|||
|
|||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
I haven't looked through that project much, it's another teams I found on Google.
|
|
#7
|
|||
|
|||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
I've got this which builds but images don't display. http://dl.dropbox.com/u/96856/Camera...tDashboard.zip
|
|
#8
|
||||
|
||||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
Generally in LabVIEW, data "flows" on wires. Data on all inputs to a program block must be available before the block can execute. Data on a wire is not available until the source function block has completed execution. A function block is any structure, native function, or subVI. This means that your vision loop would not execute until the receive data loop completed. (Meaning that this is serial, and not parallel) The value that the vision loop would use, would be the very last value that was received before the receive loop exited. One solution is to use a local variable. (I prefer something called "functional globals"/"LV2 style globals", but they are a bit more advanced. There many articles about them.)
I have added a local variable below. I wouldn't recommend hiding the control that it uses. (Poor style.) If you do, we can look at a different solution. Dashboard Main_basicxman.vi |
|
#9
|
|||
|
|||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
Quote:
|
|
#10
|
|||
|
|||
|
Re: Rectangle (Target Info) Overlaying on the Dashboard?
Ran it, getting an image now. However the Unflatten from String VI is giving an error code - 116.
According to the manual: Quote:
EDIT 2: I forgot to use pack an array: Code:
void RectangleTracker::SendVisionData() {
Dashboard &d = DriverStation::GetInstance()->GetHighPriorityDashboardPacker();
int n = (numCurrentMatches <= 10) ? numCurrentMatches : 10;
d.AddCluster(); {
d.AddArray(); {
for (int i = 0; i < n; i++) {
d.AddCluster(); {
d.AddI16((INT16)matches[i].corner[0].y);
d.AddI16((INT16)matches[i].corner[0].x);
d.AddI16((INT16)matches[i].corner[2].y);
d.AddI16((INT16)matches[i].corner[2].x);
}
d.FinalizeCluster();
}
}
d.FinalizeArray();
}
d.FinalizeCluster();
d.Finalize();
}
Last edited by basicxman : 27-01-2012 at 16:22. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|