예제 #1
0
def get_input():
    logger.log("I am ready to go!")
    while running:
        input = logger.prompt("Command?")
        command = input.split(" ")
        if len(command) == 2:
            if command[0] == "r" or command[0] == "rot" or command[0] == "rotation":
                arm.rot_servo.set_angle(float(command[1]))
            elif command[0] == "b":
                arm.b_servo.set_angle(float(command[1]))
            elif command[0] == "a":
                arm.a_servo.set_angle(float(command[1]))
            elif command[0] == "c" or command[0] == "claw":
                arm.claw_servo.set_angle(float(command[1]))
            elif command[0] == "start":
                start_task(command[1])
        elif len(command) == 3:
            if command[0] == "go" or command[0] == "move":
                arm.move_to(float(command[1]), float(command[2]))
            if command[0] == "force":
                if command[1] == "r" or command[1] == "rot" or command[1] == "rotation":
                    arm.rot_servo.set_angle(float(command[2]), force=True)
                elif command[1] == "b":
                    arm.b_servo.set_angle(float(command[2]), force=True)
                elif command[1] == "a":
                    arm.a_servo.set_angle(float(command[2]), force=True)
                elif command[1] == "c" or command[1] == "claw":
                    arm.claw_servo.set_angle(float(command[2]), force=True)
        else:
            if command[0] == "q" or command[0] == "quit":
                shutdown()
            elif command[0] == "r" or command[0] == "reset":
                arm.reset_servos()
                logger.log("Servos reset")
            elif command[0] == "rest" or command[0] == "d" or command[0] == "disable":
                arm.rest_servos()
                logger.log("Servos set to rest")
            elif command[0] == "open":
                arm.open_claw()
                logger.log("Opening claw")
            elif command[0] == "close":
                arm.close_claw()
                logger.log("Closing claw")
            elif command[0] == "up":
                arm.b_servo.set_angle(80, arm.b_servo.rest)
            elif command[0] == "down":
                arm.b_servo.set_angle(0, arm.b_servo.rest)
            elif command[0] == "left":
                arm.rot_servo.set_angle(arm.ROT_MIN, arm.rot_servo.rest)
            elif command[0] == "right":
                arm.rot_servo.set_angle(arm.ROT_MAX, arm.rot_servo.rest)
            elif command[0] == "back":
                arm.a_servo.set_angle(-70, arm.a_servo.rest)
            elif command[0] == "forward":
                arm.a_servo.set_angle(0, arm.a_servo.rest)
            elif command[0] == "hi" or command[0] == "hello" or command[0] == "greet":
                start_task("hi")
            else:
                logger.log("Command '%s' not recognized" % (input), logger.Level.ERROR)
    logger.log("Input thread stopped", logger.Level.DEBUG)
예제 #2
0
def do_restore_pkg(results):
    if not logger.prompt('是否安装缺失包', results):
        return
    groups = list_group_by(results)
    for group, args in groups.items():
        putils.restore(group, args)
예제 #3
0
def do_add_config(results):
    if not logger.prompt('是否添加配置', results):
        return
    groups = list_group_by(results)
    for group, args in groups.items():
        futils.add(group, args)
예제 #4
0
def do_restore_config(results):
    if not logger.prompt('是否恢复配置', results):
        return
    groups = list_group_by(results)
    for group, args in groups.items():
        futils.restore(group, args)