def telemetry_init():
    robot = 'roborio-501-frc.local'  # set robot name

    bot_address_found = False
    while not bot_address_found:
        try:
            robot_ip = None
            robot_ip = socket.gethostbyname(robot)  # determine robot IP
            if robot_ip is not None:
                bot_address_found = True
        except socket.gaierror:
            print("Unable to find robot IP Address.")
            continue

    nt_init = False
    while not nt_init:
        try:
            NT.initialize(server=robot_ip)  # initialize client
        except:
            continue
        try:
            vision_table = NT.getTable('SmartDashboard')
        except:
            NT.stop()
            NT.destroy()
            continue
        vision_table.putBoolean('connected', True)
        pullback = vision_table.getBoolean('connected', None)
        if pullback:
            nt_init = True
        else:
            continue
    else:
        return vision_table
def nt_init(robot_address):
    """Initialize network tables

    Arguments:
        robot_address {str} -- Address for the roborio

    Returns:
        object -- The vision table from the network tables
    """
    bot_address_found = False
    while not bot_address_found:
        try:
            robot_ip = None
            robot_ip = socket.gethostbyname(
                robot_address)  # determine robot IP
            if robot_ip is not None:
                print("INFO: Found robot at " + robot_ip)
                bot_address_found = True
        except socket.gaierror:
            # this will loop until we find the robot
            print("WARNING: Unable to find robot IP Address.")
            continue

    nt_init = False
    while not nt_init:
        try:
            NT.initialize(server=robot_ip)  # initialize client
        except:
            continue  # this will loop until we connect to the robot
        try:
            vision_table = NT.getTable('SmartDashboard')
        except:
            NT.stop()
            NT.destroy()
            continue
        vision_table.putBoolean('connected', True)
        pullback = vision_table.getBoolean('connected', None)
        if pullback:
            nt_init = True
        else:
            continue
    else:
        return vision_table
Example #3
0
def nt_init(robot_address):
    """
    Initialize network tables
    :parameter robot address
    :return camera network table
    """
    bot_address_found = False
    while not bot_address_found:
        try:
            robot_ip = None
            robot_ip = socket.gethostbyname(
                robot_address)  # determine robot IP
            if robot_ip is not None:
                bot_address_found = True
        except socket.gaierror:
            print("WARNING: Unable to find robot IP Address.")
            continue

    nt_init = False
    while not nt_init:
        try:
            NT.initialize(server=robot_ip)  # initialize client
        except:
            continue
        try:
            vision_table = NT.getTable('SmartDashboard')
        except:
            NT.stop()
            NT.destroy()
            continue
        vision_table.putBoolean('connected', True)
        pullback = vision_table.getBoolean('connected', None)
        if pullback:
            nt_init = True
        else:
            continue
    else:
        return vision_table
def init_nt():
    robot = 'roborio-501-frc.local'  # set robot name
    robot_ip = socket.gethostbyname(robot)  # determine robot IP
    nt_init = False

    while not nt_init:
        try:
            NT.initialize(server=robot_ip)  # initialize client
        except:
            continue
        try:
            vision_table = NT.getTable('SmartDashboard')
        except:
            NT.stop()
            NT.destroy()
            continue
        vision_table.putBoolean('Vision.pullback', True)
        pullback = vision_table.getBoolean('Vision.pullback', None)
        if pullback:
            nt_init = True
        else:
            continue
    else:
        return vision_table
Example #5
0
def nt_init():
    #NetworkTables.setIPAddress('10.5.1.141')
    #NetworkTables.setClientMode()
    #NetworkTables.initialize(server='10.5.1.141')
    # port 1735
    try:
        NetworkTables.initialize(server='10.5.1.193')
        init = True
    except:
        print("Unable to initialize network tables.")
        init = False
    try:
        camera_table = NetworkTables.getTable("Camera")
    except:
        print("unable to get camera networktable")
        NetworkTables.stop()
        NetworkTables.destroy()
        init = False
    if not init:
        time.sleep(1)
        print("retrying networktables initialization.")
        return nt_init()
    else:
        return camera_table