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


Python networktables.NetworkTable类代码示例

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


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

示例1: _write

    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,代码行数:29,代码来源:preferences.py

示例2: open

    def open(self):
        logger.info("NetworkTables websocket opened")

        self.ioloop = IOLoop.current()
        self.nt = NetworkTable.getGlobalTable()
        NetworkTable.addGlobalListener(self.on_nt_change, immediateNotify=True)
        self.nt.addConnectionListener(self, immediateNotify=True)
开发者ID:computer-whisperer,项目名称:pynetworktables2js,代码行数:7,代码来源:handlers.py

示例3: __init__

 def __init__(self):
     
     NetworkTable.initialize()
     self.tf = TargetFinder.TargetFinder()
     self.tf.enabled = True
     
     cv2.namedWindow('img')
 
     for s in self.settings:
         self._create_trackbar(s)
开发者ID:frc2423,项目名称:2016,代码行数:10,代码来源:test.py

示例4: __init__

    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,代码行数:25,代码来源:robotCnx.py

示例5: __init__

 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,代码行数:7,代码来源:networkTableManager.py

示例6: createObjects

 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,代码行数:28,代码来源:robot.py

示例7: __init__

 def __init__(self, table, field):
     from networktables import NetworkTable
     if isinstance(table, NetworkTable):
         self.table = table
     else:
         self.table = NetworkTable.getTable(table)
     self.field = field
开发者ID:arilotter,项目名称:robotpy-wpilib,代码行数:7,代码来源:networkbutton.py

示例8: __init__

	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,代码行数:28,代码来源:drive.py

示例9: getTable

 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,代码行数:7,代码来源:smartdashboard.py

示例10: __init__

 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,代码行数:32,代码来源:sensor.py

示例11: __init__

    def __init__(self, robot):
        # Joysticks
        self.leftStick = wpilib.Joystick(JoystickMap.PORT_LEFT)
        self.rightStick = wpilib.Joystick(JoystickMap.PORT_RIGHT)
        self.controller = wpilib.Joystick(JoystickMap.PORT_CONTROLLER)

        self.smart_dashboard = NetworkTable.getTable("SmartDashboard")
开发者ID:Team236,项目名称:2015-Retro-Python,代码行数:7,代码来源:oi.py

示例12: run_server

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,代码行数:25,代码来源:SmartDashboardVex.py

示例13: __init__

    def __init__(self, update_callback):
        """
        :param update_callback: A callable with signature ```callable(update)``` for processing outgoing updates
        formatted as strings.
        """
        self.update_callback = update_callback
        self.nt = NetworkTable.getGlobalTable()
        NetworkTable.addGlobalListener(self._nt_on_change, immediateNotify=True)

        class Empty:
            pass
        self.conn_listener = Empty()
        self.conn_listener.connected = self._nt_connected
        self.conn_listener.disconnected = self._nt_disconnected

        self.nt.addConnectionListener(self.conn_listener, immediateNotify=True)
开发者ID:FRC830,项目名称:pynetworktables2js,代码行数:16,代码来源:nt_serial.py

示例14: on_enable

    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,代码行数:27,代码来源:drive.py

示例15: __init__

    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,代码行数:30,代码来源:alignment.py


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