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): posture = self.posture # YOUR CODE HERE if posture == 'Back': self.keyframes = kf.rightBackToStand() elif posture == 'Belly': self.keyframes = kf.leftBellyToStand()
def standing_up(self): posture = self.posture # YOUR CODE HERE if posture == 'Back': self.set_keyframes(leftBackToStand()) elif posture == 'Belly': self.set_keyframes(leftBellyToStand())
def standing_up(self): posture = self.posture # YOUR CODE HERE if posture == 'Back': self.keyframes = leftBackToStand() else: # 'Belly' self.keyframes = leftBellyToStand()
def standing_up(self): posture = self.posture # YOUR CODE HERE if (posture == 'Back'): agent.keyframes = leftBackToStand() elif (posture == 'Belly'): agent.keyframes = leftBellyToStand()
def standing_up(self): posture = self.posture actions = {'Back': leftBackToStand(), 'Belly': leftBellyToStand()} if posture in actions: self.keyframes = actions[posture]
def standing_up(self): posture = self.posture if posture == 'Back': self.keyframes = leftBackToStand() elif posture == 'Belly': self.keyframes = leftBellyToStand()
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 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()
def standing_up(self): posture = self.posture # YOUR CODE HERE # Keyframe based movement is started by pressing k in SimSpark # Unfixed Problem, when the robot falls on its belly it makes a headstand when stiffness is set to 1 # I did not make Keyframes for standing up from that position if (posture == 'Back'): self.keyframes = leftBackToStand() if (posture == 'Belly'): self.keyframes = leftBellyToStand()
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()
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 = leftBellyToStand()
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 #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()
def standing_up(self): posture = self.posture # YOUR CODE HERE ROBOT_POSE_DATA_DIR = 'robot_pose_data' classes = listdir(ROBOT_POSE_DATA_DIR) if posture == 'Back': self.keyframes = leftBackToStand() if posture == 'Belly': self.keyframes = leftBellyToStand() self.keyframes = leftBackToStand()
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 # 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=([],[],[])
def standing_up(self): posture = self.posture # YOUR CODE HERE print posture if self.started: if posture == 'Belly': print 'start belly' self.keyframes = leftBellyToStand() self.set_time() self.started = 0 elif posture == 'Back': print 'start back' self.keyframes = leftBackToStand() self.set_time() self.started = 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 = ([], [], [])
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
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
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()
def standing_up(self): # Robot doesnt recognize when it falls posture = self.posture if( posture == 'Belly'): self.keyframes = keyframes.leftBellyToStand()
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()
self.posture = self.recognize_posture(perception) return super(PostureRecognitionAgent, self).think(perception) def recognize_posture(self, perception): ROBOT_POSE_DATA_DIR = '../joint_control/robot_pose_data' possible_postures = listdir(ROBOT_POSE_DATA_DIR) posture = 'unknown' ''' YOUR CODE HERE the features (e.g. each row of the data) are ['LHipYawPitch', 'LHipRoll', 'LHipPitch', 'LKneePitch', 'RHipYawPitch', 'RHipRoll', 'RHipPitch', 'RKneePitch', 'AngleX', 'AngleY'], where 'AngleX' and 'AngleY' are body angle (e.g. Perception.imu) and others are joint angles.''' features = [ 'LHipYawPitch', 'LHipRoll', 'LHipPitch', 'LKneePitch', 'RHipYawPitch', 'RHipRoll', 'RHipPitch', 'RKneePitch' ] unknown_posture = [] for feature in features: unknown_posture.append(perception.joint.get(feature)) unknown_posture += perception.imu unknown_posture = np.array(unknown_posture) #print unknown_posture posture_index = self.posture_classifier.predict( unknown_posture.reshape(1, -1)) recognized_posture = possible_postures[posture_index[-1]] #print recognized_posture return recognized_posture if __name__ == '__main__': agent = PostureRecognitionAgent() agent.set_keyframes(leftBellyToStand()) # CHANGE DIFFERENT KEYFRAMES agent.run()
def think(self, perception): self.posture = self.recognize_posture(perception) return super(PostureRecognitionAgent, self).think(perception) def recognize_posture(self, perception): posture = 'unknown' # YOUR CODE HERE format = ['LHipYawPitch', 'LHipRoll', 'LHipPitch', 'LKneePitch', 'RHipYawPitch', 'RHipRoll', 'RHipPitch', 'RKneePitch'] postures = ['Right','Sit','Crouch','Frog','Left','Stand','HeadBack','Knee','Back','Belly','StandInit'] clf2 = pickle.load(open(self.posture_classifier)) data = [] for name in format: data.append(perception.joint[name]) data.append(perception.imu[0]) #x data.append(perception.imu[1]) #y dataset = [] dataset.append(data) predicted = clf2.predict(dataset) posture = postures[predicted[0]] return posture if __name__ == '__main__': agent = PostureRecognitionAgent() agent.keyframes = leftBellyToStand() # CHANGE DIFFERENT KEYFRAMES agent.run()
def __init__(self, simspark_ip='localhost', simspark_port=3100, teamname='DAInamite', player_id=0, sync_mode=True): super(TestStandingUpAgent, self).__init__(simspark_ip, simspark_port, teamname, player_id, sync_mode) self.stiffness_on_off_time = 0 self.stiffness_on_cycle = 10 # in seconds self.stiffness_off_cycle = 3 # in seconds self.stop = 1 def think(self, perception): action = super(TestStandingUpAgent, self).think(perception) time_now = perception.time if self.stop: if time_now - self.stiffness_on_off_time < self.stiffness_off_cycle: action.stiffness = {j: 0 for j in self.joint_names} # turn off joints else: action.stiffness = {j: 1 for j in self.joint_names} # turn on joints self.stop = 0 if time_now - self.stiffness_on_off_time > self.stiffness_on_cycle + self.stiffness_off_cycle: self.stiffness_on_off_time = time_now return action if __name__ == '__main__': agent = TestStandingUpAgent() agent.set_keyframes(leftBellyToStand()) agent.run()