def _put_in_world_referential(orientation: float, cmd: Pose) -> Pose: if config['GAME']['on_negative_side']: cmd.position = rotate(cmd.position, -np.pi - orientation) cmd.x *= -1 cmd.orientation *= -1 else: cmd.position = rotate(cmd.position, orientation) return cmd
def _put_in_robots_referential(robot: Robot, cmd: Pose) -> Pose: if config['GAME']['on_negative_side']: cmd.x *= -1 cmd.orientation *= -1 cmd.position = rotate(cmd.position, np.pi + robot.orientation) else: cmd.position = rotate(cmd.position, -robot.orientation) return cmd
def test_rotate_identity(): assert rotate(A_POS, A_POS_ANGLE) is not A_POS
def test_rotate_by_negative_angle(): assert rotate(A_POS, A_NEG_ANGLE) == A_POS_ROTATED_BY_A_NEG_ANGLE
def test_rotate_return_type(): assert isinstance(rotate(A_POS, A_POS_ANGLE), Position)
def test_rotate_by_positive_angle(): assert rotate(A_POS, A_POS_ANGLE) == A_POS_ROTATED_BY_A_POS_ANGLE