def entry(self):
     
     #Resets the variables since the last use of the state:
     
     #starting angle
     self.start_angle = imu.get_angle()[2]
     
     #Timers
     self.start_time=time.time()
     self.timer=self.start_time+self.time_between
     
     #Which direction it should start turning its head
     self.left_or_right=self.direction
     
     #Makes sure that the head hardness is correct and
     #stores the current head position
     robotbody.set_head_hardness(0.95)
     self.wanted_head_position=robotbody.get_head_position()
     
     #Initiates the turn in the right direction
     if self.direction=="left":
         walk.turn_left(0.2)
     else:
         walk.turn_right(0.2)
         
     #Sets a fancy blue eye colour
     robotbody.set_eyes_led(0, 0, 31)
         
     print("Tracking ball")
Пример #2
0
 def entry(self):
     print("Tracking ball")
     robotbody.set_head_hardness(0.95)
     self.wanted_head_position=robotbody.get_head_position()
     
     self.start_angle = imu.get_angle()[2]
     
     self.start_time=time.time()
     self.timer=self.start_time+self.time_between
     
     self.left_or_right="right"
     
     walk.turn_left(0.2)
     set_head_position(self.wanted_head_position)
Пример #3
0
 def update(self):
     
     self.update_head_position()
     
     if vision.has_new_ball_observation():
         walk.turn_left(0)
         robotbody.set_eyes_led(0, 31, 0)
         print("found ball")
         return "done"
     
     if imu.get_angle()[2] > self.start_angle + self.angle:
         walk.turn_left(0)
         robotbody.set_eyes_led(31,0,0)
         print ("can't find the ball")
         return "out of sight"
 def update(self):
     
     #Tests if it has found a ball observation
     if vision.has_new_ball_observation():
         walk.turn_left(0)
         robotbody.set_eyes_led(0, 31, 0)
         print("found ball")
         return "done"
     
     #Tests if it's time to stop turning and accept a failure
     if imu.get_angle()[2] > self.start_angle + self.angle:
         walk.turn_left(0)
         robotbody.set_eyes_led(31,0,0)
         print ("can't find the ball")
         return "out of sight"
     
     #Updates the head position
     self.update_head_position()
 def exit(self):
     walk.turn_left(0)
     print("Exit gyro turn")
 def entry(self):
     print("Entry gyro turn")
     self.start_angle = imu.get_angle()[2]
     self.number_of_turns += 1
     walk.turn_left(0.4)
Пример #7
0
 def entry(self):
     print("Entry turn")
     self.start_time = time.time()
     self.number_of_turns += 1
     walk.turn_left(0.4)