def __init__(self): """initializes all values to presets or None if need to be set """ NetworkTable.initialize(server='10.44.80.2') #Current Roborio address NetworkTable.setUpdateRate(.02) self.numberPublish = NetworkTable.getTable('/GRIP/myContoursReport') self.__hsl_threshold_hue = [56.6546762589928, 83.28925638990128] self.__hsl_threshold_saturation = [229.31654676258992, 255.0] self.__hsl_threshold_luminance = [ 13.758992805755396, 51.51952461799658 ] self.hsl_threshold_output = None self.__find_contours_input = self.hsl_threshold_output self.__find_contours_external_only = False self.find_contours_output = None self.__filter_contours_contours = self.find_contours_output self.__filter_contours_min_area = 125.0 self.__filter_contours_min_perimeter = 0.0 self.__filter_contours_min_width = 0.0 self.__filter_contours_max_width = 1000.0 self.__filter_contours_min_height = 0.0 self.__filter_contours_max_height = 1000.0 self.__filter_contours_solidity = [0, 100] self.__filter_contours_max_vertices = 1000000.0 self.__filter_contours_min_vertices = 0.0 self.__filter_contours_min_ratio = 0.0 self.__filter_contours_max_ratio = 1000.0 self.filter_contours_output = None
def __init__(self, receiverIP): try: # IPAddress can be static ip ("10.49.15.2" or name:"roboRIO-4915-FRC"/"localhost") NetworkTable.setUpdateRate(.01) # default is .05 (50ms/20Hz), .01 (10ms/100Hz) NetworkTable.setIPAddress(receiverIP) NetworkTable.setClientMode() NetworkTable.initialize() self.sd = NetworkTable.getTable("SmartDashboard") # we communcate target to robot via VisionTarget table self.targetTable = self.sd.getSubTable("VisionTarget") # robot communicates to us via fields within the VisionControl SubTable # we opt for a different table to ensure we to receive callbacks from our # own writes. self.controlTable = self.sd.getSubTable("VisionControl") self.controlTable.addConnectionListener(self.connectionListener) self.controlTable.addTableListener(self.visionControlEvent) self.control = Control() self.target = Target() self.fpsHistory = [] self.lastUpdate = time.time() theComm = self except: xcpt = sys.exc_info() print("ERROR initializing network tables", xcpt[0]) traceback.print_tb(xcpt[2])