Skip to content
This repository was archived by the owner on Jul 26, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ Run them by running `python setup.py test` (or `pytest`).
## Co-ordinate spaces

sb-vision describes the locations of identified markers in either Cartesian or
spherical co-ordinate spaces. A "legacy polar" co-ordinate space exists for
backwards compatibility but is deprecated, undocumented and will be removed in
May 2018.
spherical co-ordinate spaces.

### Cartesian co-ordinates

Expand Down
3 changes: 1 addition & 2 deletions sb_vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

from .camera import Camera, FileCamera
from .coordinates import Cartesian, LegacyPolar, Spherical, cartesian_to_spherical
from .coordinates import Cartesian, Spherical, cartesian_to_spherical
from .tokens import Token
from .vision import Vision

Expand All @@ -17,7 +17,6 @@
'FileCamera',
'Token',
'Cartesian',
'LegacyPolar',
'Spherical',
'cartesian_to_spherical',
]
21 changes: 0 additions & 21 deletions sb_vision/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import NamedTuple, Union

import numpy as np
from numpy import arctan2, float64, linalg

AnyFloat = Union[float, float64]
Expand Down Expand Up @@ -30,13 +29,6 @@ def tolist(self):
('dist', AnyFloat),
))

LegacyPolar = NamedTuple('LegacyPolar', (
('polar_x', AnyFloat),
('polar_y', AnyFloat),
('dist', AnyFloat),
))


PixelCoordinate = NamedTuple('PixelCoordinate', [('x', AnyFloat), ('y', AnyFloat)])


Expand All @@ -48,16 +40,3 @@ def cartesian_to_spherical(cartesian: Cartesian) -> Spherical:
rot_y=arctan2(x, z),
dist=linalg.norm(cartesian),
)


def cartesian_to_legacy_polar(cartesian: Cartesian) -> LegacyPolar:
"""
Convert cartesian co-ordinate space to the legacy "polar" space.

This is kept for compatibility only.
"""
cart_x, cart_y, cart_z = tuple(cartesian)
polar_dist = np.linalg.norm(cartesian)
polar_x = np.arctan2(cart_z, cart_x)
polar_y = np.arctan2(cart_z, cart_y)
return LegacyPolar(polar_x, polar_y, polar_dist)
9 changes: 1 addition & 8 deletions sb_vision/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

import numpy as np

from .coordinates import (
Cartesian,
cartesian_to_legacy_polar,
cartesian_to_spherical,
)
from .coordinates import Cartesian, cartesian_to_spherical
from .find_3D_coords import (
PixelCoordinate,
calculate_transforms,
Expand Down Expand Up @@ -110,9 +106,6 @@ def update_3D_transforms(
self.cartesian = translation

# Polar co-ordinates in the 3D world, relative to the camera
self.polar = cartesian_to_legacy_polar(self.cartesian)
self.legacy_polar = cartesian_to_legacy_polar(self.cartesian)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should ensure that the robotd changes to remove legacy_polar happen before this change is merged.


self.spherical = cartesian_to_spherical(self.cartesian)

def __repr__(self) -> str:
Expand Down
22 changes: 3 additions & 19 deletions tests/test_coordinates_from_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from pytest import approx

from sb_vision import Cartesian, FileCamera, LegacyPolar, Spherical, Vision
from sb_vision import Cartesian, FileCamera, Spherical, Vision

# Ensure all distance values are within this tolerance
# (as a percentage of the total distance)
Expand All @@ -20,11 +20,6 @@
(
'1.0z-0.1x.jpg',
Cartesian(x=-0.1, y=0, z=1),
LegacyPolar(
polar_x=1.6704649792860642,
polar_y=1.5707963267948966,
dist=1.004987562112089,
),
Spherical(
rot_x=0,
rot_y=math.atan(-0.1), # or -5.710593137499643 degrees
Expand All @@ -34,11 +29,6 @@
(
'3.0z1.0x.jpg',
Cartesian(x=1, y=0, z=3),
LegacyPolar(
polar_x=1.1922,
polar_y=1.6032,
dist=(1 + 9)**0.5, # or 3.1622776601683795
),
Spherical(
rot_x=0,
rot_y=math.atan(1 / 3), # or 18.43494882296774 degrees
Expand All @@ -49,10 +39,10 @@


@pytest.mark.parametrize(
"photo, expected_cartesian, expected_polar, expected_spherical",
"photo, expected_cartesian, expected_spherical",
TEST_IMAGES,
)
def test_image_coordinates(photo, expected_cartesian, expected_polar, expected_spherical):
def test_image_coordinates(photo, expected_cartesian, expected_spherical):
"""Make sure that this particular file gives these particular tokens."""
camera = FileCamera(CALIBRATIONS / photo, camera_model='C016')
vision = Vision(camera)
Expand All @@ -70,12 +60,6 @@ def approx_ang(expected):
assert y == approx_dist(expected_cartesian.y), "Wrong y-coordinate"
assert z == approx_dist(expected_cartesian.z), "Wrong z-coordinate"

polar_x, polar_y, polar_dist = token.legacy_polar

assert polar_x == approx_ang(expected_polar.polar_x), "Wrong polar_x coordinate"
assert polar_y == approx_ang(expected_polar.polar_y), "Wrong polar_y coordinate"
assert polar_dist == approx_dist(expected_polar.dist), "Wrong polar_dist coordinate"

rot_x, rot_y, dist = token.spherical

assert rot_x == approx_ang(expected_spherical.rot_x), "Wrong x-coordinate"
Expand Down