robocin / rSoccer

🎳 Environments for Reinforcement Learning
MIT License
46 stars 19 forks source link

Add frame for yellow robot #15

Closed goncamateus closed 3 years ago

goncamateus commented 3 years ago

Add function to get a frame for the yellow robots into Frame class:

def get_yellow_frame(self):
    yellow_frame = Frame()

    yellow_frame.ball.x = -self.ball.x
    yellow_frame.ball.y = self.ball.y
    yellow_frame.ball.z = self.ball.z
    yellow_frame.ball.v_x = -self.ball.v_x
    yellow_frame.ball.v_y = self.ball.v_y

    for i in range(len(self.robots_yellow)):
        robot = Robot()
        robot.id = i
        robot.x = -self.robots_yellow[i].x
        robot.y = self.robots_yellow[i].y
        robot.theta = self._mirror_angle(self.robots_yellow[i].theta)
        robot.v_x = -self.robots_yellow[i].v_x
        robot.v_y = self.robots_yellow[i].v_y
        robot.v_theta = -self.robots_yellow[i].v_theta
        yellow_frame.robots_blue[robot.id] = robot

    for i in range(len(self.robots_blue)):
        robot = Robot()
        robot.id = i
        robot.x = -self.robots_blue[i].x
        robot.y = self.robots_blue[i].y
        robot.theta = self._mirror_angle(self.robots_blue[i].theta)
        robot.v_x = -self.robots_blue[i].v_x
        robot.v_y = self.robots_blue[i].v_y
        robot.v_theta = -self.robots_blue[i].v_theta
        yellow_frame.robots_yellow[robot.id] = robot

    return yellow_frame