当前位置: 首页>>代码示例>>Python>>正文


Python NetworkTable.getTable方法代码示例

本文整理汇总了Python中networktables.NetworkTable.getTable方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkTable.getTable方法的具体用法?Python NetworkTable.getTable怎么用?Python NetworkTable.getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在networktables.NetworkTable的用法示例。


在下文中一共展示了NetworkTable.getTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
 def __init__(self, ip, name):
     NetworkTable.setIPAddress(ip)
     NetworkTable.setClientMode()
     NetworkTable.initialize()
     self.visionNetworkTable = NetworkTable.getTable(name)
     if constants.SENDTOSMARTDASHBOARD:
         constants.smartDashboard = NetworkTable.getTable("SmartDashboard")
开发者ID:core2062,项目名称:CORE2016-VISION,代码行数:9,代码来源:networkTableManager.py

示例2: _write

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
    def _write(self):
        """Internal method that actually writes the table to a file. This is
        called in its own thread when :func:`save` is called.
        """
        with self.lock:
            with self.fileLock:
                self.fileLock.notify_all()

            with open(self.FILE_NAME, "w") as output:
                output.write("[Preferences]\n")
                for key in self.keylist:
                    value = self.values.get(key, "")
                    comment = self.comments.get(key, "")
                    if comment:
                        output.write(comment)

                    output.write(key)
                    output.write(self.VALUE_PREFIX)
                    output.write(value)
                    output.write(self.VALUE_SUFFIX)

                output.write(self.endComment)

            try:
                from networktables import NetworkTable

                NetworkTable.getTable(self.TABLE_NAME).putBoolean(self.SAVE_FIELD, False)
            except ImportError:
                pass
开发者ID:granjef3,项目名称:robotpy-wpilib,代码行数:31,代码来源:preferences.py

示例3: __init__

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
    def __init__(self, fakerobot):
        try:
            if fakerobot:
                NetworkTable.setIPAddress("localhost")
            else:
                NetworkTable.setIPAddress("roboRIO-4915-FRC")
            NetworkTable.setClientMode()
            NetworkTable.initialize()

            self.sd = NetworkTable.getTable("SmartDashboard")
            self.visTable = self.sd.getSubTable("Vision")
            self.connectionListener = ConnectionListener()
            self.visTable.addConnectionListener(self.connectionListener)
            self.visTable.addTableListener(self.visValueChanged)
            self.targetState = targetState.TargetState(self.visTable)
            self.targetHigh = True
            self.autoAimEnabled = False
            self.imuHeading = 0
            self.fpsHistory = []
            self.lastUpdate = time.time()

        except:
            xcpt = sys.exc_info()
            print("ERROR initializing network tables", xcpt[0])
            traceback.print_tb(xcpt[2])
开发者ID:KNX32542,项目名称:2016-Stronghold,代码行数:27,代码来源:robotCnx.py

示例4: run_server

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
def run_server(serial_conn):
    sd = NetworkTable.getTable("SmartDashboard")
    
    def value_changed(table, key, value, is_new):
        debug("value_changed(): key='%s', value=%s, is_new=%s" % (key, value, is_new))
        if key in receiveList and receiveList[key] == value:
            debug("value_changed(): update was caused by receive")
            del receiveList[key]
        else:
            if isinstance(value, numbers.Number):
                try:
                    send_int(serial_conn, key, round(value))
                except OverflowError:
                    info("Integer too big to be sent: key=%s, value=%s" % (key, value));
            elif isinstance(value, bool):
                send_bool(serial_conn, key, value)

    sd.addTableListener(value_changed)
    
    for name, value in recieve_packets(serial_conn):
        receiveList[name] = value
        if isinstance(value, numbers.Number):
            sd.putNumber(name, value)
        elif isinstance(value, bool):
            sd.putBoolean(name, value)
开发者ID:RobotsByTheC,项目名称:SmartDashboardVex,代码行数:27,代码来源:SmartDashboardVex.py

示例5: initNetworktables

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
def initNetworktables():
    logging.basicConfig(level=logging.DEBUG)         # to see messages from networktables
    NetworkTable.setIPAddress('127.0.0.1')
    # NetworkTable.setIPAddress('roborio-5260.local')
    NetworkTable.setClientMode()
    NetworkTable.initialize()
    return NetworkTable.getTable('Pi')
开发者ID:greg7mdp,项目名称:frc-shooter-software,代码行数:9,代码来源:towertrack.py

示例6: __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

示例7: createObjects

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
 def createObjects(self):
     self.logger = logging.getLogger("robot")
     self.sd = NetworkTable.getTable('SmartDashboard')
     self.intake_motor = wpilib.CANTalon(14)
     self.shooter_motor = wpilib.CANTalon(12)
     self.defeater_motor = wpilib.CANTalon(1)
     self.joystick = wpilib.Joystick(0)
     self.gamepad = wpilib.Joystick(1)
     self.pressed_buttons_js = set()
     self.pressed_buttons_gp = set()
     # needs to be created here so we can pass it in to the PIDController
     self.bno055 = BNO055()
     self.vision = Vision()
     self.range_finder = RangeFinder(0)
     self.heading_hold_pid_output = BlankPIDOutput()
     Tu = 1.6
     Ku = 0.6
     Kp = Ku * 0.3
     self.heading_hold_pid = wpilib.PIDController(0.6,
                                                  2.0 * Kp / Tu * 0.1,
                                                  1.0 * Kp * Tu / 20.0 * 0,
                                                  self.bno055, self.heading_hold_pid_output)
     self.heading_hold_pid.setTolerance(3.0*math.pi/180.0)
     self.heading_hold_pid.setContinuous(True)
     self.heading_hold_pid.setInputRange(-math.pi, math.pi)
     self.heading_hold_pid.setOutputRange(-1.0, 1.0)
     self.intake_motor.setFeedbackDevice(wpilib.CANTalon.FeedbackDevice.QuadEncoder)
     self.intake_motor.reverseSensor(False)
开发者ID:dbadb,项目名称:pystronghold,代码行数:30,代码来源:robot.py

示例8: on_enable

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
    def on_enable(self):
        """
            Constructor.

            :param robotDrive: a `wpilib.RobotDrive` object
            :type rf_encoder: DriveEncoders()
            :type lf_encoder: DriveEncoders()

        """

        # Hack for one-time initialization because magicbot doesn't support it
        if not self.enabled:
            nt = NetworkTable.getTable('components/autoaim')
            nt.addTableListener(self._align_angle_updated, True, 'target_angle')

        self.isTheRobotBackwards = False
        self.iErr = 0
        # set defaults here
        self.y = 0
        self.rotation = 0
        self.squaredInputs = False

        self.halfRotation = 1

        self.gyro_enabled = True

        self.align_angle = None
开发者ID:frc1418,项目名称:2016-robot,代码行数:29,代码来源:drive.py

示例9: __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) )
开发者ID:Sabercat-Robotics-4146-FRC,项目名称:Vision_Processing-2016,代码行数:37,代码来源:saber_track.py

示例10: __init__

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
 def __init__(self, tote_motor):
     
     self.sd = NetworkTable.getTable('SmartDashboard')
     
     self.toteLimitLSensor = wpilib.DigitalInput(0) ##Left limit switch
     self.toteLimitRSensor = wpilib.DigitalInput(1) ##Right limit switch
     
     self.longDistanceLSensor = SharpIR2Y0A02(1)  # # Robot's left
     self.longDistanceRSensor = SharpIR2Y0A02(3)  # # Robot's right
     self.shortDistanceLSensor = SharpIRGP2Y0A41SK0F(2)  # # Robot's left
     self.shortDistanceRSensor = SharpIRGP2Y0A41SK0F(7)  # # Robot's right
             
     self.leftSensor = CombinedSensor(self.longDistanceLSensor, 22, self.shortDistanceLSensor, 6)
     self.rightSensor = CombinedSensor(self.longDistanceRSensor, 22, self.shortDistanceRSensor, 6)
     
     self.tote_motor = tote_motor
     
     self.in_range = False
     self.in_range_start = None
     
     # Premature optimization, but it looks nicer
     self._tote_exclude_range = set()
     
     # measured using the calibration routine
     interference = [(1031, 1387), (1888, 2153), (4544, 4895), (5395, 5664), (8008, 8450)]
     
     #for i in [1033, 2031, 4554, 5393, 7902]:
     for r1, r2 in interference:
         for j in range(r1, r2):
             self._tote_exclude_range.add(j)
     
     self.update()
开发者ID:DavidD121,项目名称:2015-robot,代码行数:34,代码来源:sensor.py

示例11: getTable

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
 def getTable(cls):
     if cls.table is None:
         from networktables import NetworkTable
         cls.table = NetworkTable.getTable("SmartDashboard")
         hal.report(hal.UsageReporting.kResourceType_SmartDashboard,
                    hal.UsageReporting.kSmartDashboard_Instance)
     return cls.table
开发者ID:Seamonsters-2605,项目名称:robotpy-wpilib,代码行数:9,代码来源:smartdashboard.py

示例12: main

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
def main():
    cap = cv2.VideoCapture(1)
    
    #Network Tables Setup
    logging.basicConfig(level=logging.DEBUG)
    NetworkTable.setIPAddress('10.32.56.2')
    NetworkTable.setClientMode()
    NetworkTable.initialize()
    nt = NetworkTable.getTable('SmartDashboard')

    while cap.isOpened():

        _,frame=cap.read()
        hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
        #Range for green light reflected off of the tape. Need to tune.
        lower_green = np.array(constants.LOWER_GREEN, dtype=np.uint8)
        upper_green = np.array(constants.UPPER_GREEN, dtype=np.uint8)

        #Threshold the HSV image to only get the green color.
        mask = cv2.inRange(hsv, lower_green, upper_green)
        #Gets contours of the thresholded image.
        _,contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
        #Draw the contours around detected object
        cv2.drawContours(frame, contours, -1, (0,0,255), 3)

        #Get centroid of tracked object.
        #Check to see if contours were found.
        if len(contours)>0:
            #find largest contour
            cnt = max(contours, key=cv2.contourArea)
            #get center
            center = get_center(cnt)
            cv2.circle(frame, center, 3, (0,0,255), 2)
            if(center[0] != 0 and center[1]!=0):
                center_str_x = "x = "+str(center[0])
                center_str_y = "y = "+str(center[1])
                font = cv2.FONT_HERSHEY_SIMPLEX
                cv2.putText(frame, "Center", constants.TEXT_COORDINATE_1, font, 0.7, (0,0,255), 2)
                cv2.putText(frame, center_str_x, constants.TEXT_COORDINATE_2, font, 0.7, (0,0,255), 2)
                cv2.putText(frame, center_str_y, constants.TEXT_COORDINATE_3, font, 0.7, (0,0,255), 2)
                angle, direction = get_offset_angle(center[0], center[1])
                cv2.putText(frame, "Angle: "+str(angle),constants.TEXT_COORDINATE_4, font, 0.7, (0,0,255), 2)
                nt.putNumber('CameraAngle', angle)
                cv2.putText(frame, "Turn "+direction, constants.TEXT_COORDINATE_5, font, 0.7, (0,0,255), 2)
                if direction == right:
                    nt.putNumber('Direction', 0)
                else:
                    nt.putNumber('Direction', 1)

        #show image
        cv2.imshow('frame',frame)
        cv2.imshow('mask', mask)
        cv2.imshow('HSV', hsv)

        #close if delay in camera feed is too long
        k = cv2.waitKey(1) & 0xFF
        if k == 27:
            break

    cv2.destroyAllWindows()
开发者ID:apache8080,项目名称:FRC_VisionTracking_2016,代码行数:62,代码来源:tower_tracking.py

示例13: __init__

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
    def __init__(self, sensors, forkLift, drive, autolift):
        """
            :param sensors: Sensors object
            :type sensors: :class:`.Sensor`
        """

        self.sensors = sensors
        self.forkLift = forkLift
        self.drive = drive
        self.autolift = autolift
        sd = NetworkTable.getTable("SmartDashboard")

        self.rotate_constant = sd.getAutoUpdateValue("Align|Rotation Constant", 0.015)
        self.fwd_constant = sd.getAutoUpdateValue("Align|FwdConstant", 175.0)

        self.drive_speed = sd.getAutoUpdateValue("Align|Speed", -0.3)
        # self.threshold = sd.getAutoUpdateValue('Align|DistThreshold', 3)
        self.strafe_speed = sd.getAutoUpdateValue("Align|StrafeSpeed", 0.2)

        self.binPos = sd.getAutoUpdateValue("binPosition", 0)

        # in centimeters
        self.sensor_spacing = 18

        self.next_pos = None
        self.aligning = False
        self.aligned = False

        self.can_aligning = True
        self.can_aligned = False
开发者ID:DavidD121,项目名称:2015-robot,代码行数:32,代码来源:alignment.py

示例14: __init__

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
	def __init__(self, robotDrive, gyro, backInfrared):
		'''
			Constructor. 
			
			:param robotDrive: a `wpilib.RobotDrive` object
		'''
		self.isTheRobotBackwards = False
		# set defaults here
		self.x = 0
		self.y = 0
		self.rotation = 0
		self.gyro = gyro
		
		self.angle_constant = .040
		self.gyro_enabled = True
		
		self.robotDrive = robotDrive
		
		# Strafe stuff
		self.backInfrared = backInfrared
		
		sd = NetworkTable.getTable('SmartDashboard')
		self.strafe_back_speed = sd.getAutoUpdateValue('strafe_back', .23)
		self.strafe_fwd_speed = sd.getAutoUpdateValue('strafe_fwd', -.23)
		
		# Top range: 50 is slow
		# Low range: 10 is too much acceleration
		self.strafe_adj = sd.getAutoUpdateValue('strafe_adj', 35)
开发者ID:DavidD121,项目名称:2015-robot,代码行数:30,代码来源:drive.py

示例15: getTable

# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import getTable [as 别名]
 def getTable():
     if SmartDashboard.table is None:
         from networktables import NetworkTable
         SmartDashboard.table = NetworkTable.getTable("SmartDashboard")
         hal.HALReport(hal.HALUsageReporting.kResourceType_SmartDashboard,
                       hal.HALUsageReporting.kSmartDashboard_Instance)
     return SmartDashboard.table
开发者ID:arilotter,项目名称:robotpy-wpilib,代码行数:9,代码来源:smartdashboard.py


注:本文中的networktables.NetworkTable.getTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。