示例#1
0
def attractCustomers(emotions):
    """
    Randomize between:

    Two Achoo - https://freesound.org/people/Reitanna/sounds/343921/ 
    Scoot a bit back with each achoo, then roll slowly forward
    Roll eyes all the way around with each achoo
    Show purple light on achoo

    Random chirping - https://freesound.org/people/radarflora/sounds/350690/ 
    Roll around a bit
    Look around a bit
    Rainbow lights

    """

    #TODO

    reaction = random.random() * 100

    if reaction < 10:
        mir_calls.add_to_mission_queue("f747a369-509c-11e9-9b99-94c691a3a93e")
        emotions.mod_emotion(2, 2)
        eyes.rollEyes()

    if reaction >= 10 and reaction < 20:
        eyes.lookRight()
        time.sleep(2)
        eyes.lookUp()
        time.sleep(5)
        eyes.lookDown

    if reaction >= 20 and reaction < 50:
        eyes.lookLeft()
        time.sleep(1)
        eyes.lookRight()
        time.sleep(1)
        eyes.lookDown()

    if reaction >= 50:
        eyes.lookRight()
        time.sleep(3)
        eyes.lookDown()

    print("attracting customers")
示例#2
0
def main():

    #set counter to 0
    counter = 0

    # is this a category-only mission
    catmission = False

    #create stack for status histories
    statushistory = deque([], 50)

    #create emotion table
    emotions = Emotion(9)
    emotions.create_area("angry", 0, 0, 2, 2)
    emotions.create_area("frustrated", 0, 3, 2, 5)
    emotions.create_area("sad", 0, 6, 2, 8)
    emotions.create_area("bored", 3, 0, 5, 8)
    emotions.create_area("excited", 6, 0, 8, 2)
    emotions.create_area("happy", 6, 3, 8, 5)
    emotions.create_area("ok", 6, 6, 8, 8)

    # primary status, possibilities are: idle = waiting for customers, mission = on a mission, advising = telling where the book is, feedback = waiting for or reacting to feedback
    robot_status = "idle"

    print("ROBOT STATUS: " + robot_status)

    while True:
        #get robot status
        status = mir_calls.get_mir_status()

        if (counter % 1 == 0):
            statushistory.append(status)
            print("counter: " + str(counter) + " status: " + status)

        counter = counter + 1

        print("debug: checking if we are on a mission")

        ### ON A MISSION? if yes, call the related logic in travel.py, and skip cycle

        if robot_status == 'shelfmission':
            mir_status = travel.move()
            print("debug: shelf mission in progress, mir state: " + mir_status)

            if mir_status == 'Ready':
                print("debug: shelf-mission has been accomplished")

                print("debug: wait for 5 seconds")

                if catmission == True:

                    print("DEBUG: catmission true, cat " + category)

                    if category == '79000':
                        switch_flask_view('r')

                    if category == '46900':
                        switch_flask_view('r')

                    if category == '69110':
                        switch_flask_view('lr')

                    if category == '85000':
                        switch_flask_view('r')

                    if category == '99000':
                        switch_flask_view('l')

                    if category == '90000':
                        switch_flask_view('l')

                    time.sleep(10)
                    mir_calls.add_to_mission_queue(
                        "beb5b742-341b-11e9-a33f-94c691a3a93e")
                    robot_status = 'homing'
                    time.sleep(2)
                    #eyes.lookDown()
                    catmission = False
                    sierra.update_target_time()
                    continue

                # FLASK: display arrow to left or right
                side = find_side_by_category(category, "column")
                switch_flask_view(side)
                print("debug: the book could be on the " + side + " side")

                # if side == 'r':
                #eyes.lookLeft()

                #if side == 'l':
                #eyes.lookRight()

                time.sleep(5)

                # the category should be mapped to a physical oodi position recognised by the mir robot
                print("debug: move to the correct column")
                positionguid = str(
                    find_position_by_category(category, "column"))
                print(
                    "debug: position guid for category column from database is "
                    + positionguid)
                # if we have a position, we can create a mission
                mir_calls.modify_mir_mission(positionguid)
                # add the modified travel mission to the queue
                mir_calls.add_to_mission_queue(
                    "2e066786-3424-11e9-954b-94c691a3a93e")

                # set the robot status to be on a mission
                robot_status = 'columnmission'
                switch_flask_view("blank")

                # give the MiR a few seconds to react so we enter the correct state (mission executing)
                time.sleep(2)

            time.sleep(1)
            continue

        if robot_status == 'columnmission':
            mir_status = travel.move()
            print("debug: column mission in progress, mir state: " +
                  mir_status)

            if mir_status == 'Ready':
                print("debug: column-mission has been accomplished")
                print("debug: wait for 5 seconds")
                # FLASK: display arrow to left or right
                side = find_side_by_category(category, "column")
                switch_flask_view(side)
                sierra.update_target_time()

                print("debug: the book could be on the " + side + " side")
                time.sleep(10)
                #switch_flask_view("blank")

                # move forward one meter to make room for the customer
                #mir_calls.add_to_mission_queue("3ac4fc26-3f3f-11e9-9822-94c691a3a93e")
                #time.sleep(10)

                # TODO ask for feedback! maybe not?
                mir_calls.add_to_mission_queue(
                    "beb5b742-341b-11e9-a33f-94c691a3a93e")
                robot_status = 'homing'
                #eyes.lookDown()
                time.sleep(5)

            time.sleep(1)
            continue

        if robot_status == 'homing':
            mir_status = travel.move()
            print("debug: homing in progress, mir state: " + mir_status)

            switch_flask_view("home")

            if mir_status == 'Ready':
                print("debug: homing has been accomplished")
                print("debug: enter idle loop")
                switch_flask_view("home2")
                robot_status = 'idle'
                #eyes.lookLeft()
                #eyes.lookRight()
                #eyes.lookDown()
                sierra.update_home_time()

            time.sleep(1)
            continue

        print("debug: checking if we have a new mission")

        ### NEW MISSION AVAILABLE? if there's a category entry in missions table with status new, we have a new mission

        category = check_for_new_mission()

        if category is not None:

            # a quick hack to allow for the category missions
            if category == '79000':
                positionguid = 'aac480fd-44d5-11e9-b653-94c691a3a93e'
                catmission = True

            if category == '46900':
                positionguid = '48e76bd3-44d4-11e9-b653-94c691a3a93e'
                catmission = True

            if category == '69110':
                positionguid = '78795881-44d5-11e9-b653-94c691a3a93e'
                catmission = True

            if category == '85000':
                positionguid = 'b955c6f0-4bb0-11e9-98e7-94c691a3a93e'
                catmission = True

            if category == '99000':
                positionguid = 'd8585103-4bb0-11e9-98e7-94c691a3a93e'
                catmission = True

            if category == '90000':
                positionguid = 'eb62e8a2-4bb0-11e9-98e7-94c691a3a93e'
                catmission = True

            if catmission == True:
                print("DEBUG: catmission is true!")
                change_mission_status()

            # the category should be mapped to a physical oodi position recognised by the mir robot
            if catmission == False:
                print("debug: received target category is " + category)
                change_mission_status()
                positionguid = str(find_position_by_category(
                    category, "shelf"))
                print(
                    "debug: position guid for category shelf from database is "
                    + positionguid)

            # if we have a position, we can create a mission
            mir_calls.modify_mir_mission(positionguid)

            # finally add the modified shelf/column mission to the queue
            mir_calls.add_to_mission_queue(
                "2e066786-3424-11e9-954b-94c691a3a93e")

            # set the robot status to be on a mission
            robot_status = 'shelfmission'

            # give the MiR a few seconds to react so we enter the correct state (mission executing)
            time.sleep(3)

            # eye movement :D
            #eyes.topRoll()

            continue

        ### NO MISSIONS? let's call the related logic in idle.py to attract customers

        if robot_status == 'idle':
            idle.idle(statushistory, emotions)
            time.sleep(1)
            continue

        if robot_status == "advising":
            advise.advise(emotions, "atColumn", "right")
            time.sleep(1)
            continue

        if robot_status == "feedback":
            feedback.feedback(emotions, 1, "good")

        ### NO STATUS, NO NEW MISSION? let's send the robot back to the homebase

        print("debug: no status, return to home")
        mir_calls.add_to_mission_queue("beb5b742-341b-11e9-a33f-94c691a3a93e")
        robot_status = 'homing'
        time.sleep(2)
        continue
示例#3
0
文件: idle.py 项目: futurice/oodipoc
def chirping():
    mir_calls.add_to_mission_queue("17f74b3b-5b99-11e9-90b2-94c691a3a93e")
示例#4
0
文件: idle.py 项目: futurice/oodipoc
def emotionAngry():
    mir_calls.add_to_mission_queue("9cf49b99-5b9b-11e9-90b2-94c691a3a93e")
    time.sleep(0.2)
    eyes.lookRight()
    eyes.lookLeft()
    eyes.lookDown()
示例#5
0
文件: idle.py 项目: futurice/oodipoc
def achoo():
    mir_calls.add_to_mission_queue("f747a369-509c-11e9-9b99-94c691a3a93e")
    eyes.rollEyesAchoo()