コード例 #1
0
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     if self.keyframes == ([], [], []):
         if posture == "Back":
             if self.keyframes != rightBackToStand():
                 self.reset_time()
                 self.keyframes = rightBackToStand()
                 print(
                     "Posture is \"Back\" --> Changing keyframe to rightBackToStand"
                 )
         elif posture == "Belly":
             if self.keyframes != rightBellyToStand():
                 self.reset_time()
                 self.keyframes = rightBellyToStand()
                 print(
                     "Posture is \"Belly\" --> Changing keyframe to rightBellyToStand"
                 )
         elif posture == "Left":
             if self.keyframes != leftBackToStand():
                 self.reset_time()
                 self.keyframes = leftBackToStand()
                 print(
                     "Posture is \"Left\" --> Changing keyframe to leftBackToStand"
                 )
         elif posture == "Right":
             if self.keyframes != rightBellyToStand():
                 self.reset_time()
                 self.keyframes = rightBellyToStand()
                 print(
                     "Posture is \"Right\" --> Changing keyframe to rightBellyToStand"
                 )
コード例 #2
0
    def standing_up(self):
        posture = self.posture
        # YOUR CODE HERE

        if posture == "Left":
            self.keyframes = keyframes.leftBackToStand()
        elif posture == "Right":
            self.keyframes = keyframes.rightBackToStand()
        elif posture == "Belly":
            self.keyframes = keyframes.leftBellyToStand()
        elif posture == "Back":
            self.keyframes = keyframes.rightBackToStand()
コード例 #3
0
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     if posture == 'Back' or posture == 'HeadBack':
         self.keyframes = rightBackToStand()
         return
     elif posture == 'Belly' or posture == 'Frog:
         self.keyframes = rightBellyToStand()
         return
     elif posture == 'Right' or posture is 'Left':
         self.keyframes = rightBackToStand()
         return
     elif posture == 'Stand':
         self.keyframes = hello()
         return
コード例 #4
0
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     if posture == 'Back':
         self.keyframes = kf.rightBackToStand()
     elif posture == 'Belly':
         self.keyframes = kf.leftBellyToStand()
コード例 #5
0
 def standing_up(self):
     posture = self.posture
     #returns the predicted postrue
     if posture in ['Back','Sit','Left','Headback','Right']: # Left, 'Headback', 'Sit', 'Right'
         self.keyframes = rightBackToStand()
     elif posture in ['Belly','Frog','Crouch']:
         self.keyframes = rightBellyToStand()
コード例 #6
0
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     #['Back', 'Belly', 'Crouch', 'Frog', 'HeadBack', 'Knee', 'Left', 'Right', 'Sit', 'Stand', 'StandInit']
     if posture == 'Belly':
         self.keyframes = rightBellyToStand()
     elif posture == 'Back':
         self.keyframes = rightBackToStand()
コード例 #7
0
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     print(posture)
     if (posture == 1):  # 'Belly'):
         self.keyframes = rightBellyToStand()
     elif (posture == 0):  # 'Back'):
         self.keyframes = rightBackToStand()
コード例 #8
0
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     if posture == 'Left':
         self.keyframe = leftBackToStand()
     if posture in ['Back', 'Headback', 'Sit', 'Right']:
         self.keyframe = rightBackToStand()
     if posture in ['Crouch', 'Belly', 'Frog']:
         self.keyframe = rightBellyToStand()
    def standing_up(self):
        posture = self.posture
        # YOUR CODE HERE
        # print(f"{posture}")
        if self.old_posture != "unknown" and self.old_posture != posture and posture in ["Belly", "Back", "Left", "Right"] :
            logging.info(f"{self.old_posture} != {posture}!!!")
            self.start_time = -1

        if self.start_time == -1:
            if posture == "Left":
                self.keyframes = kf.leftBackToStand()
            elif posture == "Right":
                self.keyframes = kf.rightBackToStand()
            elif posture == "Belly":
                self.keyframes = kf.leftBellyToStand()
            elif posture == "Back":
                self.keyframes = kf.rightBackToStand()

        self.old_posture = posture
コード例 #10
0
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     
     print self.startTime, self.stiffness
     if(self.startTime == -1 and self.stiffness == 1):
         # postures: ['Left', 'HeadBack', 'Belly', 'Stand', 'Frog', 'StandInit', 'Back', 'Right', 'Knee', 'Sit', 'Crouch']
         if(posture == "Left"):
             self.keyframes = kf.leftBackToStand()
             print "### recognized :" + posture + ", executing leftBackToStand()"
         elif(posture == "Right"):
             self.keyframes = kf.rightBackToStand()
             print "### recognized :" + posture + ", executing rightBackToStand()"
         elif(posture == "Belly"):
             self.keyframes = kf.rightBellyToStand()
             print "### recognized :" + posture + ", executing leftBellyToStand()"
         elif(posture == "Back" or posture == "Frog" or posture == "Sit"):
             self.keyframes = kf.rightBackToStand()
             print "### recognized :" + posture + ", executing rightBackToStand()"
コード例 #11
0
 def standing_up(self):
     posture = self.posture
     if (posture == 'Belly'):
         self.keyframes = leftBellyToStand()
     elif (posture == 'Back' or posture == 'Left'):
         self.keyframes = leftBackToStand()
     elif (posture == 'Right'):
         self.keyframes = rightBackToStand()
     elif (posture == 'Stand'):
         self.keyframes = hello()
コード例 #12
0
 def standing_up(self):
     posture = self.posture
     print posture
     if posture == "Belly":
         self.keyframes = leftBellyToStand()
     if posture == "Back":
         self.keyframes = leftBackToStand()
     if posture == "Left":
         self.keyframes = leftBackToStand()
     if posture == "Right":
         self.keyframes = rightBackToStand()
コード例 #13
0
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     #print(posture == 0)
     # ['Back', 'Belly', 'Crouch', 'Frog', 'HeadBack',
     # 'Knee', 'Left', 'Right', 'Sit', 'Stand', 'StandInit']
     # 0 = back , 1 = belly etc
     if posture == 1 or posture == 2 or posture == 5 or posture == 6:
         self.keyframes = leftBellyToStand()
     if posture == 0 or posture == 3 or posture == 7 or posture == 8:
         #print('test')
         self.keyframes = rightBackToStand()
コード例 #14
0
    def standing_up(self):
        posture = self.posture
        # YOUR CODE HERE

        if posture == "Back":
            self.keyframes = leftBackToStand()
        elif posture == "Belly":
            self.keyframes = leftBellyToStand()
        elif posture == "Stand":
            self.keyframes = leftBellyToStand()
        elif posture == "Left":
            self.keyframes = rightBackToStand()
    def standing_up(self, perception):
        posture = self.posture
        # YOUR CODE HERE

        # The robot plays the animation, but can't actually stand up using that.
        # I expect that the interpolation is at fault for that.
        if posture == 'Belly':
            self.keyframes = rightBellyToStand()
        if posture == 'Back':
            self.keyframes = rightBackToStand()
        if posture == 'Standing':
            self.keyframes = hello()
コード例 #16
0
 def standing_up(self):
     posture = self.posture
     # only update keyframe if the agent is in on mode and no other keyframe is being executed
     if self.is_on and self.t0==-1 :
         self.posture = self.recognize_posture(self.perception) # regonize posture
         # select keyframe based on the posture
         if posture=='Belly':
             self.keyframes=leftBellyToStand()
         elif posture=='Back' or posture=='Left' or posture=='HeadBack':
             self.keyframes=leftBackToStand()
         elif posture=='Right' or posture=='Sit':
             self.keyframes=rightBackToStand()
         elif posture=='Stand' or posture =='StandInit':
             self.keyframes=([],[],[])
コード例 #17
0
 def standing_up(self):
     posture = self.posture
     if (posture == 'Belly'):
         if (self.time <= 0):
             self.start_time = 0
             self.keyframes = rightBellyToStand()
             self.time = 14.02
     if (posture == 'Back'):
         if (self.time <= 0):
             self.start_time = 0
             self.keyframes = rightBackToStand()
             self.time = 14.02
     if (self.time > 0):
         self.time -= 0.02
コード例 #18
0
    def standing_up(self):
        posture = self.posture
        # YOUR CODE HERE

        leftBackToStand_classes = ['Back', 'HeadBack', 'Left', 'Sit']
        leftBellyToStand_classes = ['Belly']
        rightBackToStand_classes = ['Right']

        if (self.perception.time -
                self.stiffness_on_off_time) > self.stiffness_off_cycle:
            if posture in leftBackToStand_classes:
                self.keyframes = leftBackToStand()
            elif posture in leftBellyToStand_classes:
                self.keyframes = leftBellyToStand()
            elif posture in rightBackToStand_classes:
                self.keyframes = rightBackToStand()
        else:
            self.keyframes = ([], [], [])
コード例 #19
0
    def standing_up(self):
        posture = self.posture
        #print(posture)
        # YOUR CODE HERE

        leftBack = ['HeadBack', 'Left']
        rightBack = ['Back', 'Right']
        leftBelly = ['Belly', 'knee']
        rightBelly = ['Crouch', 'Frog', 'Sit']
        standing = ['Stand', 'StandInit']

        #if (self.stiffness_on_off_time + self.stiffness_off_cycle - self.perception.time <= 0.1):
        if not self.keyframes[0]:
            if posture in leftBack:
                self.keyframes = keyframes.leftBackToStand()
            elif posture in rightBack:
                self.keyframes = keyframes.rightBackToStand()
            elif posture in leftBelly:
                self.keyframes = keyframes.leftBellyToStand()
            elif posture in rightBelly:
                self.keyframes = keyframes.rightBellyToStand()
            elif posture in standing:
                pass
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     self.keyframes = rightBackToStand()  # CHANGE DIFFERENT KEYFRAMES
コード例 #21
0
    def recognize_posture(self, perception):
        posture = 'unknown'
        # YOUR CODE HERE

        # YOUR CODE HERE
        # get angles of: ['AngleX', 'AngleY', 'LHipYawPitch', 'LHipRoll', 'LHipPitch', 'LKneePitch', 'RHipYawPitch', 'RHipRoll', 'RHipPitch', 'RKneePitch']
        angles = []
        angles.append(perception.imu[0])
        angles.append(perception.imu[1])
        angles.append(perception.joint['LHipYawPitch'])
        angles.append(perception.joint['LHipRoll'])
        angles.append(perception.joint['LHipPitch'])
        angles.append(perception.joint['LKneePitch'])
        angles.append(perception.joint['RHipYawPitch'])
        angles.append(perception.joint['RHipRoll'])
        angles.append(perception.joint['RHipPitch'])
        angles.append(perception.joint['RKneePitch'])

        angles = np.array(angles).reshape(1, -1)

        posture = self.posture_classifier.predict(angles)[0]
        print self.classes[posture]

        return posture


if __name__ == '__main__':
    agent = PostureRecognitionAgent()
    agent.keyframes = rightBackToStand()  # CHANGE DIFFERENT KEYFRAMES
    agent.run()
    def recognize_posture(self, perception):
        posture = 'unknown'
        # YOUR CODE HERE

        # YOUR CODE HERE
        # get angles of: ['AngleX', 'AngleY', 'LHipYawPitch', 'LHipRoll', 'LHipPitch', 'LKneePitch', 'RHipYawPitch', 'RHipRoll', 'RHipPitch', 'RKneePitch']
        angles = []
        angles.append(perception.imu[0])
        angles.append(perception.imu[1])
        angles.append(perception.joint['LHipYawPitch'])
        angles.append(perception.joint['LHipRoll'])
        angles.append(perception.joint['LHipPitch'])
        angles.append(perception.joint['LKneePitch'])
        angles.append(perception.joint['RHipYawPitch'])
        angles.append(perception.joint['RHipRoll'])
        angles.append(perception.joint['RHipPitch'])
        angles.append(perception.joint['RKneePitch'])
        
        angles = np.array(angles).reshape(1, -1)
        
        posture = self.posture_classifier.predict(angles)[0]
        print self.classes[posture]

        return posture

if __name__ == '__main__':
    agent = PostureRecognitionAgent()
    agent.keyframes = rightBackToStand()  # CHANGE DIFFERENT KEYFRAMES
    agent.run()
コード例 #23
0
 def standing_up(self):
     posture = self.posture
     if posture == 'Left' or posture == 'Belly' or posture == "Crouch" or posture == "Knee":
         self.keyframes = leftBellyToStand()
     if posture == 'Right' or posture == 'Back' or posture == "Frog" or posture == "Sit":
         self.keyframes = rightBackToStand()
コード例 #24
0
        return super(PostureRecognitionAgent, self).think(perception)

    def recognize_posture(self, perception):
        posture = 'unknown'
        dataSet = []
        ROBOT_POSE_DATA_DIR = 'robot_pose_data'
        classes = listdir(ROBOT_POSE_DATA_DIR)
        moveements = [
            'LHipYawPitch', 'LHipRoll', 'LHipPitch', 'LKneePitch',
            'RHipYawPitch', 'RHipRoll', 'RHipPitch', 'RKneePitch'
        ]
        clf = pickle.load(open(self.posture_classifier, 'rb'))

        for i in moveements:
            dataSet.append(perception.joint[i])

        dataSet.append(perception.imu[0])
        dataSet.append(perception.imu[1])

        allDataset = [dataSet]
        pred = clf.predict(allDataset)
        posture = classes[pred[0]]
        print(posture)
        return posture


if __name__ == '__main__':
    agent = PostureRecognitionAgent()
    agent.keyframes = rightBackToStand()
    agent.run()
コード例 #25
0
        self.posture = self.recognize_posture(perception)
        return super(PostureRecognitionAgent, self).think(perception)

    def recognize_posture(self, perception):
        posture = 'unknown'
        # YOUR CODE HERE

        data = [
            perception.joint['LHipYawPitch'], perception.joint['LHipRoll'],
            perception.joint['LHipPitch'], perception.joint['LKneePitch'],
            perception.joint['RHipYawPitch'], perception.joint['RHipRoll'],
            perception.joint['RHipPitch'], perception.joint['RKneePitch'],
            perception.imu[0], perception.imu[1]
        ]

        data = np.array(data).reshape(1, -1)

        index = self.posture_classifier.predict(data)
        posture = self.posture_classes[index[0]]

        if posture != self.posture:
            print('posture changed to: ' + posture)

        return posture


if __name__ == '__main__':
    agent = PostureRecognitionAgent()
    agent.start_animation(rightBackToStand())  # CHANGE DIFFERENT KEYFRAMES
    agent.run()
        self.posture = 'unknown'
        # get the classifier created by learn_posture
        self.posture_classifier = pickle.load(open('robot_pose.pkl'))
        # get list of poses
        self.classes = listdir('robot_pose_data')

    def think(self, perception):
        self.posture = self.recognize_posture(perception)
        return super(PostureRecognitionAgent, self).think(perception)

    def recognize_posture(self, perception):
        posture = 'unknown'
        # store the current data from the perception class in a list
        data = []
        data.extend(perception.imu)
        # as shown in learn_posture get the current angle of all relative
        # joints and store in teh list 
        joints = ['LHipYawPitch', 'LHipRoll', 'LHipPitch', 'LKneePitch', 'RHipYawPitch', 'RHipRoll', 'RHipPitch', 'RKneePitch']
        
        for j in joints:
            data.append(perception.joint[j])
        # get the predicted Posture from the classifier and return it
        posture = self.classes[self.posture_classifier.predict(data)]
        print posture
        return posture

if __name__ == '__main__':
    agent = PostureRecognitionAgent()
    agent.keyframes = keyframes.rightBackToStand()
    agent.run()
 def standing_up(self):
     posture = self.posture
     # YOUR CODE HERE
     self.keyframes = rightBackToStand()  # CHANGE DIFFERENT KEYFRAMES