def queue_program(username, password, label):
    queue = ProgramQueue(username, password)
    try:
        rc = queue.login()
    except:
        rc = False
    if not rc:
        QMessageBox.critical(
            main_window, main_window.tr('Login failed'),
            main_window.tr('Could not log in to the program queue.'))
        return

    output = StringIO()
    storage = SimpleFormat(output)
    serialize(storage)
    program_data = output.getvalue()
    output.close()

    try:
        id = queue.upload_program(program_data, label)
    except:
        id = False
    if not id:
        QMessageBox.critical(
            main_window, main_window.tr('Upload failed'),
            main_window.tr('Could not upload program to queue.'))
        return
    try:
        queue.logout()
    except:
        pass
    QMessageBox.information(
        main_window, main_window.tr('Uploaded program'),
        main_window.tr('Uploaded program (%d) successfully.') % id)
Exemplo n.º 2
0
def change_input_method():
    global manniquin_controllers_loaded
    global joint_observer
    index = main_window.input_method_comboBox.currentIndex()
    input_method = main_window.input_method_comboBox.itemData(index)
    print 'change_input_method()', index

    manniquin_controllers = ['r_arm_controller_loose', 'l_arm_controller_loose', 'head_traj_controller_loose']
    standard_controllers = ['r_arm_controller', 'l_arm_controller', 'head_traj_controller']
    if input_method == INPUT_METHOD_ROBOT:
        # setup controllers for manniquin mode
        if not manniquin_controllers_loaded:
            # load controllers once
            print 'change_input_method()', 'load manniquin controllers'
            manniquin_controllers_loaded = load_controllers(manniquin_controllers)
            if not manniquin_controllers_loaded:
                QMessageBox.critical(main_window, main_window.tr('Loading controllers failed'), main_window.tr('Could not load manniquin controllers.'))
        # switch to manniquin controllers
        success = switch_controllers(manniquin_controllers, standard_controllers)
        if success:
            joint_observer.start()
    else:
        # restore standard controllers
        success = switch_controllers(standard_controllers, manniquin_controllers)
        if success:
            joint_observer.stop()
    if not success:
        QMessageBox.critical(main_window, main_window.tr('Switching controllers failed'), main_window.tr('Could not switch controllers.'))
Exemplo n.º 3
0
def queue_program(username, password, label):
    queue = ProgramQueue(username, password)
    try:
        rc = queue.login()
    except:
        rc = False
    if not rc:
        QMessageBox.critical(main_window, main_window.tr('Login failed'), main_window.tr('Could not log in to the program queue.'))
        return

    output = StringIO()
    storage = SimpleFormat(output)
    serialize(storage)
    program_data = output.getvalue()
    output.close()

    try:
        id = queue.upload_program(program_data, label)
    except:
        id = False
    if not id:
        QMessageBox.critical(main_window, main_window.tr('Upload failed'), main_window.tr('Could not upload program to queue.'))
        return
    try:
        queue.logout()
    except:
        pass
    QMessageBox.information(main_window, main_window.tr('Uploaded program'), main_window.tr('Uploaded program (%d) successfully.') % id)
Exemplo n.º 4
0
def save_screenshot():
    path = os.path.expanduser('~')
    filename_template = 'robot-%d.png'
    serial = 1
    while True:
        filename = os.path.join(path, filename_template % serial)
        if not os.path.exists(filename):
            break
        serial += 1
    widget = robot_view.children()[0]
    pixmap = QPixmap.grabWindow(widget.winId())
    rc = pixmap.save(filename)
    if rc:
        QMessageBox.information(main_window, main_window.tr('Saved screenshot'), main_window.tr('Screenshot saved in file: %s') % filename)
    else:
        QMessageBox.critical(main_window, main_window.tr('Saving screenshot failed'), main_window.tr('Could not save screenshot.'))
def save_screenshot():
    path = os.path.expanduser('~')
    filename_template = 'robot-%d.png'
    serial = 1
    while True:
        filename = os.path.join(path, filename_template % serial)
        if not os.path.exists(filename):
            break
        serial += 1
    widget = robot_view.children()[0]
    pixmap = QPixmap.grabWindow(widget.winId())
    rc = pixmap.save(filename)
    if rc:
        QMessageBox.information(
            main_window, main_window.tr('Saved screenshot'),
            main_window.tr('Screenshot saved in file: %s') % filename)
    else:
        QMessageBox.critical(main_window,
                             main_window.tr('Saving screenshot failed'),
                             main_window.tr('Could not save screenshot.'))
def change_input_method():
    global manniquin_controllers_loaded
    global joint_observer
    index = main_window.input_method_comboBox.currentIndex()
    input_method = main_window.input_method_comboBox.itemData(index)
    print 'change_input_method()', index

    manniquin_controllers = [
        'r_arm_controller_loose', 'l_arm_controller_loose',
        'head_traj_controller_loose'
    ]
    standard_controllers = [
        'r_arm_controller', 'l_arm_controller', 'head_traj_controller'
    ]
    if input_method == INPUT_METHOD_ROBOT:
        # setup controllers for manniquin mode
        if not manniquin_controllers_loaded:
            # load controllers once
            print 'change_input_method()', 'load manniquin controllers'
            manniquin_controllers_loaded = load_controllers(
                manniquin_controllers)
            if not manniquin_controllers_loaded:
                QMessageBox.critical(
                    main_window, main_window.tr('Loading controllers failed'),
                    main_window.tr('Could not load manniquin controllers.'))
        # switch to manniquin controllers
        success = switch_controllers(manniquin_controllers,
                                     standard_controllers)
        if success:
            joint_observer.start()
    else:
        # restore standard controllers
        success = switch_controllers(standard_controllers,
                                     manniquin_controllers)
        if success:
            joint_observer.stop()
    if not success:
        QMessageBox.critical(main_window,
                             main_window.tr('Switching controllers failed'),
                             main_window.tr('Could not switch controllers.'))