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)