コード例 #1
0
ファイル: Robot.py プロジェクト: AndersonUFC/rob-the-robot
    def __init__(self, size=1):
        bpy.ops.object.select_all(action='DESELECT')

        # BB8
        #bpy.ops.import_scene.obj(filepath=config.DATA_PATH + 'BB8/bb8.obj')

        bpy.ops.import_scene.obj(filepath=config.DATA_PATH + 'rob/rob.obj')
        bpy.context.scene.objects.active = bpy.context.selected_objects[0]
        bpy.ops.object.join()

        bpy.ops.transform.resize(value=(size, size, size))

        # BB8
        #bpy.ops.transform.rotate(value=-math.pi/2, axis=(0,0,1))

        bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_VOLUME')

        self.data = bpy.context.object
        self.data.name = 'robot'

        # sensors ----------------------------------
        self.sensor_wall = WallSensor.WallSensor(number_of_features=4)
        self.sensor_fruit = FruitSensor.FruitSensor(number_of_features=2,
                                                    radius=1.5)

        # actuators --------------------------------
        self.act_walk = Walk.Walk(velocity=0.05)
        self.act_rotate = Rotate.Rotate(degree_rotation=math.pi / 10)

        self.act_mouth = Mouth.Mouth(robot_size=0.03)

        # brain ------------------------------------
        self.brain = Brain.Brain(number_of_actions=4)
コード例 #2
0
 def __init__(self):
     # determine the path and set the default path place
     os.chdir(r'/home/{}/ros_ws/src/baxter_face/scripts'.format(
         getpass.getuser()))
     ''' Parts of the face of baxter are defined.'''
     self.backgroundImage = Image.open(
         "data/baxter_background.png")  # Background behind the eyes
     # Face partions objects
     self.skin = Skin.Skin(5)  # range: [0, 5]
     self.mouth = Mouth.Mouth(2)  # range: [0, 6]
     self.eyebrow = Eyebrow.Eyebrow(1)  # range: [0, 3]
     self.eye = Eye.Eye()
     self.eyelid = Eyelid.Eyelid()
     self.eyelid.setPosition(-330)
     self.eyesCoordinateX = self.eye.getPositionX()
     self.angleOfView = 0.25
コード例 #3
0
def main(argv):
    noofhair = ''
    radiusofhead = ''
    left_eye_radius = ''
    right_eye_radius = ''

    try:
        opts, args = getopt.getopt(argv, "hf:", ["head="])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    for opt, arg in opts:
        if (opt == "-h"):
            usage()
            sys.exit()
        elif opt in ("-f", "--head"):
            noofhair = argv[1]
            radiusofhead = argv[2]
            left_eye_radius = argv[3]
            right_eye_radius = argv[4]

    left_eye = Eye.Eye(left_eye_radius)
    right_eye = Eye.Eye(right_eye_radius)
    left_eye_abnormal = Eye.Eye(0)
    right_eye_abnormal = Eye.Eye(0)
    mouth_height_width = Mouth.Mouth(0, 0)

    normalhead = Head.Head(noofhair, radiusofhead, left_eye, right_eye,
                           mouth_height_width)
    print("Normal Head:" + "\n")
    print(normalhead.toString() + "\n")
    abnormalhead = Head.Head(noofhair, radiusofhead, left_eye_abnormal,
                             right_eye_abnormal, mouth_height_width)
    print("Abnormal Head:" + "\n")
    print(abnormalhead.toString())

    normalhead = Head.Head(noofhair, radiusofhead, left_eye_abnormal,
                           right_eye_abnormal, mouth_height_width)
    # Mouth.Mouth.setHeight(1)
    print("\n")
    print("After Closing Eyes and Mouth for Normal Head" + "\n")
    print(normalhead.toString() + "\n")
    normalhead.headAche()
コード例 #4
0
def analyze_data():
    if not request.json and not 'message' in request.json and 'userID' in request.json:
        abort(400)
    message = request.json['message']
    userid = request.json['userID']
    EAR = NLP()
    Mou = Mouth()
    ################ RECOMMENDER  #################
    EAR.execute(message)
    print(EAR.information)
    try:
        if EAR.information['Type'] == 'movie':
            genra = EAR.information['Category']
            movie = recommend(genra)
            return jsonify({'message': 'Here is your Movie : ' + movie}), 200
    except (RuntimeError, TypeError, NameError, KeyError):
        pass

        ################# Light Cycle ##################
    try:
        if EAR.information['Appliance'] == 'light' and EAR.information[
                'State'] == 'on':
            code = lightCodeON[EAR.information['Location']]
            print(code)
            print(Devices[EAR.information['Location']])
            if Devices[EAR.information['Location']] == '1':
                return jsonify({'message': "it's already on "}), 207

            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)
            Devices[EAR.information['Location']] = '1'

            val = 1
            memory.insertValues(
                'light_DS', {
                    'user_id': int(userid),
                    'room_num': int(learn[EAR.information['Location']]),
                    'val': val
                })

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200

            print(Devices[EAR.information['Location']])
        elif EAR.information['Appliance'] == 'light' and EAR.information[
                'State'] == 'off':
            code = lightCodeOff[EAR.information['Location']]
            if Devices[EAR.information['Location']] == '0':
                return jsonify({'message': "it's already off "}), 207
            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)
            Devices[EAR.information['Location']] = '0'

            memory.insertValues(
                'light_DS', {
                    'user_id': int(userid),
                    'room_num': int(learn[EAR.information['Location']])
                })

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200

    except (RuntimeError, TypeError, NameError, KeyError):
        pass

        # save

    ########################################       tv Cycle                 ##########################################

    try:
        if EAR.information['Appliance'] == 'television':
            code = tvCode[EAR.information['State']]
            print(EAR.information)
            print(code)
            print(Devices["tv"])

            if code == '17' and Devices["tv"] == '1':
                return jsonify({'message': "it's already on "}), 207

            if code == '18' and Devices["tv"] == '0':
                return jsonify({'message': "it's already off "}), 207

            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)

            if code == '17':
                Devices["tv"] = '1'
            if code == '18':
                Devices["tv"] = '0'

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200

    except (RuntimeError, TypeError, NameError, KeyError):
        pass

    #######################################    coffee machine Cycle   #########################################

    try:
        if EAR.information['Appliance'] == 'coffee machine':
            code = coffeeCode[EAR.information['State']]
            print(code)
            print(Devices["coffeMachine"])

            if code == '21' and Devices["coffeMachine"] == '1':
                return jsonify({'message': "it's already on "}), 207

            if code == '22' and Devices["coffeMachine"] == '0':
                return jsonify({'message': "it's already off "}), 207

            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)

            if code == '21':
                Devices["coffeMachine"] = '1'
            if code == '22':
                Devices["coffeMachine"] = '0'

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200

    except (RuntimeError, TypeError, NameError, KeyError):
        pass

    #######################   air conditioning   ##############################
    try:
        if EAR.information['Appliance'] == 'air conditioner':
            code = airConditioner[EAR.information['State']]
            print(code)
            #print(Devices["airConditioner"])

            if code == '52' and Devices["air conditioner"] == '1':
                return jsonify({'message': "it's already on "}), 207

            if code == '53' and Devices["air conditioner"] == '0':
                return jsonify({'message': "it's already off "}), 207

            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)

            if code == '52':

                val = 1
                memory.insertValues(
                    'air_con_DS', {
                        'external_val': Interior_Value,
                        'internal_val': Exterior_Value,
                        'user_id': int(userid),
                        'val': val
                    })
                Devices["air conditioner"] = '1'
            if code == '53':

                val = 0
                memory.insertValues(
                    'air_con_DS', {
                        'external_val': Interior_Value,
                        'internal_val': Exterior_Value,
                        'user_id': int(userid),
                        'val': val
                    })
                Devices["air conditioner"] = '0'

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200

    except (RuntimeError, TypeError, NameError, KeyError):
        pass

    ###############################  Curtains  ######################################
    try:
        if EAR.information['Appliance'] == 'curtains':
            code = curtains[EAR.information['State']]
            print(code)
            #print(Devices["airConditioner"])

            if code == '29' and Devices["curtains"] == '1':
                return jsonify({'message': "it's already on "}), 207

            if code == '30' and Devices["curtains"] == '0':
                return jsonify({'message': "it's already off "}), 207

            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)

            if code == '29':
                Devices["curtains"] = '1'
            if code == '30':
                Devices["curtains"] = '0'

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200

    except (RuntimeError, TypeError, NameError, KeyError):

        pass
################################    Fridge    ###################################
    try:
        if EAR.information['Appliance'] == 'fridge':
            code = fridge[EAR.information['State']]
            print(code)
            #print(Devices["airConditioner"])

            if code == '27' and Devices["fridge"] == '1':
                return jsonify({'message': "it's already on "}), 207

            if code == '28' and Devices["fridge"] == '0':
                return jsonify({'message': "it's already off "}), 207

            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)

            if code == '27':
                Devices["fridge"] = '1'
            if code == '28':
                Devices["fridge"] = '0'

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200

    except (RuntimeError, TypeError, NameError, KeyError):
        pass

    try:
        if EAR.information['Appliance'] == 'elevator':
            code = '31'
            print(code)
            #print(Devices["airConditioner"])

            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200

    except (RuntimeError, TypeError, NameError, KeyError):
        pass

    try:
        if EAR.information['Inquiry'] == 'weather':
            print('123')
            print(EAR.information['Location'])
            tem = get_temperature(EAR.information['Location'])
            str1 = 'the weather in '
            str2 = str(EAR.information['Location'])
            str3 = ' is: '
            str4 = ' Celsius'
            strr = str1 + str2 + str3 + str(tem) + str4
            print(strr)
            return jsonify({'message': strr}), 200

    except (RuntimeError, TypeError, NameError, KeyError):
        pass

#########################################################################

################################    water tap    ###################################
    try:
        if EAR.information['Appliance'] == 'water tap':
            code = waterTap[EAR.information['State']]
            print(code)
            #print(Devices["airConditioner"])

            if code == '100' and Devices["waterTap"] == '1':
                return jsonify({'message': "it's already on "}), 207

            if code == '101' and Devices["waterTap"] == '0':
                return jsonify({'message': "it's already off "}), 207

            send.Conect(clientName)
            send.send(clientName, TOPIC, code)
            send.disconnect(clientName)

            if code == '100':
                Devices["waterTap"] = '1'
            if code == '101':
                Devices["waterTap"] = '0'

            Mou.speak(EAR.intent, EAR.tense)
            return jsonify({'message': Mou.respone}), 200
    except (RuntimeError, TypeError, NameError, KeyError):
        pass

    #return jsonify({'message': "Sory some times i don't understand"}), 200

    Mou.speak(EAR.intent, EAR.tense)
    return jsonify({'message': Mou.respone}), 200
コード例 #5
0
 def load(self):
     self.shape = Shape.Shape(self)
     self.mouth = Mouth.Mouth(self)
     self.eyes = Eyes.Eyes(self)
     self.nose = Nose.Nose(self)
     self.ear = Ear.Ear(self)
コード例 #6
0
ファイル: AlienTest.py プロジェクト: JuileePanse/Python
#!/usr/bin/python

# AlienTest.py
from Alien import *
from Eye import *
from Nose import *
from Mouth import *
from Head import *
import sys, getopt

if __name__ == '__main__':

    eyeLeft1 = Eye(2)
    eyeRight1 = Eye(2)
    nose = Nose(3, 3, 2)
    mouth = Mouth(5, 2)

    eyeLeft2 = Eye(2)
    eyeRight2 = Eye(3)
    normalHead = Head(100, 4, eyeLeft1, eyeRight1, nose, mouth)
    abnormalHead = Head(100, 4, eyeLeft2, eyeRight2, nose, mouth)

    print("Normal Head", normalHead.toString())
    print("\n\nAbnormal Head", abnormalHead.toString())

    normalHead.getLeft().close()
    normalHead.getRight().close()
    normalHead.getMouth().close()

    if normalHead.headAche():
        print("\nHead Ache")