Go to Post sigh, I started wondering why we weren't there than I realized it was in California. Thats a bit of a road trip... - Raumiester2010 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-02-2016, 21:32
szsz9 szsz9 is offline
Registered User
FRC #6000
 
Join Date: Feb 2016
Location: Los Angeles, CA
Posts: 5
szsz9 is an unknown quantity at this point
How to pause GRIP data input?

We are using GRIP for our image processing and we need to grab the information of a single contour. Currently it is not possible for us to eliminate all other contours, so instead we are using the largest contour to determine what the goal is.

We are currently finding the position of the largest contour in the array and finding that number value in another array (like center x, or height). This doesn't work because the smaller contours fluctuate a lot and the position of the goal/largest contour changes from the first time we get the data (area) to the second time we get the data (centerX, or height).

Is there any way to pause the input from the Network Tables? Or can we take a picture using the webcam and just analyze the picture?

Thanks
  #2   Spotlight this post!  
Unread 23-02-2016, 22:45
ThomasClark's Avatar
ThomasClark ThomasClark is offline
Registered User
FRC #0237
 
Join Date: Dec 2012
Location: Watertown, CT
Posts: 146
ThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud of
Re: How to pause GRIP data input?

This feature hasn't been documented yet, but yes, you can pause GRIP using NetworkTables if you're using the very latest release candidate (v1.3-rc1).


Code:
NetworkTable table = NetworkTable.getTable("GRIP");

table.putBoolean("run", false); // Stop GRIP without killing the process

doSomeStuffThatDoesntNeedVision();

table.putBoolean("run", true); // Start GRIP again
This should work if you just want to process a "snapshot" of the input, but keep in mind that there's always a little latency with NetworkTables updates, so you can't precisely control when GRIP starts and stops.

Quote:
This doesn't work because the smaller contours fluctuate a lot and the position of the goal/largest contour changes from the first time we get the data (area) to the second time we get the data (centerX, or height).
The latest NetworkTables protocol supports RPC "transactions", which should help fix this, but currently there's still work to be done in bringing support for this feature to the Java bindings.
__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC
  #3   Spotlight this post!  
Unread 23-02-2016, 23:14
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: How to pause GRIP data input?

Quote:
This doesn't work because the smaller contours fluctuate a lot and the position of the goal/largest contour changes from the first time we get the data (area) to the second time we get the data (centerX, or height).
You could just flash the data immediately... something like how I do ours

Code:
        self.rotateError = 0
        try:
            beta = self._getArray("area")
            x = self._getArray("centerX")
            y = self._getArray("centerY") 
            self.largestArea = 0
            self.largestIndex = -1
            for index in range(len(beta)):
                if beta[index] > self.largestArea:
                    self.largestIndex = index
                    self.largestArea = beta[index]
            if self.largestIndex != -1:
                wpilib.SmartDashboard.putNumber("Largest Area", beta[self.largestIndex])
                wpilib.SmartDashboard.putNumber("Largest x", x[self.largestIndex])
                wpilib.SmartDashboard.putNumber("Largest y", y[self.largestIndex])
                wpilib.SmartDashboard.putNumber("X Error", self.center_x - x[self.largestIndex])
                wpilib.SmartDashboard.putNumber("Rotate Error", self.degrees_per_x_error * (self.center_x - x[self.largestIndex]))
                wpilib.SmartDashboard.putNumber("Y Error", self.center_y - y[self.largestIndex])
                
                self.rotateError = self.degrees_per_x_error * (self.center_x - x[self.largestIndex])
                self.y = y[self.largestIndex]
            return
        except KeyError:
            return
        except IndexError:
            return
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
  #4   Spotlight this post!  
Unread 27-02-2016, 11:43
s-taylor s-taylor is offline
Scott Taylor
FRC #1735 (Green Reapers)
Team Role: Mentor
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Auburn, MA
Posts: 22
s-taylor has a spectacular aura abouts-taylor has a spectacular aura about
Re: How to pause GRIP data input?

In our testing of the system, we have seen the noise coming fast enough that successive calls to getArray() return different sized arrays (meaning the table updated asynchronously in the two cycles between the getArray() calls)

For now, I have solved this by checking the array size for all the elements, and if there is a mismatch I just punt that dataset. Even that isn't perfect because the array could have updated but be different sizes... but it's as close as I can get without an atomic operation.
Closed Thread


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 00:42.

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