Exemple #1
0
 def CLOSE(self):
     print 'closing the robot'
     #present_position = [motor[name].present_position for name in self.motorsName]
     #goal_position = {"Robot": [0 for name in self.motorsName],
     #                    "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100],
     #                    "Left_hand" : [200, 200, 100, 100, 200, 100, 100, 100, 100]}
     #tools.go_to_pos(self.motorsName, motor, goal_position, pub)
     tools.releas(self.motorsName, pub, motor)
     print 'Robot Closed'
     self.master.destroy()
Exemple #2
0
 def close(self):
     self.info.set("Closing the Robot")
     #present_position = [motor[name].present_position for name in self.motorsName]
     #goal_position = {"Robot": [0 for name in self.motorsName],
     #                 "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100],
     #                 "Left_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100]}
     #tools.go_to_pos(self.motorsName, motor, goal_position, pub)
     tools.releas(self.motorsName, pub, motor)
     self.info.set("Robot Closed")
     self.master.destroy()
Exemple #3
0
 def close(self):
     self.info.set("Closing the Robot")
     goal_position = {
         "Robot": [0 for name in self.motorsName],
         "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100],
         "Left_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100]
     }
     tools.go_to_pos(self.motorsName, motor, goal_position, pub)
     tools.releas(self.motorsName, pub)
     self.info.set("Robot Closed")
     self.master.destroy()
Exemple #4
0
 def CLOSE(self):
     print 'closing the robot'
     goal_position = {
         "Robot": [0 for name in self.motorsName],
         "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100],
         "Left_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100]
     }
     tools.go_to_pos(self.motorsName, motor, goal_position, pub)
     tools.releas(self.motorsName, pub)
     print 'Robot Closed'
     self.master.destroy()
Exemple #5
0
    def STARTREC(self):
        self.STOP = 0
        self.sleeping = 1 / float(self.Frq.get())
        present_position = [
            motor[name].present_position for name in self.deadmotors
        ]
        IDs = [motor[name].id for name in self.motorsName]
        self.pos = {}
        tools.releas(self.motorsName, pub)
        for sec in range(int(self.StrTm.get())):
            self.info.config(text=str(sec))
            time.sleep(1)
        print 'Starting record'
        i = 0
        start = default_timer()
        while self.STOP == 0:
            self.pos[str(i)] = {
                'Robot':
                [motor[name].present_position for name in self.motorsName],
                'Right_hand': [200, 200, 100, 100, 200, 100, 100, 100, 100],
                'Left_hand': [200, 200, 100, 100, 200, 100, 100, 100, 100]
            }
            i += 1

            time.sleep(self.sleeping)
            if self.STP.get() == 1 & (default_timer() - start > float(
                    self.StpTm.get())):
                self.STOP = 1
                print 'Stop Recording'

        self.frames = i
        self.movement = {
            'actors_ID': IDs,
            'actors_NAME': self.motorsName,
            'freq': self.Frq.get(),
            'frame_number': self.frames,
            'emotion_name': '',
            'text': '',
            'emotion_time': [],
            'position': self.pos
        }
        self.save.config(state=NORMAL)
        self.play.config(state=NORMAL)
        self.handset.config(state=NORMAL)

        self.varInfo.set(
            'Done Recording, now you can play the recorded movement\n'
            'if it is OK you can save it or go to hand setting\n\n'
            '<------ Click here to play the recording\n\n'
            '<------ Click here to save the recording\n\n'
            '<------ Click here to go to Hand Setting')
        self.info.config(justify=LEFT)
Exemple #6
0
    def closecall():
        if save['state']==NORMAL:
            decision = tkMessageBox.askyesnocancel('CLOSE', "Do you want to save sign: ", parent=master)
            if decision:
                savecall()
            elif decision is None:
                return
        print 'closing the robot'
        tools.multi_servo_set([200, 200, 100, 100, 200, 100, 100, 100, 100], [200, 200, 100, 100, 200, 100, 100, 100, 100], L, R)
        goal_position = {"Robot": [0 for name in dead_motors],
                         "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100],
                         "Left_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100]}
        tools.go_to_pos(dead_motors, motor, goal_position, pub)
        goal_position = {"Robot": [0 for name in active_motors],
                         "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100],
                         "Left_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100]}
        tools.go_to_pos(active_motors, motor, goal_position, pub)
        tools.releas(active_motors, pub, L, R)
        print 'Robot Closed'

        master.destroy()
Exemple #7
0
def do_sign(buffer):
    time.sleep(5)
    start = time.time()
    print "reseting positions"
    tools.reset(torso + head, present_pos, pub)
    robot_stat = 'ready'
    right_hand = [200, 200, 100, 100, 200, 100, 100, 100, 100]
    left_hand  = [200, 200, 100, 100, 200, 100, 100, 100, 100]
    old_motors = []
    print "BEGIN"
    while True:
        if buffer:
            start = time.time()
            if robot_stat == 'sleep':
                tools.reset(torso, present_pos, pub)
                robot_stat = 'ready'
            try:
                SIGN = buffer.pop(0)
                print 'Doing sign: ' + SIGN
                with open("/home/odroid/catkin_ws/src/robot_body/recording/data_base/" + SIGN + ".json", "r") as sign:
                    movement = json.load(sign)
            except Exception, err:
                print 'Robot can not do sign, error is '
                print  err
                show.name = SIGN
                show.time = 3
                HEAD_TXT.publish(show)
                time.sleep(3)
                continue
            playingPub.publish(1)
            names = movement["actors_NAME"]
            frames = movement["frame_number"]
            freq = float(movement["freq"])
            emotion = movement["emotion_name"]
            text = movement["text"]
            time_to_show = [3]#movement["emotion_time"]
            word_to_speak = movement["speak"]
            sign = movement["position"]
            motor_to_release = [mtr for mtr in old_motors if (mtr not in names) & (mtr not in torso)]
            if motor_to_release:
                goal_position = {"Robot": sign['0']['Robot']+[0 for name in motor_to_release],
                    "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100] if [mtr for mtr in motor_to_release if mtr in right_hand_motors]
                    else sign['0']['Right_hand'],
                    "Left_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100] if [mtr for mtr in motor_to_release if mtr in left_hand_motors]
                    else sign['0']['Left_hand']}
            else:
                goal_position = sign['0']
            tools.go_to_pos(names+motor_to_release, present_pos, goal_position, pub, L, R, left_hand, right_hand)
            tools.releas(motor_to_release, pub, present_pos)
            if emotion != '':
                HEAD_PUB = HEAD_EMO
                show.name = emotion
            elif text != '':
                HEAD_PUB = HEAD_TXT
                show.name = text
            else:
                HEAD_PUB = None
            print "time: " + str(time_to_show)
            if time_to_show:
                show.time = time_to_show[0]
            SPEAKER.publish(word_to_speak)
            tools.do_seq(names, freq, sign, pub, L, R, HEAD_PUB, show)
            right_hand = sign[str(frames - 1)]["Right_hand"]
            left_hand  = sign[str(frames - 1)]["Left_hand"]
            old_motors = names
            
            playingPub.publish(0)


            if not buffer:
                goal_position = {'Robot': [0 for name in names],
                                 'Right_hand': [200, 200, 100, 100, 200, 100, 100, 100, 100],
                                 'Left_hand': [200, 200, 100, 100, 200, 100, 100, 100, 100]}
                tools.go_to_pos(names, present_pos, goal_position, pub, L, R, left_hand, right_hand)
                right_hand = [200, 200, 100, 100, 200, 100, 100, 100, 100]
                left_hand = [200, 200, 100, 100, 200, 100, 100, 100, 100]
                tools.releas([name for name in names if name not in torso], pub, None, L, R)
                old_motors = []


        else:
            if (time.time() - start > time_to_sleep) & (robot_stat == 'ready'):
                tools.releas([name for name in list  if present_pos[name].compliant == False], pub, present_pos, L, R)
                robot_stat = 'sleep'
                print 'robot going to sleep'
            time.sleep(1)
Exemple #8
0
    def __init__(self, master, motors):
        self.motorsName = motors
        self.deadmotors = [x for x in motor_names if x not in self.motorsName]
        self.master = master
        self.master.geometry('250x200')
        self.master.title('POS_BY_POS RECORDING')
        self.tl = Label(master, text="Time:")
        self.tl.grid(row=0, column=0)
        self.time = StringVar(value=1)
        self.timeEntry = Entry(master, width=3, textvariable=self.time)
        self.timeEntry.grid(row=0, column=1)
        self.setpos = Button(master,
                             text="Set pos",
                             width=5,
                             command=self.setcall)
        self.setpos.grid(row=1, column=0, columnspan=2)
        self.build = Button(master, text="Build", width=5, command=self.build)
        self.build.grid(row=2, column=0, columnspan=2)
        self.build.config(state=DISABLED)
        self.play = Button(master, text="Play", width=5, command=self.play)
        self.play.grid(row=3, column=0, columnspan=2)
        self.play.config(state=DISABLED)
        self.save = Button(master, text="Save", width=5, command=self.save)
        self.save.grid(row=4, column=0, columnspan=2)
        self.save.config(state=DISABLED)
        self.info = StringVar()
        self.show = Label(master, textvariable=self.info)
        self.show.grid(row=5, column=0, columnspan=4)
        self.set_hand = Button(master,
                               text="Config fingers",
                               width=8,
                               command=self.Handset)
        self.set_hand.grid(row=5, column=4)
        self.set_hand.config(state=DISABLED)
        self.close = Button(master, text="Close", width=8, command=self.close)
        self.close.grid(row=6, column=4)
        self.sl = Label(master, text="Settings")
        self.sl.grid(row=0, column=2, columnspan=2)
        self.sets = Listbox(master, height=5, width=8)
        self.sets.grid(row=1, column=2, rowspan=3, columnspan=2)
        self.mtr_l = Label(master, text="Motors to block")
        self.mtr_l.grid(row=0, column=4)
        self.activemotors = Listbox(master,
                                    height=7,
                                    width=12,
                                    selectmode=MULTIPLE)
        self.activemotors.grid(row=1, column=4, rowspan=4)
        self.activemotors.bind('<<ListboxSelect>>', self.selection)
        self.edit = Button(master, text="Edit", width=1, command=self.edit)
        self.edit.grid(row=4, column=2)
        self.edit.config(state=DISABLED)
        self.delete = Button(master, text="Del", width=1, command=self.delete)
        self.delete.grid(row=4, column=3)
        self.delete.config(state=DISABLED)
        #print self.motorsName
        #print self.deadmotors
        for name in self.motorsName:
            self.activemotors.insert(END, str(name))
        self.settings = {}
        self.sign = {}

        print('Starting the ROBOT')
        #present_position = [motor[name].present_position for name in self.motorsName]
        goal_position = {
            "Robot": [0 for name in self.deadmotors],
            "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100],
            "Left_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100]
        }
        tools.go_to_pos(self.deadmotors, motor, goal_position, pub)
        tools.releas(self.motorsName, pub, motor)
        print('Robot started')
        self.info.set("Robot is Ready")
Exemple #9
0
    def __init__(self, master, motors):
        self.motorsName = motors
        self.deadmotors = [x for x in motor_names if x not in self.motorsName]
        self.master = master
        self.master.geometry('540x220')
        self.master.title('AUTO RECORDING')
        self.freqLb = Label(master, text="freq").grid(row=0, column=0)
        self.Frq = StringVar(self.master, value='50')
        self.freq = Entry(master, width=10,
                          textvariable=self.Frq).grid(row=0, column=1)
        self.strTm = Label(master, text="Time to start").grid(row=1, column=1)
        self.StrTm = StringVar(self.master, value='2')
        self.startTime = Entry(master, width=10,
                               textvariable=self.StrTm).grid(row=1,
                                                             column=2,
                                                             sticky=W)
        self.stpTm = Label(master, text="Time to stop").grid(row=2, column=1)
        self.STP = IntVar(self.master, value=1)
        self.stop = Checkbutton(master,
                                variable=self.STP,
                                command=self.timeToStop).grid(row=2, column=0)
        self.StpTm = StringVar(self.master, value='5')
        self.stopTime = Entry(self.master, width=10, textvariable=self.StpTm)
        self.stopTime.grid(row=2, column=2, sticky=W)
        self.startRec = Button(self.master,
                               text='Start Recording',
                               width=10,
                               command=self.STARTREC)
        self.startRec.grid(row=5, column=1, sticky=NW)
        self.play = Button(self.master,
                           text='Play',
                           width=10,
                           command=self.PLAY)
        self.play.grid(row=6, column=1, sticky=NW)
        self.play.config(state=DISABLED)
        self.save = Button(self.master,
                           text='Save',
                           width=10,
                           command=self.SAVE)
        self.save.grid(row=7, column=1, sticky=NW)
        self.save.config(state=DISABLED)
        self.varInfo = StringVar(
            self.master,
            value="<------ Click here to start recording \n\n\n\n"
            "First you need to set the friquance of recording, \n"
            "time to start and the recording time \n"
            "than click on Start Recording Button to start the recording.")
        self.info = Label(self.master,
                          justify=LEFT,
                          width=50,
                          height=8,
                          textvariable=self.varInfo)
        self.info.grid(row=5, column=2, rowspan=4, sticky=W)
        self.close = Button(self.master,
                            text='Close',
                            width=6,
                            command=self.CLOSE)
        self.close.grid(row=9, column=2, sticky=E)

        self.handset = Button(self.master,
                              text='Hand set',
                              width=10,
                              command=self.Handset)
        self.handset.grid(row=8, column=1)
        self.handset.config(state=DISABLED)
        self.STOP = 0

        print('Starting the ROBOT')
        goal_position = {
            "Robot": [0 for name in self.deadmotors],
            "Right_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100],
            "Left_hand": [200, 200, 100, 100, 200, 100, 100, 100, 100]
        }
        tools.go_to_pos(self.deadmotors, motor, goal_position, pub)
        tools.releas(self.motorsName, pub, motor)
        print('Robot started')