Beispiel #1
0
    def buildPlay():
        if master.needToBuild:
            print 'building'
            #if master.setted_frame[0] != 0:
             #   master.setted_frame.insert(0, 0)
                #master.movement['position'][str(0)]['Left_hand'] = [200] * 9
                #master.movement['position'][str(0)]['Right_hand'] = [200] * 9
            if master.setted_frame[len(master.setted_frame) - 1] != master.movement['frame_number']:
                master.setted_frame.append(master.movement['frame_number'])
            index = 1
            while index < len(master.setted_frame):
                start = master.setted_frame[index - 1]
                stop = master.setted_frame[index]
                #        if (not master.movement['position'][str(0)]['Left_hand'])|(not master.movement['position'][str(0)]['Right_hand']):
                #            master.movement['position'][str(0)]['Left_hand'] = [200]*9
                #            master.movement['position'][str(0)]['Right_hand'] = [200]*9

                for frame in range(start + 1, stop, 1):
                    master.movement['position'][str(frame)]['Left_hand'] = master.movement['position'][str(start)]['Left_hand']
                    master.movement['position'][str(frame)]['Right_hand'] = master.movement['position'][str(start)]['Right_hand']
                index += 1
            print 'Done Building'

            print 'Smoothing the motion'

            win = find_smth_win()/int(2) if master.autoSmth.get() == 1 else master.smooth.get()
            for frame in range(master.movement['frame_number']):
                master.movement['position'][str(frame)]['Left_hand'] = np.mean([master.movement['position'][str(frame + i)]['Left_hand'] for i in range(min(master.movement['frame_number'] - frame-1, win)+1)], 0)
                master.movement['position'][str(frame)]['Right_hand'] = np.mean([master.movement['position'][str(frame + i)]['Right_hand'] for i in range(min(master.movement['frame_number'] - frame-1, win)+1)], 0)
                master.movement['position'][str(frame)]['Left_hand'] = list(np.int_(master.movement['position'][str(frame)]['Left_hand']))
                master.movement['position'][str(frame)]['Right_hand'] = list(np.int_(master.movement['position'][str(frame)]['Right_hand']))
            print 'Done Smoothing'
            master.needToBuild = False
            save.config(state=NORMAL)

        time.sleep(0.5)
        print 'Playing'
        goal_position = master.movement["position"]["0"]
        tools.go_to_pos(active_motors, motor, goal_position, pub, L, R)



        if list(master.emotion_list.curselection()):
            if master.emotion_list.get(master.emotion_list.curselection())=='show text':
                print 'text'
                HEAD_PUB = HEAD_TXT
                show.name = master.text.get()
            else:
                print 'emotion'
                HEAD_PUB = HEAD_EMO
                show.name = master.emotion_list.get(master.emotion_list.curselection())
            show.time = float(master.emotion_time.get())
            print show
        else:
            HEAD_PUB = None

        tools.do_seq(active_motors, master.movement["freq"], master.movement["position"],pub, L, R, HEAD_PUB, show)
        master.recSlider.set(master.movement["frame_number"])
        print 'Done'
Beispiel #2
0
    def PLAY(self):

        print 'Playing'
        goal_position = self.movement['position']['0']
        tools.go_to_pos(self.movement['actors_NAME'], motor, goal_position,
                        pub)
        tools.do_seq(self.movement['actors_NAME'], self.movement['freq'],
                     self.movement['position'], pub)
        print 'Done'
Beispiel #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()
Beispiel #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()
Beispiel #5
0
 def play(self):
     self.info.set("Playing")
     goal_position = self.sign["position"]["0"]
     tools.go_to_pos(self.motorsName, motor, goal_position, pub)
     for frame in range(len(self.sign["position"])):
         id = 0
         for name in self.sign["actors_NAME"]:
             MOTOR.compliant = False
             MOTOR.goal_position = self.sign["position"][str(
                 frame)]["Robot"][id]
             id += 1
             pub[name].publish(MOTOR)
         time.sleep(
             float(self.time.get()) / float(self.sign["frame_number"]))
     self.info.set("Done")
Beispiel #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()
Beispiel #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)
Beispiel #8
0
def __init__(master, movement, motor, pub):
    master.geometry('575x405')
    master.title('SETTING THE HAND')
    title = Frame(master)
    title.grid(row=0, column=0, columnspan=3, sticky=W+E+N+S)
    lefthand = LabelFrame(master, text="Left hand", bg = "red")
    lefthand.grid(row=1, column=0)
    righthand = LabelFrame(master, text="Right hand", bg = "green")
    righthand.grid(row=1, column=2)
    medButt = LabelFrame(master, text="Hands sets",bg = "blue")
    medButt.grid(row=1, column=1)
    buttfram = LabelFrame(master, text="Tools", bg="blue")
    buttfram.grid(row=2, column=0, columnspan=3, sticky=W+E+N+S)
    master.closing = False
    master.movement = movement
    active_motors = master.movement['actors_NAME']
    dead_motors = [name for name in motor if name not in active_motors]
    print('Starting the ROBOT')
    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 = master.movement['position']['0']
    tools.go_to_pos(active_motors, motor, goal_position, pub)
    print('Robot Started')



#//////////////////////////////////////////////////////////////////////////LEFT  ARM////////////////////////////////////////////////////////////////////////
    def LgetValue1(event):
        tools.left_servo_set(1, master.Lwrist_V.get(), L)

    master.Lwrist_V = Scale(lefthand, from_=300, to =100, orient = VERTICAL, length = 100, showvalue=0, command = LgetValue1)
    master.Lwrist_V.set(200)
    master.Lwrist_V.grid(row=2, column=0, rowspan=3, sticky=E)

    def LgetValue2(event):
        tools.left_servo_set(2, master.Lwrist_H.get(), L)

    master.Lwrist_H = Scale(lefthand, from_=300, to =100, orient = HORIZONTAL, length = 100, showvalue=0, command = LgetValue2)
    master.Lwrist_H.set(200)
    master.Lwrist_H.grid(row=4, column=1, columnspan=3, sticky=SW)

    def LgetValue3(event):
        tools.left_servo_set(3, master.Lthump_J.get(), L)

    master.Lthump_J = Scale(lefthand, from_=300, to =100, orient = HORIZONTAL, length = 75, showvalue=0, command = LgetValue3)
    master.Lthump_J.set(100)
    master.Lthump_J.grid(row=2, column=3, columnspan=2, sticky=NE)

    def LgetValue4(event):
        tools.left_servo_set(4, master.Lthump.get(), L)

    master.Lthump = Scale(lefthand, from_=100, to =300, orient = VERTICAL, length = 100, showvalue=0, command = LgetValue4)
    master.Lthump.set(100)
    master.Lthump.grid(row=0, column=4, rowspan=2, sticky=SE)

    def LgetValue5(event):
        tools.left_servo_set(5, master.LOpen.get(), L)

    master.LOpen = Scale(lefthand, from_=300, to =100, orient = HORIZONTAL, length = 125, showvalue=0, command = LgetValue5)
    master.LOpen.set(200)
    master.LOpen.grid(row=1, column=0, columnspan=4, sticky=W)

    def LgetValue6(event):
        tools.left_servo_set(6, master.Lindex.get(), L)

    master.Lindex = Scale(lefthand, from_=100, to =300, orient = VERTICAL, length = 100, showvalue=0, command = LgetValue6)
    master.Lindex.set(100)
    master.Lindex.grid(row=0, column=3)

    def LgetValue7(event):
        tools.left_servo_set(7, master.Lmajor.get(), L)

    master.Lmajor = Scale(lefthand, from_=100, to =300, orient = VERTICAL, length = 100, showvalue=0, command = LgetValue7)
    master.Lmajor.set(100)
    master.Lmajor.grid(row=0, column=2)

    def LgetValue8(event):
        tools.left_servo_set(8, master.Lring.get(), L)

    master.Lring = Scale(lefthand, from_=100, to =300, orient = VERTICAL, length = 100, showvalue=0, command = LgetValue8)
    master.Lring.set(100)
    master.Lring.grid(row=0, column=1)

    def LgetValue9(event):
        tools.left_servo_set(9, master.Lauri.get(), L)

    master.Lauri = Scale(lefthand, from_=100, to =300, orient = VERTICAL, length = 100, showvalue=0, command = LgetValue9)
    master.Lauri.set(100)
    master.Lauri.grid(row=0, column=0)
#//////////////////////////////////////////////////////////////////////////LEFT  ARM////////////////////////////////////////////////////////////////////////


#//////////////////////////////////////////////////////////////////////////RIGHT ARM////////////////////////////////////////////////////////////////////////
    def RgetValue1(event):
        tools.right_servo_set(1, master.Rwrist_V.get(), R)


    master.Rwrist_V = Scale(righthand, from_=100, to =300, orient=VERTICAL, length=100, showvalue=0, command=RgetValue1)
    master.Rwrist_V.set(200)
    master.Rwrist_V.grid(row=2, column=4, rowspan=3, sticky=W)


    def RgetValue2(event):
        tools.right_servo_set(2, master.Rwrist_H.get(), R)


    master.Rwrist_H = Scale(righthand, from_=100, to =300, orient=HORIZONTAL, length=100, showvalue=0, command=RgetValue2)
    master.Rwrist_H.set(200)
    master.Rwrist_H.grid(row=4, column=1, columnspan=3, sticky=SE)


    def RgetValue3(event):
        tools.right_servo_set(3, master.Rthump_J.get(), R)


    master.Rthump_J = Scale(righthand, from_=100, to =300, orient=HORIZONTAL, length=75, showvalue=0, command=RgetValue3)
    master.Rthump_J.set(100)
    master.Rthump_J.grid(row=2, column=0, columnspan=2, sticky=NW)


    def RgetValue4(event):
        tools.right_servo_set(4, master.Rthump.get(), R)


    master.Rthump = Scale(righthand, from_=100, to =300, orient=VERTICAL, length=100, showvalue=0, command=RgetValue4)
    master.Rthump.set(100)
    master.Rthump.grid(row=0, column=0, rowspan=2, sticky=SW)


    def RgetValue5(event):
        tools.right_servo_set(5, master.ROpen.get(), R)


    master.ROpen = Scale(righthand, from_=100, to =300, orient=HORIZONTAL, length=125, showvalue=0, command=RgetValue5)
    master.ROpen.set(200)
    master.ROpen.grid(row=1, column=1, columnspan=4, sticky=E)


    def RgetValue6(event):
        tools.right_servo_set(6, master.Rindex.get(), R)


    master.Rindex = Scale(righthand, from_=100, to =300, orient=VERTICAL, length=100, showvalue=0, command=RgetValue6)
    master.Rindex.set(100)
    master.Rindex.grid(row=0, column=1)


    def RgetValue7(event):
        tools.right_servo_set(7, master.Rmajor.get(), R)


    master.Rmajor = Scale(righthand, from_=100, to =300, orient=VERTICAL, length=100, showvalue=0, command=RgetValue7)
    master.Rmajor.set(100)
    master.Rmajor.grid(row=0, column=2)


    def RgetValue8(event):
        tools.right_servo_set(8, master.Rring.get(), R)


    master.Rring = Scale(righthand, from_=100, to =300, orient=VERTICAL, length=100, showvalue=0, command=RgetValue8)
    master.Rring.set(100)
    master.Rring.grid(row=0, column=3)


    def RgetValue9(event):
        tools.right_servo_set(9, master.Rauri.get(), R)


    master.Rauri = Scale(righthand, from_=100, to =300, orient=VERTICAL, length=100, showvalue=0, command=RgetValue9)
    master.Rauri.set(100)
    master.Rauri.grid(row=0, column=4)
#//////////////////////////////////////////////////////////////////////////RIGHT ARM////////////////////////////////////////////////////////////////////////


    def setframe(event):
        master.frm = master.recSlider.get()

        tools.do_seq(active_motors, 100, {'0':master.movement['position'][str(master.frm)]}, pub)

        if master.Lrec.get() == 0:
            tools.multi_servo_set(master.movement['position'][str(master.frm)]['Left_hand'], None, L)

        if master.Rrec.get() == 0:
            tools.multi_servo_set(None, master.movement['position'][str(master.frm)]['Right_hand'], None, R)


    def DelBefor():

        if tkMessageBox.askyesno(title='Warning', message='Warning: Do you want to delete the sequanses Befor the the frame ' + str(master.frm) + '?', parent=master):
            mov = {} #master.movement['position']

            newfrm=0
            for frm in range(master.frm, master.movement['frame_number'], 1):
                mov[str(newfrm)] = master.movement['position'][str(frm)]
                newfrm +=1
            master.movement.pop('position')
            master.movement['position'] = mov
            #master.movement['position'] = master.movement['position'][str(0):str(master.frm)]
            master.movement['frame_number']=newfrm
            master.recSlider.config(to=master.movement['frame_number'] - 1)
            master.recSlider.set(0)
            save.config(state=NORMAL)

    def DelAfter():

        if tkMessageBox.askyesno(title='Warning', message='Warning: Do you want to delete the sequanses After the the frame '+ str(master.frm) + '?', parent=master):
            for frm in range(master.frm, master.movement['frame_number'], 1):
                master.movement['position'].pop(str(frm))

            master.movement['frame_number'] = master.frm
            master.recSlider.config(to=master.movement['frame_number'] - 1)
            save.config(state=NORMAL)

    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)
        tools.multi_servo_set([0] * 9, [0] * 9, L, R)
        print 'Robot Closed'

        master.destroy()

    def savecall():
        print 'saving movement'
        saveFile = tkFileDialog.asksaveasfilename(defaultextension="json", initialdir="/home/odroid/catkin_ws/src/robot_body/recording/data_base", parent=master)
        if not saveFile:
            return None
        if list(master.emotion_list.curselection()):
            if master.emotion_list.get(master.emotion_list.curselection())=='show text':
                master.movement['text']=master.text.get()
            else:
                master.movement['emotion_name']=master.emotion_list.get(master.emotion_list.curselection())
            master.movement['emotion_time']=master.emotion_time.get()
        with open(saveFile, "w") as record:
            json.dump(master.movement, record)
        print 'saved'

    def setcall():
        print 'seting'
        master.lefthandpos = [master.Lwrist_V.get(), master.Lwrist_H.get(), master.Lthump_J.get(), master.Lthump.get(), master.LOpen.get(),
               master.Lindex.get(), master.Lmajor.get(), master.Lring.get(), master.Lauri.get()]
        master.righthandpos = [master.Rwrist_V.get(), master.Rwrist_H.get(), master.Rthump_J.get(), master.Rthump.get(), master.ROpen.get(),
                              master.Rindex.get(), master.Rmajor.get(), master.Rring.get(), master.Rauri.get()]
        master.movement['position'][str(master.frm)]['Left_hand'] = master.lefthandpos
        master.movement['position'][str(master.frm)]['Right_hand'] = master.righthandpos
        if master.frm not in master.setted_frame:
            master.setted_frame.append(master.frm)
            list(set(master.setted_frame))  # sort the list
        if ~master.needToBuild:
            master.needToBuild = True

        clear.config(state=NORMAL)
        print 'done'

    def find_smth_win():
        winSize = master.setted_frame[len(master.setted_frame)-1] - master.setted_frame[0]
        for i in range(len(master.setted_frame)-1):
            winSize = min(master.setted_frame[i+1]-master.setted_frame[i], winSize)
        return winSize;

    def buildPlay():
        if master.needToBuild:
            print 'building'
            #if master.setted_frame[0] != 0:
             #   master.setted_frame.insert(0, 0)
                #master.movement['position'][str(0)]['Left_hand'] = [200] * 9
                #master.movement['position'][str(0)]['Right_hand'] = [200] * 9
            if master.setted_frame[len(master.setted_frame) - 1] != master.movement['frame_number']:
                master.setted_frame.append(master.movement['frame_number'])
            index = 1
            while index < len(master.setted_frame):
                start = master.setted_frame[index - 1]
                stop = master.setted_frame[index]
                #        if (not master.movement['position'][str(0)]['Left_hand'])|(not master.movement['position'][str(0)]['Right_hand']):
                #            master.movement['position'][str(0)]['Left_hand'] = [200]*9
                #            master.movement['position'][str(0)]['Right_hand'] = [200]*9

                for frame in range(start + 1, stop, 1):
                    master.movement['position'][str(frame)]['Left_hand'] = master.movement['position'][str(start)]['Left_hand']
                    master.movement['position'][str(frame)]['Right_hand'] = master.movement['position'][str(start)]['Right_hand']
                index += 1
            print 'Done Building'

            print 'Smoothing the motion'

            win = find_smth_win()/int(2) if master.autoSmth.get() == 1 else master.smooth.get()
            for frame in range(master.movement['frame_number']):
                master.movement['position'][str(frame)]['Left_hand'] = np.mean([master.movement['position'][str(frame + i)]['Left_hand'] for i in range(min(master.movement['frame_number'] - frame-1, win)+1)], 0)
                master.movement['position'][str(frame)]['Right_hand'] = np.mean([master.movement['position'][str(frame + i)]['Right_hand'] for i in range(min(master.movement['frame_number'] - frame-1, win)+1)], 0)
                master.movement['position'][str(frame)]['Left_hand'] = list(np.int_(master.movement['position'][str(frame)]['Left_hand']))
                master.movement['position'][str(frame)]['Right_hand'] = list(np.int_(master.movement['position'][str(frame)]['Right_hand']))
            print 'Done Smoothing'
            master.needToBuild = False
            save.config(state=NORMAL)

        time.sleep(0.5)
        print 'Playing'
        goal_position = master.movement["position"]["0"]
        tools.go_to_pos(active_motors, motor, goal_position, pub, L, R)



        if list(master.emotion_list.curselection()):
            if master.emotion_list.get(master.emotion_list.curselection())=='show text':
                print 'text'
                HEAD_PUB = HEAD_TXT
                show.name = master.text.get()
            else:
                print 'emotion'
                HEAD_PUB = HEAD_EMO
                show.name = master.emotion_list.get(master.emotion_list.curselection())
            show.time = float(master.emotion_time.get())
            print show
        else:
            HEAD_PUB = None

        tools.do_seq(active_motors, master.movement["freq"], master.movement["position"],pub, L, R, HEAD_PUB, show)
        master.recSlider.set(master.movement["frame_number"])
        print 'Done'

    def clearcall():
        master.setted_frame = []
        master.needToBuild = False

    def setauto():
        master.smooth.config(state=NORMAL) if master.autoSmth.get() == 0 else master.smooth.config(state=DISABLED)

    def saveL():
        lefthandpos = [master.Lwrist_V.get(), master.Lwrist_H.get(), master.Lthump_J.get(), master.Lthump.get(),
                              master.LOpen.get(), master.Lindex.get(), master.Lmajor.get(), master.Lring.get(), master.Lauri.get()]
        name = tkSimpleDialog.askstring('Left Hand set name', 'Please enter the name of the Left hand set', parent=master)
        if name:
            handSetting["Left"][name] = lefthandpos
            L_handSets.insert(len(handSetting["Left"]), name)
        else:
            print "you Should enter the mane of the hand set"

        with open("/home/odroid/catkin_ws/src/robot_body/recording/handSetting.json", "w") as h:
            json.dump(handSetting, h)

    def saveR():
        righthandpos = [master.Rwrist_V.get(), master.Rwrist_H.get(), master.Rthump_J.get(), master.Rthump.get(),
                                master.ROpen.get(), master.Rindex.get(), master.Rmajor.get(), master.Rring.get(), master.Rauri.get()]
        name = tkSimpleDialog.askstring('Right Hand set name', 'Please enter the name of the Right hand set', parent=master)
        if name:
            handSetting["Right"][name] = righthandpos
            R_handSets.insert(len(handSetting["Right"]), name)
        else:
            print "you Should enter the mane of the hand set"

        with open("/home/odroid/catkin_ws/src/robot_body/recording/handSetting.json", "w") as h:
            json.dump(handSetting, h)

    def Lrel():
        tools.multi_servo_set([50] * 9, None, L)

    def Rrel():
        tools.multi_servo_set(None, [50] * 9, None, R)

    close = Button(buttfram, text='Close', width=5, command=closecall)
    close.grid(row=4, column=7, sticky=E)


    rel = Button(lefthand, text="Rel",width = 0, command =  Lrel)
    rel.grid(row=3, column=1)
    LSET = Button(lefthand, text=">>", width=0, command=saveL)
    LSET.grid(row=3, column=3)
    master.Lrec = IntVar(lefthand,value=1)
    recL = Checkbutton(lefthand, variable=master.Lrec)
    recL.grid(row=3, column=2)

    rer = Button(righthand, text="Rel", width=0, command= Rrel)
    rer.grid(row=3, column=3)
    RSET = Button(righthand, text="<<", width=0, command=saveR)
    RSET.grid(row=3, column=1)
    master.Rrec = IntVar(righthand, value=1)
    recR = Checkbutton(righthand, variable=master.Rrec)
    recR.grid(row=3, column=2)


    L_handSets = Listbox(medButt, height=10, width=10)
    L_handSets.grid(row=2, column=0, columnspan=2)
    R_handSets = Listbox(medButt, height=10, width=10)
    R_handSets.grid(row=2, column=2, columnspan=2)
    try:
        with open("/home/odroid/catkin_ws/src/robot_body/recording/handSetting.json", "r") as f:
            handSetting = json.load(f)

        for name, pos in handSetting["Left"].items():

            L_handSets.insert(END, (name))
        for name, pos in handSetting["Right"].items():

            R_handSets.insert(END, (name))
    except Exception, err:
        print err
Beispiel #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('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")
Beispiel #10
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')