def move_or_kick(self):
     #Gets the angles for to the ball
     self.ball_angle=ball_angle()[0]
     
     #If they are close to the middle it will move sideways
     if like(self.ball_angle,0):
         walk.set_velocity(0, 0.4, 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()
         if self.ball_angle>0:
             kick.forward_left()
         else:
             kick.forward_right()
 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()
Example #3
0
    def update(self):
        if has_fallen():
            return "fallen"
        
        if not self.start_time:
            if like(self.wanted_head_position,robotbody.get_head_position()):
                self.ball_angle=ball_angle()[0]

                if like(self.ball_angle,0):
                    walk.set_velocity(0, 0.4, 0)
                else:
                    walk.set_velocity(0, 0, 0)
                    set_head_position([0,0])
                    self.start_time = time.time()
                    if self.ball_angle>0:
                        kick.forward_left()
                    else:
                        kick.forward_right()
        
        if self.start_time and time.time()>self.time+self.start_time:
            return "done"