예제 #1
0
    def planner(self, goal):

        aStarPlanner.actions = []
        aStarPlanner.step = 0
        currAction = ""
        currPrecondition = ""
        preconditionFlag = False
        a = actionsList.actionsList()
        print aStarPlanner.actions

        if len(a.actionFromEffect[goal]) == 2:
            currAction = findCheapest(goal)
        else:
            currAction = a.actionFromEffect[goal][0]

        while preconditionFlag == False:

            aStarPlanner.actions.append(currAction)
            aStarPlanner.step += 1

            currPrecondition = a.findPrecondition(currAction)

            if a.checkEffect(currPrecondition) == True:
                preconditionFlag = True
            else:
                if len(a.actionFromEffect[currPrecondition]) == 2:
                    currAction = aStarPlanner.findCheapest(currPrecondition)
                else:
                    currAction = a.actionFromEffect[currPrecondition][0]

        print "the list of actions is: " + str(aStarPlanner.actions)
예제 #2
0
    def planner(self, goal):

        aStarPlanner.actions = []
        aStarPlanner.step = 0
        currAction = ""
        currPrecondition = ""
        preconditionFlag = False
        a = actionsList.actionsList()
        print aStarPlanner.actions

        if len(a.actionFromEffect[goal]) == 2:
            currAction = findCheapest(goal)
        else:
            currAction = a.actionFromEffect[goal][0]
            
        while preconditionFlag == False:

            aStarPlanner.actions.append(currAction)
            aStarPlanner.step+=1

            currPrecondition = a.findPrecondition(currAction)

            if a.checkEffect(currPrecondition) == True:
                preconditionFlag = True
            else:
                if len(a.actionFromEffect[currPrecondition]) == 2:
                    currAction = aStarPlanner.findCheapest(currPrecondition)
                else:
                    currAction = a.actionFromEffect[currPrecondition][0]

        print "the list of actions is: " + str(aStarPlanner.actions)
예제 #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()
예제 #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()
예제 #5
0
    def findCheapest(effect):

        a = actionsList.actionsList()
        
        actionCost1 = a.getCost(a.actionFromEffect[effect][0])
        actionCost2 = a.getCost(a.actionFromEffect[effect][1])

        if a.checkEffect(a.findPrecondition(a.actionFromEffect[effect][0])) == False:
            actionCost1+=1

        if a.checkEffecT(a.findPrecondition(a.actionFromEffect[effect][1])) == False:
            actionCost2+=1

        if actionCost1 <= actionCost2:
            return a.actionFromEffect[effect][0]
        else:
            return a.actionFromEffect[effect][1]
예제 #6
0
    def findCheapest(effect):

        a = actionsList.actionsList()

        actionCost1 = a.getCost(a.actionFromEffect[effect][0])
        actionCost2 = a.getCost(a.actionFromEffect[effect][1])

        if a.checkEffect(a.findPrecondition(
                a.actionFromEffect[effect][0])) == False:
            actionCost1 += 1

        if a.checkEffecT(a.findPrecondition(
                a.actionFromEffect[effect][1])) == False:
            actionCost2 += 1

        if actionCost1 <= actionCost2:
            return a.actionFromEffect[effect][0]
        else:
            return a.actionFromEffect[effect][1]
예제 #7
0
def finiteStateMachine():

    if actions.actionsInit.goalAchieved == True:
        actions.stopTracking()
        return

    global step
    global listOfActions

    a = actionsList.actionsList()
    goal.Goal.target = "Nothing"

    print "The precondition is: " + str(
        a.checkEffect(a.findPrecondition(listOfActions[0])))
    if a.checkEffect(a.findPrecondition(
            listOfActions[0])) == True and step > 1:
        perform(listOfActions[0])
        del listOfActions[0]
        step -= 1
    elif a.checkEffect(a.findPrecondition(
            listOfActions[0])) == True and step == 1:
        perform(listOfActions[0])
        del listOfActions[0]
        step -= 1

    print "Goalachieved is: " + str(actions.actionsInit.goalAchieved)

    if actions.actionsInit.goalAchieved == True:
        for index in range(len(listOfActions)):
            del listOfActions[0]
        print "returning"
        return

    print listOfActions

    if step == 0:
        actions.actionsInit.goalAchieved = True
    else:
        actions.actionsInit.goalAchieved = False
예제 #8
0
def finiteStateMachine():

    if actions.actionsInit.goalAchieved == True:
        actions.stopTracking()
        return


    global step
    global listOfActions
    
    a = actionsList.actionsList()
    goal.Goal.target = "Nothing"

    print "The precondition is: " + str(a.checkEffect(a.findPrecondition(listOfActions[0])))
    if a.checkEffect(a.findPrecondition(listOfActions[0])) == True and step > 1:
        perform(listOfActions[0])
        del listOfActions[0]
        step-=1
    elif a.checkEffect(a.findPrecondition(listOfActions[0])) == True and step == 1:
        perform(listOfActions[0])
        del listOfActions[0]
        step-=1

    print "Goalachieved is: " + str(actions.actionsInit.goalAchieved)

    if actions.actionsInit.goalAchieved == True:
        for index in range(len(listOfActions)):
            del listOfActions[0]
        print "returning"
        return
    
    print listOfActions
    
    if step == 0:
        actions.actionsInit.goalAchieved = True
    else:
        actions.actionsInit.goalAchieved = False
예제 #9
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()
예제 #10
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()