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" )
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()
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()
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()
def standing_up(self): posture = self.posture # YOUR CODE HERE if posture == 'Back' or posture =='Left': self.keyframes = leftBackToStand() elif posture == 'Belly' or posture == 'Right': self.keyframes = rightBellyToStand()
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 if posture == 'Belly' and not self.is_animating(): self.start_animation(rightBellyToStand()) if posture == 'Back' and not self.is_animating(): self.start_animation(leftBackToStand())
def standing_up(self): posture = self.posture # YOUR CODE HERE self.posture = self.recognize_posture(self.perception) # print(self.posture) if posture == "Belly": # print("belly to stand") self.keyframes = rightBellyToStand() elif posture == "Back": # print("back to stand") self.keyframes = leftBackToStand()
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()
def standing_up(self): posture = self.posture if posture == "Belly": self.keyframes = leftBellyToStand() if posture == "Left": self.keyframes = leftBackToStand() if posture == "Back": self.keyframes = leftBackToStand() if posture == "Stand": self.keyframes = self.keyframes else: self.keyframes = rightBellyToStand()
def standing_up(self): posture = self.posture # YOUR CODE HERE if posture in ['Stand', 'StandInit', 'Sit']: return if posture == 'Back': self.keyframes = kf.leftBellyToStand() elif posture == 'Belly': self.keyframes = kf.rightBellyToStand() print(posture) pass
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
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
def standing_up(self, perception): posture = self.posture if posture == "Back": new_keyframes = leftBackToStand() elif posture == "Belly": new_keyframes = leftBellyToStand() elif posture == "Left": new_keyframes = leftBellyToStand() elif posture == "Right": new_keyframes = rightBellyToStand() else: #do nothing return if new_keyframes != self.keyframes: self.init_time = perception.time self.keyframes = new_keyframes
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()"
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 think(self, perception): self.posture = self.recognize_posture(perception) return super(PostureRecognitionAgent, self).think(perception) def recognize_posture(self, perception): posture = 'unknown' measurement = np.zeros((10,)) measurement[8] = perception.imu[0] measurement[9] = perception.imu[1] #insert values for AngleX and AngleY for i,j in enumerate(measurement[:8]): measurement[i] = perception.joint[self.joint_data[i]] posture = self.classes[int(self.posture_classifier.predict(measurement)[0])] #predict posture with classifier print posture return posture if __name__ == '__main__': agent = PostureRecognitionAgent() agent.keyframes = rightBellyToStand() # CHANGE DIFFERENT KEYFRAMES agent.run()
if j == len(times[i]) - 1: if names[i] in perception.joint: target_joints[names[i]] = self.perception.joint[ names[i]] else: break return target_joints def interpolate(self, time_fracture, index_i, index_j, keys): x_0 = keys[index_i][index_j][0] x_1 = keys[index_i][index_j][1][2] + x_0 x_2 = keys[index_i][0][0] x_3 = keys[index_i][index_j][2][2] + x_2 y_0 = (1 - time_fracture)**3 y_1 = 3 * (1 - time_fracture)**2 y_2 = 3 * (1 - time_fracture) bezier = (y_0 * x_0) + (y_1 * x_1 * time_fracture) + ( y_2 * x_3 * (time_fracture**2)) + (x_2 * (time_fracture**3)) return bezier if __name__ == '__main__': agent = AngleInterpolationAgent() agent.keyframes = rightBellyToStand() # CHANGE DIFFERENT KEYFRAMES agent.run()
dt = (current_time - t_0) / (t_3 - t_0) # Angles p0 = keys[j][t][0] p3 = keys[j][t + 1][0] # Control angles p1 = p0 + keys[j][t][1][2] p2 = p3 + keys[j][t][1][2] return self.cubic_bezier_interpolation(p0, p1, p2, p3, dt) @staticmethod def cubic_bezier_interpolation(p0, p1, p2, p3, i): t0 = (1 - i)**3 t1 = 3 * i * (1 - i)**2 t2 = 3 * (1 - i) * i**2 t3 = i**3 return t0 * p0 + t1 * p1 + t2 * p2 + t3 * p3 if __name__ == '__main__': agent = AngleInterpolationAgent() agent.keyframes = hello() # CHANGE DIFFERENT KEYFRAMES # By the Belly keyframes NAO not falls on the Belly ... if agent.keyframes == leftBellyToStand( ) or agent.keyframes == rightBellyToStand(): agent.keyframes[2][0] = agent.keyframes[2][1] agent.run()