def update_head_position(self):
     angles=ball_angle()
     
     self.wanted_head_position[0]=angles[0]
     
     self.wanted_head_position[1]=angles[1]
         
     set_head_position(self.wanted_head_position)
 def entry(self):
     #Reset the variables from the last use of the state
     self.time_since_kick=False
     
     #Sets the head to the wanted position and stores the value
     self.wanted_head_position=[0,pi/8]
     set_head_position(self.wanted_head_position)
     
     print ("kicking the ball")
    def entry(self):
        #Sets the eyes to a fancy blue
        robotbody.set_eyes_led(0, 0, 31)

        #Starts walking forward with the given speed
        walk.walk_forward(self.speed)
        
        #Sets the head position down to the ground
        set_head_position([0,pi/8])
        
        #How long it will wait until it has concluded that it has lost the ball
        self.lost_ball_timer=time.time()+2
        
        print("See the robot walk")
 def update_head_position(self):
     if self.up_and_down=="down":
         if self.current_time>=self.timer+self.max_angle_timer:
             self.timer=self.current_time+self.max_angle_timer
             self.up_and_down="up"
         
         else: 
             set_head_position([0,self.head_turning_speed*(self.current_time-self.timer)])
     
     else:
         if self.current_time>=self.timer-self.min_angle_timer:
             self.timer=self.current_time-self.min_angle_timer
             self.up_and_down="down"
         else:    
             set_head_position([0,self.head_turning_speed*(self.timer-self.current_time)])
 def entry(self):
     #Starts the timer from when the ball was last seen
     self.lost_ball_timer=time.time()+5
     
     #Sets the wanted head position, either to the current or
     #to one looking down at the ball
     if self.look_down:
         self.wanted_head_position=[0,pi/8]
     else:
         self.wanted_head_position=robotbody.get_head_position()
     
     #Makes sure that the head hardness is correct and updates the head position
     robotbody.set_head_hardness(0.95)
     set_head_position(self.wanted_head_position)
     
     print("following the ball")
 def update_head_position(self):
     self.current_time=time.time()
     if self.left_or_right=="left":
         if self.current_time>=self.timer+self.max_time_difference:
             self.timer=self.current_time+self.max_time_difference
             self.wanted_head_position[1]=self.highest_head_position
             self.left_or_right="right"
         else:
             self.wanted_head_position[0]=self.current_time-self.timer
     
     else:
         if self.current_time>=self.timer+self.max_time_difference:
             self.timer=self.current_time+self.max_time_difference
             self.wanted_head_position[1]=self.lowest_head_position
             self.left_or_right="left"
         else:
             self.wanted_head_position[0]=-(self.current_time-self.timer)
         
     set_head_position(self.wanted_head_position)
 def move_or_kick(self):
     #Gets the angles for to the ball
     self.ball_angle=ball_angle()[0]
     
     #If the ball is to the right of the left foot
     if self.ball_angle<0.1:
         walk.set_velocity(0, -0.01, 0)
     
     #If the ball is to the left of the left foot 
     elif self.ball_angle>0.47:
         walk.set_velocity(0, 0.01, 0)
         
     #Else it will stop, look up, start the timer since the last kick
     #and kick with the foot that has the ball in front of it.
     else:
         walk.set_velocity(0, 0, 0)
         set_head_position([0,0])
         self.time_since_kick = time.time()
         kick.forward_left()
    def entry(self):
        #Reseting the forward velocity from the last time the state was used
        self.forward_velocity=0
        
        #Updating the head position so that DARwIn will look down at the ball
        self.wanted_head_position=[0,pi/8]
        set_head_position(self.wanted_head_position)
        
        #Starting the sideways walk
        walk.set_velocity(self.forward_velocity, self.circling_velocity, ball_angle()[0])
        
        #Starting the turning timer
        self.start_time = time.time()
        self.time = 10
        
        #starting the lost ball timer
        self.lost_ball_timer=time.time()+4

        
        print ("Turning away from our goal")