Esempio n. 1
0
def main():
    try:    
        while True:
            try: #Try to open status file
                with open('status.txt', 'w') as s: 
                    lock_flags = portalocker.LOCK_EX | portalocker.LOCK_NB
                    portalocker.lock(s, lock_flags) #Lock status file
                    try:
                        with open('comando.txt', 'r') as c: #try to open command file
                            getc = c.readline()
                            print "Reading command file"
                            print (getc) #Print command
                            if getc != None:
                                cmd = 'actions.%s' % getc
                                result = eval(cmd) #Run command
                                print (result) #Print result
                                s.write(str(result)) #Write result
                                print "Writing on status file"
                    except IOError: #If command is occupied wait 1 sec
                        time.sleep(1)
            except IOError: #If status file cannot be opened
                print "Status is busy"
                time.sleep(1)
    except KeyboardInterrupt:
        print "Interrupted by user"
        print "Stopping..."
        actions.rest()
    except Exception as e: #If any other error
        print e
        print "Stopping..."
        actions.rest()
Esempio n. 2
0
def display_main_menu(vitals):
    # asks user for input
    # fly
    # rest
    # poop
    # eat
    time.sleep(1)
    pigeon_options = "\n\n\nDear Pigeon, \n\
    Would you like to: \n\
    1. Fly \n\
    2. Rest \n\
    3. Poop \n\
    4. Eat \n\
    5. Quit this Mission \n\
    Enter 1, 2, 3, 4, or 5: "

    while True:
        if vitals["distance"] == 5:
            print """
                 ___  __   __ _   ___  ____   __  ____  ____  _   
                / __)/  \ (  ( \ / __)(  _ \ / _\(_  _)/ ___)/ \  
               ( (__(  O )/    /( (_ \ )   //    \ )(  \___ \\_/  
                \___)\__/ \_)__) \___/(__\_)\_/\_/(__) (____/(_)  
            """

            time.sleep(.5)
            print "you've made it to Point B!"
            break
        elif vitals["poop_load"] > 4:
            print "I recommend you poop"
        elif vitals["health"] < 3:
            print "I recommend you eat or rest"

        pigeon_input = raw_input(pigeon_options)
        subprocess.call("clear")

        if (pigeon_input == "1") and vitals["health"] >= 3:
            actions.fly(vitals)
        elif pigeon_input == "2":
            actions.rest(vitals)
        elif pigeon_input == "3":
            actions.poop(vitals)
        elif pigeon_input == "4":
            actions.eat(vitals)
        elif pigeon_input == "5":
            break
        else:
            print "invalid option, please enter 1, 2, 3, 4, or 5"
Esempio n. 3
0
def main():

    #print "Enter the IP of the robot: "
    #robotIP = raw_input()

    #print "Enter the PORT of the robot: "
    #robotPORT = int(raw_input())
    global searchTime
    searchTime = time.clock()
    global memoryProxy
    global postureProxy
    global motionProxy
    global speechProxy
    global ballSub
    global faceSub

    goal.Goal.target = "Nothing"
    print goal.Goal.target
    
    a = actions.actionsInit()  
    a.init()

    a.toggleAutoLife()
    r = actions.rest()
    r.rest()
    
    
    action = actionsList.actionsList()
    action.init()
    
    memoryProxy = ALProxy("ALMemory")
    postureProxy = ALProxy("ALRobotPosture")
    motionProxy = ALProxy("ALMotion")
    speechProxy = ALProxy("ALAnimatedSpeech")
    
    global ballEvent
    ballEvent = ballEventListener("ballEvent")

    global faceEvent
    faceEvent = faceEventListener("faceEvent")

    actions.actionsInit.goalAchieved = True
    
    try:
        while True:
            aStarPlanner()
            time.sleep(1)
    except KeyboardInterrupt:
        ballEvent.unsub()
        faceEvent.unsub()
        actions.stopTracking()
        quit()
Esempio n. 4
0
def main():

    #print "Enter the IP of the robot: "
    #robotIP = raw_input()

    #print "Enter the PORT of the robot: "
    #robotPORT = int(raw_input())
    global searchTime
    searchTime = time.clock()
    global memoryProxy
    global postureProxy
    global motionProxy
    global speechProxy
    global ballSub
    global faceSub

    goal.Goal.target = "Nothing"
    print goal.Goal.target

    a = actions.actionsInit()
    a.init()

    a.toggleAutoLife()
    r = actions.rest()
    r.rest()

    action = actionsList.actionsList()
    action.init()

    memoryProxy = ALProxy("ALMemory")
    postureProxy = ALProxy("ALRobotPosture")
    motionProxy = ALProxy("ALMotion")
    speechProxy = ALProxy("ALAnimatedSpeech")

    global ballEvent
    ballEvent = ballEventListener("ballEvent")

    global faceEvent
    faceEvent = faceEventListener("faceEvent")

    actions.actionsInit.goalAchieved = True

    try:
        while True:
            aStarPlanner()
            time.sleep(1)
    except KeyboardInterrupt:
        ballEvent.unsub()
        faceEvent.unsub()
        actions.stopTracking()
        quit()
Esempio n. 5
0
def perform(action):

    global movX
    global movY
    global movR
    global target
    aList = actionsList.actionsList()

    print "Performing: " + action + "..."
    
    if action == "moveTo":
        m = actions.moveTo()
        m.move(movX, movY, movR)

    elif action == "wakeUp":
        w = actions.wakeUp()
        w.wake()

    elif action == "rest":
        r = actions.rest()
        r.rest()

    elif action == "kickBall":
        k = actions.kickBall()
        k.kick()

    elif action == "stand":
        s = actions.stand()
        s.goToStand()

    elif action == "trackBall":
        b = actions.trackBall()
        b.track("RedBall")

    elif action == "trackFace":
        f = actions.trackFace()
        f.track("Face")

    elif action == "followFace":
        ff = actions.followFace()
        ff.follow()

    elif action == "moveToFace":
        print "at perform"
        mf = actions.moveToFace()
        mf.move()

    elif action == "moveToBall":
        mb = actions.moveToBall()
        mb.move()

    elif action == "searchForObject":
        so = actions.searchForObject()
        ballEvent.sub()
        faceEvent.sub()
        so.search()
        if faceSub == True:
            faceEvent.unsub()
        if ballSub == True:
            ballEvent.unsub()
        searchTime = time.clock
    elif action == "robotIdle":
        ri = actions.robotIdle()
        ri.idle()
    elif action == "greetFace":
        gf = actions.greetFace()
        gf.greet()
    else:
        print "Error actions is not supported. Shutting down."
        exit()

    aList.setupCheckEffect()
Esempio n. 6
0
def perform(action):

    global movX
    global movY
    global movR
    global target
    aList = actionsList.actionsList()

    print "Performing: " + action + "..."

    if action == "moveTo":
        m = actions.moveTo()
        m.move(movX, movY, movR)

    elif action == "wakeUp":
        w = actions.wakeUp()
        w.wake()

    elif action == "rest":
        r = actions.rest()
        r.rest()

    elif action == "kickBall":
        k = actions.kickBall()
        k.kick()

    elif action == "stand":
        s = actions.stand()
        s.goToStand()

    elif action == "trackBall":
        b = actions.trackBall()
        b.track("RedBall")

    elif action == "trackFace":
        f = actions.trackFace()
        f.track("Face")

    elif action == "followFace":
        ff = actions.followFace()
        ff.follow()

    elif action == "moveToFace":
        print "at perform"
        mf = actions.moveToFace()
        mf.move()

    elif action == "moveToBall":
        mb = actions.moveToBall()
        mb.move()

    elif action == "searchForObject":
        so = actions.searchForObject()
        ballEvent.sub()
        faceEvent.sub()
        so.search()
        if faceSub == True:
            faceEvent.unsub()
        if ballSub == True:
            ballEvent.unsub()
        searchTime = time.clock
    elif action == "robotIdle":
        ri = actions.robotIdle()
        ri.idle()
    elif action == "greetFace":
        gf = actions.greetFace()
        gf.greet()
    else:
        print "Error actions is not supported. Shutting down."
        exit()

    aList.setupCheckEffect()