コード例 #1
0
def check_for_thrusters():
    ''' Checks for a response from thrusters on a given port '''
    # Stop all thrusters
    for key in individual_thrusts.keys():
        individual_thrusts[key] = 0

    declared_ports = []
    for port in thruster_ports.values():
        if port not in declared_ports:
            declared_ports.append(port)

    declared_ports.sort(key=lambda p: p.port_name)

    fprint('Declared ports:')
    for i, p in enumerate(declared_ports):
        print '{})'.format(i), p.port_name

    fprint('Select a port by index: ')
    sel = int(raw_input())

    start_id = 0
    end_id = 127
    fprint('Checking for thrusters with id\'s in [{}, {}]'.format(
        start_id, end_id))

    found_motor_ids, avg_turnaround_time = declared_ports[
        sel].get_node_ids_on_port(start_id, end_id)
    fprint('Responding motor ids:\t\t\t{}'.format(
        te.Printer().set_cyan.bold(found_motor_ids)))
    fprint('Average packet turnaround time:\t{} seconds'.format(
        te.Printer().set_cyan.bold(avg_turnaround_time)))
コード例 #2
0
def check_for_thrusters():
    ''' Checks for a response from thrusters on a given port '''
    active_thrusters = set()
    fprint("Active thrusters: {}".format(list(active_thrusters)))

    declared_ports = []
    for port in thruster_ports.values():
        if port not in declared_ports:
            declared_ports.append(port)

    declared_ports.sort(key=lambda p: p.port_name)

    fprint('Declared ports:')
    for i, p in enumerate(declared_ports):
        print "{})".format(i), p.port_name

    fprint("Select a port by index: ")
    sel = int(raw_input())

    start_id = 0
    end_id = 10
    fprint("Checking for thrusters with id's in [{}, {}]".format(
        start_id, end_id))

    found_motor_ids, avg_turnaround_time = \
        declared_ports[sel].get_motor_ids_on_port(start_id, end_id)
    fprint("Responding motor ids:\t\t\t{}".format(
        te.Printer().set_cyan.bold(found_motor_ids)))
    fprint("Average packet turnaround time:\t{} seconds".format(
        te.Printer().set_cyan.bold(avg_turnaround_time)))
コード例 #3
0
def ports_from_layout(layout):
    '''Load and handle the thruster bus layout'''
    port_dict = {}
    thruster_definitions = layout['thrusters']

    msg = te.Printer('Instantiating thruster_port:')
    for port_info in layout['thruster_ports']:
        try:
            port = port_info['port']
            thruster_names = port_info['thruster_names']
            thruster_port = thrust_comm.thruster_comm_factory(
                port_info, thruster_definitions, fake=False)

            # Add the thrusters to the thruster dict
            for name in thruster_names:
                port_dict[name] = thruster_port

            s = list(thruster_port.online_thruster_names)
            fprint(
                msg.reset.text('\n\tName: ').set_yellow.text(port).reset.text(
                    '\n\tMotor id\'s on port: ').set_cyan.bold(s).reset)

        except SubjuGatorException:
            pass

    return port_dict
コード例 #4
0
def ports_from_layout(layout):
    '''Load and handle the thruster bus layout'''
    port_dict = {}
    thruster_definitions = layout['thrusters']

    msg = te.Printer('Instantiating thruster_port:')
    for port_info in layout['thruster_ports']:
        try:
            port = port_info['port']
            thruster_names = port_info['thruster_names']
            thruster_port = thruster_comm_factory(port_info,
                                                  thruster_definitions,
                                                  fake=False)

            # Add the thrusters to the thruster dict
            for name in thruster_names:
                port_dict[name] = thruster_port

            s = str(
                np.sort([x[1] for x in thruster_port.thruster_dict.items()
                         ]).tolist())
            fprint(
                msg.reset.text("\n\tName: ").set_yellow.text(port).reset.text(
                    "\n\tMotor id's on port: ").set_cyan.bold(s).reset)

        except serial.serialutil.SerialException:
            pass

    return port_dict
コード例 #5
0
def main():
    nh = yield txros.NodeHandle.from_argv("startup_checker")
    check_order = [
        ThrusterChecker(nh, "Thrusters"),
        CameraChecker(nh, "Cameras"),
        StateEstChecker(nh, "State Estimation"),
        ShoreControlChecker(nh, "Shore Control")
    ]

    p = text_effects.Printer()
    yield txros.util.nonblocking_raw_input(
        str(
            p.bold("\n  >>>>").text("   Press return when ").negative(
                "sub8.launch").text(" is running.")))
    print p.newline().set_blue.bold(
        "-------- Running self checks...").newline()

    for check in check_order:
        try:
            yield check.tx_init()
            yield nh.sleep(0.1)
            yield check.do_check()
        except Exception as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()
            check.err_msg(e, exc_tb.tb_lineno)

        del check

    print p.newline().set_blue.bold("-------- Finished!").newline()
    reactor.stop()
コード例 #6
0
    def __init__(self, nh, name):
        self.nh = nh
        self.name = name

        self.p = text_effects.Printer()