Example #1
0
def init_network_tables():
    logging.basicConfig(level=logging.DEBUG)
    NetworkTables.enableVerboseLogging()
    NetworkTables.initialize(server='10.12.1.59')

    while (not NetworkTables.isConnected()):
        time.sleep(1)
        print("waiting")
def main(server_type):
    '''Main routine'''

    import argparse
    parser = argparse.ArgumentParser(description='2018 Vision Server')
    parser.add_argument('--calib', help='Calibration file for camera')
    parser.add_argument('--test',
                        action='store_true',
                        help='Run in local test mode')
    parser.add_argument(
        '--delay',
        type=int,
        default=0,
        help='Max delay trying to connect to NT server (seconds)')
    parser.add_argument('--verbose',
                        '-v',
                        action='store_true',
                        help='Verbose. Turn up debug messages')
    parser.add_argument('--files',
                        action='store_true',
                        help='Process input files instead of camera')
    parser.add_argument('input_files', nargs='*', help='input files')

    args = parser.parse_args()

    # To see messages from networktables, you must setup logging
    log_level = logging.DEBUG if args.verbose else logging.INFO
    logging.basicConfig(level=log_level,
                        format='%(asctime)s %(levelname)s: %(message)s')

    logging.info("cscore version '%s'" % cscore.__version__)
    logging.info("OpenCV version '%s'" % cv2.__version__)

    if args.test:
        # FOR TESTING, set this box as the server
        NetworkTables.enableVerboseLogging()
        NetworkTables.startServer()
    else:
        if args.verbose:
            # Turn up the noise from NetworkTables. VERY noisy!
            # DO NOT do this during competition, unless you are really sure
            NetworkTables.enableVerboseLogging()
        # NetworkTables.startClient('10.28.77.2')
        # Try startClientTeam() method; it auto tries a whole bunch of standard addresses
        NetworkTables.startClientTeam(7520)
        if args.delay > 0:
            wait_on_nt_connect(args.delay)
    calib_string = '{"camera_matrix": [[373.31641495, 0.0, 210.90913851], [0.0, 373.0841807, 113.30714513], [0.0, 0.0, 1.0]], "distortion": [[1.84199750e-01, -1.48673528e+00, 2.11833158e-03, 2.51929227e-04, 2.87637488e+00]]}'
    server = server_type(calib_string=calib_string, test_mode=args.test)

    if args.files:
        if not args.input_files:
            parser.usage()

        server.run_files(args.input_files)
    else:
        server.run()
    return
Example #3
0
def main(server_type):
    '''Main routine'''

    import argparse
    parser = argparse.ArgumentParser(description='2019 Vision Server')
    parser.add_argument('--calib',
                        required=True,
                        help='Calibration file for camera')
    parser.add_argument('--test',
                        action='store_true',
                        help='Run in local test mode')
    parser.add_argument('--verbose',
                        '-v',
                        action='store_true',
                        help='Verbose. Turn up debug messages')
    parser.add_argument('--files',
                        action='store_true',
                        help='Process input files instead of camera')
    parser.add_argument('input_files', nargs='*', help='input files')

    args = parser.parse_args()

    # To see messages from networktables, you must setup logging
    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    if args.test:
        # FOR TESTING, set this box as the server
        NetworkTables.enableVerboseLogging()
        NetworkTables.initialize()
    else:
        if args.verbose:
            # Turn up the noise from NetworkTables. VERY noisy!
            # DO NOT do this during competition, unless you are really sure
            NetworkTables.enableVerboseLogging()
        NetworkTables.initialize(server='10.2.93.2')

    server = server_type(calib_file=args.calib, test_mode=args.test)

    if args.files:
        if not args.input_files:
            parser.usage()

        server.run_files(args.input_files)
    else:
        server.run()
    return
Example #4
0
def main():
    '''Main routine'''

    import argparse
    parser = argparse.ArgumentParser(description='2018 Vision Server')
    parser.add_argument('--test',
                        action='store_true',
                        help='Run in local test mode')
    parser.add_argument('--verbose',
                        '-v',
                        action='store_true',
                        help='Verbose. Turn up debug messages')
    parser.add_argument('--files',
                        action='store_true',
                        help='Process input files instead of camera')
    parser.add_argument('--calib',
                        required=True,
                        help='Calibration file for camera')
    parser.add_argument('input_files', nargs='*', help='input files')

    args = parser.parse_args()

    # To see messages from networktables, you must setup logging
    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    if args.test:
        # FOR TESTING, set this box as the server
        NetworkTables.enableVerboseLogging()
        NetworkTables.initialize()
    else:
        NetworkTables.initialize(server='10.28.77.2')

    server = VisionServer2018(args.calib)

    if args.files:
        if not args.input_files:
            parser.usage()

        server.run_files(args.input_files)
    else:
        server.run()
    return
Example #5
0
#!/usr/bin/env python

from __future__ import print_function

# pip install pynetworktables

from networktables import NetworkTables

NetworkTables.enableVerboseLogging()
NetworkTables.initialize(server='roborio-3656-frc.local')
print("Connected says: %s" % NetworkTables.isConnected())

import time
time.sleep(2)

sd = NetworkTables.getTable('SmartDashboard')

print("Connected says: %s" % NetworkTables.isConnected())

#sd = NetworkTables.getTable('/')
stables = sd.getSubTables()
print("= NetworkTables %s = " % len(stables))
for st in stables:
    print("- '%s'" % st)
print(" ")


def ShowTable(sd):
    keys = sd.getKeys()
    print("= NetworkTables %s = " % len(keys))