當前位置: 首頁>>代碼示例>>Python>>正文


Python NetworkTable.getTable方法代碼示例

本文整理匯總了Python中networktables.NetworkTable.getTable方法的典型用法代碼示例。如果您正苦於以下問題:Python NetworkTable.getTable方法的具體用法?Python NetworkTable.getTable怎麽用?Python NetworkTable.getTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在networktables.NetworkTable的用法示例。


在下文中一共展示了NetworkTable.getTable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def main():
    NetworkTable.setIPAddress('10.19.37.2')
    NetworkTable.setClientMode()
    NetworkTable.initialize()
    sd = NetworkTable.getTable('SmartDashboard')
    #ms_list = []
    while True:
            time.sleep(0.1)
            start_time = datetime.now()

            # returns the elapsed milliseconds since the start of the program
            vision(sd)
            dt = datetime.now() - start_time
            ms = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000 + dt.microseconds / 1000.0
            #ms_list.append(ms)
            print ms
            #print np.mean(ms_list)
            cv2.destroyAllWindows() 
開發者ID:Elysium1937,項目名稱:Millennium-Eye,代碼行數:20,代碼來源:Falafel.py

示例2: main

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def main():
    NetworkTable.setIPAddress('10.19.37.2')
    NetworkTable.setClientMode()
    NetworkTable.initialize()
    sd = NetworkTable.getTable('SmartDashboard')
    #ms_list = []
    while True:
            time.sleep(0.1)
            start_time = datetime.now()

            # returns the elapsed milliseconds since the start of the program
            vision(sd)
            dt = datetime.now() - start_time
            ms = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000 + dt.microseconds / 1000.0
            print ms
            cv2.destroyAllWindows() 
開發者ID:Elysium1937,項目名稱:Millennium-Eye,代碼行數:18,代碼來源:Falafel Vision Processing.py

示例3: extra_processing

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def extra_processing(pipeline):
    """
    Performs extra processing on the pipeline's outputs and publishes data to NetworkTables.
    :param pipeline: the pipeline that just processed an image
    :return: None
    """
    center_x_positions = []
    center_y_positions = []
    widths = []
    heights = []

    # Find the bounding boxes of the contours to get x, y, width, and height
    for contour in pipeline.filter_contours_output:
        x, y, w, h = cv2.boundingRect(contour)
        center_x_positions.append(x + w / 2)  # X and Y are coordinates of the top-left corner of the bounding box
        center_y_positions.append(y + h / 2)
        widths.append(w)
        heights.append(y)
    # Publish to the '/vision' network table
    table = NetworkTable.getTable("/vision")
    table.putValue("centerX", NumberArray.from_list(center_x_positions))
    table.putValue("centerY", NumberArray.from_list(center_y_positions))
    table.putValue("width", NumberArray.from_list(widths))
    table.putValue("height", NumberArray.from_list(heights)) 
開發者ID:FRC5254,項目名稱:GRIP-Raspberry-Pi-3,代碼行數:26,代碼來源:sample_vision.py

示例4: extra_processing

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def extra_processing(pipeline):
    """
    Performs extra processing on the pipeline's outputs and publishes data to NetworkTables.
    :param pipeline: the pipeline that just processed an image
    :return: None
    """
    center_x_positions = []
    center_y_positions = []
    widths = []
    heights = []

    # Find the bounding boxes of the contours to get x, y, width, and height
    for contour in pipeline.filter_contours_output:
        x, y, w, h = cv2.boundingRect(contour)
        center_x_positions.append(x + w / 2)  # X and Y are coordinates of the top-left corner of the bounding box
        center_y_positions.append(y + h / 2)
        widths.append(w)
        heights.append(y)
    print(center_x_positions)
    # Publish to the '/vision' network table
    table = NetworkTable.getTable("/vision")
    table.putValue("centerX", NumberArray.from_list(center_x_positions))
    table.putValue("centerY", NumberArray.from_list(center_y_positions))
    table.putValue("width", NumberArray.from_list(widths))
    table.putValue("height", NumberArray.from_list(heights)) 
開發者ID:FRC5254,項目名稱:GRIP-Raspberry-Pi-3,代碼行數:27,代碼來源:ip_vision.py

示例5: __init__

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def __init__(self, table, silent=False):
        super().__init__()
        LOG.info('NetworkTablePublisher initialized for table "{}"'.format(table))

        try:
            NetworkTable.checkInit()
        except RuntimeError:
            # An exception is raised if NetworkTables was initialized
            pass
        else:
            # Since no exception was raised, NetworkTables is not initialized
            error = 'NetworkTables is not initialized. Call "init_network_tables()" '
            error += 'prior to instantiating this class.'
            raise RuntimeError(error)

        # For access by other methods for debugging
        self.table_name = table

        # We'll be pushing our own values to this table
        self.nt = NetworkTable.getTable(table)

        # Don't log anything to the console if silent
        self.silent = silent 
開發者ID:teamresistance,項目名稱:remho,代碼行數:25,代碼來源:network.py

示例6: __init__

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def __init__(self, options):
        NetworkTable.setIPAddress(options.ip)
        NetworkTable.setClientMode()
        NetworkTable.initialize()
        logger.debug('Networktables Initialized')

        self.current_session = None

        self.sd = NetworkTable.getTable('/')
        self.sd.addConnectionListener(self)

        with open(options.config) as config_file:
            self.config = json.load(config_file)

        self.run() 
開發者ID:frc1418,項目名稱:RobotRecorder,代碼行數:17,代碼來源:recorder.py

示例7: drive_distance

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def drive_distance(self, initial_call):
        if initial_call:
            self.drive.field_centric = False
            self.sd = NetworkTable.getTable('SmartDashboard')
            self.tracker.enable()

        self.y_ctrl.move_to(self.drive_distance_feet)
        self.sd.putNumber('TESTING: ', self.y_ctrl.get_position())

        if self.y_ctrl.is_at_location():
            self.next_state('finish') 
開發者ID:frc1418,項目名稱:2017-robot,代碼行數:13,代碼來源:auto_tests.py

示例8: __init__

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def __init__(self):
        target = None

        nt = NetworkTable.getTable('/camera')
        nt.addTableListener(self._on_target, True, 'target')

        self.aimed_at_angle = None
        self.aimed_at_x = None 
開發者ID:frc1418,項目名稱:2017-robot,代碼行數:10,代碼來源:auto_align.py

示例9: __init__

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def __init__(self):
        self.size = None
        self.thresh_low = np.array([self.thresh_hue_lower, self.thresh_sat_lower, self.thresh_val_lower], dtype=np.uint8)
        self.thresh_high = np.array([self.thresh_hue_high, self.thresh_sat_high, self.thresh_val_high], dtype=np.uint8)

        self.nt = NetworkTable.getTable('/camera/processor') 
開發者ID:frc1418,項目名稱:2017-robot,代碼行數:8,代碼來源:image_processor.py

示例10: __init__

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def __init__(self, dio_number=0):
        self.range_finder_counter = wpilib.Counter(dio_number, mode=wpilib.Counter.Mode.kPulseLength)
        self.range_finder_counter.setSemiPeriodMode(highSemiPeriod=True)
        self.range_finder_counter.setSamplesToAverage(10)
        self._smoothed_d = 0.0
        self.sd = NetworkTable.getTable('SmartDashboard') 
開發者ID:thedropbears,項目名稱:pysteamworks,代碼行數:8,代碼來源:range_finder.py

示例11: __init__

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def __init__( self, capture, log, settings ):
        # port="",filters="", hsv=False, original=True, in_file="", out_file="", display=True
        self.limits = {}
        # Pass the log object
        self.log = log
        log.init( "initializing saber_track Tracker" )
        self.settings = settings
        # If the port tag is True, set the
        if settings["port"] != "":
            logging.basicConfig( level=logging.DEBUG )
            NetworkTable.setIPAddress( settings["port"] )
            NetworkTable.setClientMode( )
            NetworkTable.initialize( )
            self.smt_dash = NetworkTable.getTable( "SmartDashboard" )

        # initialize the filters. If the filter is the default: "", it will not create trackbars for it.
        self.init_filters( settings["filters"] )

        # Deal with inputs and outputs
        self.settings["out_file"] = str( self.settings["out_file"] ) # set the file that will be written on saved

        if settings["in_file"] != "":
            self.log.init( "Reading trackfile: " + settings["in_file"] + ".json" )
            fs = open( name + ".json", "r" ) # open the file under a .json extention
            data = json.loads( fs.read() )
            self.limits.update( data )
            fs.close( )


        # Localize the caputure object
        self.capture = capture
        # if there are any color limits (Upper and Lower hsv values to track) make the tracking code runs
        self.track = len( self.limits ) > 0

        self.log.info( "Tracking: " + str(self.track) )

    # The self.init_filters( filters ) function will take a string of filters and break it up by spaces
    # Each whitespace isolated string will become the name of a limit and trackbar.
    # Example, the self.init_filters( "hello world") would split the string into two windows, "hello" and "world"
    # The windows will be trackbars and will get their own tracking bounding box, tag, and binary color window 
開發者ID:Sabercat-Robotics-4146-FRC,項目名稱:Vision_Processing-2016,代碼行數:42,代碼來源:saber_track.py

示例12: __init__

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def __init__(self):
        print "Initializing NetworkTables..."
        NetworkTable.setClientMode()
        NetworkTable.setIPAddress("roborio-4761-frc.local")
        NetworkTable.initialize()
        self.table = NetworkTable.getTable("vision")
        print "NetworkTables initialized!" 
開發者ID:Team4761,項目名稱:2016-Vision,代碼行數:9,代碼來源:network.py

示例13: init_networktables

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def init_networktables():
	#TODO: Check to see if NetworkTables is already initialized
	if not using_networktables:
		raise Exception("Attempted to initialize NetworkTables while NetworkTables is disabled!")
	NetworkTable.setIPAddress(args.networktables_ip)
	NetworkTable.setClientMode()
	NetworkTable.initialize()
	global table
	table = NetworkTable.getTable("vision")
	log.info("Initialized NetworkTables")

# Loads dict into networktables 
開發者ID:Team4761,項目名稱:2016-Vision,代碼行數:14,代碼來源:vision.py

示例14: __init__

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def __init__(self):
        self.nt = NetworkTable.getTable('/camera')
        
        #Cameras
        self.piston_cam = cs.UsbCamera('Piston Cam', 0)
        self.piston_cam.setVideoMode(cs.VideoMode.PixelFormat.kMJPEG, 160, 120, 35) #160 vs. 120
        
        self.piston_cam.setExposureAuto()
        self.piston_cam.getProperty('backlight_compensation').set(5)
        
        #self.piston_cam.setExposureManual(35)
        #self.piston_cam.setBrightness(65)
        #test = self.piston_cam.getProperty("exposure_absolute")
        #print(self.piston_cam.getProperty("exposure_absolute"))
        
        
        self.piston_server = cs.MjpegServer('httpserver', 1181)
        self.piston_server.setSource(self.piston_cam)
        
        if self.secondary_cam:
            self.light_ring_cam = cs.UsbCamera('Light Ring Cam', 0)
            self.light_ring_cam.setVideoMode(cs.VideoMode.PixelFormat.kMJPEG, 320, 240, 20)
            
            # This only seems to affect automatic exposure mode
            # -> higher value means it lets more light in when facing a big light
            self.light_ring_cam.getProperty('backlight_compensation').set(5)
            
            #Image Processing
            self.cvsink = cs.CvSink('cvsink')
            self.cvsink.setSource(self.light_ring_cam)
            
            self.cvsource = cs.CvSource('cvsource', cs.VideoMode.PixelFormat.kMJPEG, 320, 240, 20)
            
            #Streaming Servers
            
            
            
            #self.ring_stream = cs.MjpegServer("ring server", 1182)
            #self.ring_stream.setSource(self.light_ring_cam)
            
            if self.STREAM_CV:
                self.cv_stream = cs.MjpegServer('cv stream', 1183)
                self.cv_stream.setSource(self.cvsource)
            
            #Blank mat
            self.img = np.zeros(shape=(320, 240, 3), dtype=np.uint8)
            
            self.processor = ImageProcessor() 
開發者ID:frc1418,項目名稱:2017-robot,代碼行數:50,代碼來源:vision.py

示例15: setup

# 需要導入模塊: from networktables import NetworkTable [as 別名]
# 或者: from networktables.NetworkTable import getTable [as 別名]
def setup(self):
        """
        Called after injection.
        """

        # Put all the modules into a dictionary
        self.modules = {
            'front_right': self.fr_module,
            'front_left': self.fl_module,
            'rear_left': self.rl_module,
            'rear_right': self.rr_module
        }

        self.sd = NetworkTable.getTable('SmartDashboard')

        self._requested_vectors = {
            'fwd': 0,
            'strafe': 0,
            'rcw': 0
        }

        self._requested_angles = {
            'front_right': 0,
            'front_left': 0,
            'rear_left': 0,
            'rear_right': 0
        }

        self._requested_speeds = {
            'front_right': 0,
            'front_left': 0,
            'rear_left': 0,
            'rear_right': 0
        }

        self._predicted_position = {
            'fwd': 0,
            'strafe': 0,
            'rcw': 0
        }

        self.predict_position = False

        # Variables that allow enabling and disabling of features in code
        self.allow_reverse = False
        self.squared_inputs = True
        self.snap_rotation = False
        self.wait_for_align = False
        self.threshold_input_vectors = True

        self.width = (22/12)/2
        self.length = (18.5/12)/2

        self.request_wheel_lock = False 
開發者ID:frc1418,項目名稱:2017-robot,代碼行數:56,代碼來源:swervedrive.py


注:本文中的networktables.NetworkTable.getTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。