def update_speed(self): if self.distance_to_ball> pi*3: self.current_forward_speed = self.forward_speed elif self.distance_to_ball< pi and self.distance_to_ball>0: self.current_forward_speed = self.backward_speed else: self.current_forward_speed = 0 #Updates the circling direction if it finds that it's looking to the right of the right post #or if it looks to the left of the left post if self.has_new_goal_observation: if self.goal_type==1 and self.goal_angle<0 and\ self.current_circling_speed==-self.circling_speed: self.current_circling_speed=self.circling_speed self.changed_speed=True self.start_time=self.current_time+2 elif self.goal_type==2 and self.goal_angle>0 and\ self.current_circling_speed==self.circling_speed: self.current_circling_speed=-self.circling_speed self.changed_speed=True self.start_time=self.current_time+2 #Sets the new walk instructions walk.set_velocity(self.current_forward_speed, self.current_circling_speed, ball_angle()[0])
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 update_speed(self): self.distance_to_ball=distance_to_ball() if self.distance_to_ball> pi*3: self.forward_velocity = self.const_forward_velocity; elif self.distance_to_ball< pi and self.distance_to_ball>0: self.forward_velocity = -self.const_forward_velocity else: self.forward_velocity = 0 walk.set_velocity(self.forward_velocity, self.circling_velocity, ball_angle()[0])
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")
def entry(self): #Gets the last vision of the ball self.last_ball_angles=ball_angle()[0]
def update_head_position(self): angles=ball_angle() robotbody.set_head_position(angles[0],angles[1])