Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remade branch for commits for ObjectInWorld label parameter implemented #208

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions modules/cluster_estimation/cluster_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,15 @@ def run(
# Create output list of remaining valid clusters
detections_in_world = []
for cluster in model_output:
result, landing_pad = object_in_world.ObjectInWorld.create(
result, temp_object = object_in_world.ObjectInWorld.create(
Copy link
Collaborator

Choose a reason for hiding this comment

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

cluster_object

cluster[0][0],
cluster[0][1],
cluster[2],
0,
)

if result:
detections_in_world.append(landing_pad)
detections_in_world.append(temp_object)

return True, detections_in_world

Expand Down
9 changes: 7 additions & 2 deletions modules/object_in_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,27 @@ class ObjectInWorld:

@classmethod
def create(
cls, location_x: float, location_y: float, spherical_variance: float
cls, location_x: float, location_y: float, spherical_variance: float, label: int
) -> "tuple[bool, ObjectInWorld | None]":
"""
location_x, location_y: Location of the object.
spherical_variance: Uncertainty of the location.
label: Type of object in real world.
"""
if spherical_variance < 0.0:
return False, None

return True, ObjectInWorld(cls.__create_key, location_x, location_y, spherical_variance)
return True, ObjectInWorld(
cls.__create_key, location_x, location_y, spherical_variance, label
)

def __init__(
self,
class_private_create_key: object,
location_x: float,
location_y: float,
spherical_variance: float,
label: int,
) -> None:
"""
Private constructor, use create() method.
Expand All @@ -38,3 +42,4 @@ def __init__(
self.location_x = location_x
self.location_y = location_y
self.spherical_variance = spherical_variance
self.label = label
14 changes: 9 additions & 5 deletions tests/unit/test_decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def best_pad_within_tolerance() -> object_in_world.ObjectInWorld: # type: ignor
location_x = BEST_PAD_LOCATION_X
location_y = BEST_PAD_LOCATION_Y
spherical_variance = 1.0
result, pad = object_in_world.ObjectInWorld.create(location_x, location_y, spherical_variance)
result, pad = object_in_world.ObjectInWorld.create(
location_x, location_y, spherical_variance, 0
)
assert result
assert pad is not None

Expand All @@ -56,7 +58,9 @@ def best_pad_outside_tolerance() -> object_in_world.ObjectInWorld: # type: igno
location_x = 100.0
location_y = 200.0
spherical_variance = 5.0 # variance outside tolerance
result, pad = object_in_world.ObjectInWorld.create(location_x, location_y, spherical_variance)
result, pad = object_in_world.ObjectInWorld.create(
location_x, location_y, spherical_variance, 0
)
assert result
assert pad is not None

Expand All @@ -68,15 +72,15 @@ def pads() -> "list[object_in_world.ObjectInWorld]": # type: ignore
"""
Create a list of ObjectInWorld instances for the landing pads.
"""
result, pad_1 = object_in_world.ObjectInWorld.create(30.0, 40.0, 2.0)
result, pad_1 = object_in_world.ObjectInWorld.create(30.0, 40.0, 2.0, 0)
assert result
assert pad_1 is not None

result, pad_2 = object_in_world.ObjectInWorld.create(50.0, 60.0, 3.0)
result, pad_2 = object_in_world.ObjectInWorld.create(50.0, 60.0, 3.0, 0)
assert result
assert pad_2 is not None

result, pad_3 = object_in_world.ObjectInWorld.create(70.0, 80.0, 4.0)
result, pad_3 = object_in_world.ObjectInWorld.create(70.0, 80.0, 4.0, 0)
assert result
assert pad_3 is not None

Expand Down
72 changes: 36 additions & 36 deletions tests/unit/test_landing_pad_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ def detections_1() -> "list[object_in_world.ObjectInWorld]": # type: ignore
"""
Sample instances of ObjectInWorld for testing.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 8)
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 8, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(2, 2, 4)
result, obj_2 = object_in_world.ObjectInWorld.create(2, 2, 4, 0)
assert result
assert obj_2 is not None

result, obj_3 = object_in_world.ObjectInWorld.create(-2, -2, 2)
result, obj_3 = object_in_world.ObjectInWorld.create(-2, -2, 2, 0)
assert result
assert obj_3 is not None

result, obj_4 = object_in_world.ObjectInWorld.create(3, 3, 10)
result, obj_4 = object_in_world.ObjectInWorld.create(3, 3, 10, 0)
assert result
assert obj_4 is not None

result, obj_5 = object_in_world.ObjectInWorld.create(-3, -3, 6)
result, obj_5 = object_in_world.ObjectInWorld.create(-3, -3, 6, 0)
assert result
assert obj_5 is not None

Expand All @@ -59,23 +59,23 @@ def detections_2() -> "list[object_in_world.ObjectInWorld]": # type: ignore
"""
Sample instances of ObjectInWorld for testing.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0.5, 0.5, 1)
result, obj_1 = object_in_world.ObjectInWorld.create(0.5, 0.5, 1, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(1.5, 1.5, 3)
result, obj_2 = object_in_world.ObjectInWorld.create(1.5, 1.5, 3, 0)
assert result
assert obj_2 is not None

result, obj_3 = object_in_world.ObjectInWorld.create(4, 4, 7)
result, obj_3 = object_in_world.ObjectInWorld.create(4, 4, 7, 0)
assert result
assert obj_3 is not None

result, obj_4 = object_in_world.ObjectInWorld.create(-4, -4, 5)
result, obj_4 = object_in_world.ObjectInWorld.create(-4, -4, 5, 0)
assert result
assert obj_4 is not None

result, obj_5 = object_in_world.ObjectInWorld.create(5, 5, 9)
result, obj_5 = object_in_world.ObjectInWorld.create(5, 5, 9, 0)
assert result
assert obj_5 is not None

Expand All @@ -88,23 +88,23 @@ def detections_3() -> "list[object_in_world.ObjectInWorld]": # type: ignore
"""
Sample instances of ObjectInWorld for testing.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 8)
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 8, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(0.5, 0.5, 4)
result, obj_2 = object_in_world.ObjectInWorld.create(0.5, 0.5, 4, 0)
assert result
assert obj_2 is not None

result, obj_3 = object_in_world.ObjectInWorld.create(-2, -2, 2)
result, obj_3 = object_in_world.ObjectInWorld.create(-2, -2, 2, 0)
assert result
assert obj_3 is not None

result, obj_4 = object_in_world.ObjectInWorld.create(3, 3, 10)
result, obj_4 = object_in_world.ObjectInWorld.create(3, 3, 10, 0)
assert result
assert obj_4 is not None

result, obj_5 = object_in_world.ObjectInWorld.create(-3, -3, 6)
result, obj_5 = object_in_world.ObjectInWorld.create(-3, -3, 6, 0)
assert result
assert obj_5 is not None

Expand All @@ -123,11 +123,11 @@ def test_is_similar_positive_equal_to_threshold(self) -> None:
Test case where the second landing pad has positive coordinates and the distance between
them is equal to the distance threshold.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0)
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(1, 1, 0)
result, obj_2 = object_in_world.ObjectInWorld.create(1, 1, 0, 0)
assert result
assert obj_2 is not None

Expand All @@ -145,11 +145,11 @@ def test_is_similar_negative_equal_to_threshold(self) -> None:
Test case where the second landing pad has negative coordinates and the distance between
them is equal to the distance threshold.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0)
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(-1, -1, 0)
result, obj_2 = object_in_world.ObjectInWorld.create(-1, -1, 0, 0)
assert result
assert obj_2 is not None

Expand All @@ -168,11 +168,11 @@ def test_is_similar_positive_less_than_threshold(self) -> None:
Test case where the second landing pad has positive coordinates and the distance between
them is less than the distance threshold.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0)
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(0.5, 0.5, 0)
result, obj_2 = object_in_world.ObjectInWorld.create(0.5, 0.5, 0, 0)
assert result
assert obj_2 is not None

Expand All @@ -191,11 +191,11 @@ def test_is_similar_negative_less_than_threshold(self) -> None:
Test case where the second landing pad has negative coordinates and the distance between
them is less than the distance threshold.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0)
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(-0.5, -0.5, 0)
result, obj_2 = object_in_world.ObjectInWorld.create(-0.5, -0.5, 0, 0)
assert result
assert obj_2 is not None

Expand All @@ -214,11 +214,11 @@ def test_is_similar_positive_more_than_threshold(self) -> None:
Test case where the second landing pad has positive coordinates and the distance between
them is more than the distance threshold.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0)
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(2, 2, 0)
result, obj_2 = object_in_world.ObjectInWorld.create(2, 2, 0, 0)
assert result
assert obj_2 is not None

Expand All @@ -237,11 +237,11 @@ def test_is_similar_negative_more_than_threshold(self) -> None:
Test case where the second landing pad has negative coordinates and the distance between
them is more than the distance threshold.
"""
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0)
result, obj_1 = object_in_world.ObjectInWorld.create(0, 0, 0, 0)
assert result
assert obj_1 is not None

result, obj_2 = object_in_world.ObjectInWorld.create(-2, -2, 0)
result, obj_2 = object_in_world.ObjectInWorld.create(-2, -2, 0, 0)
assert result
assert obj_2 is not None

Expand Down Expand Up @@ -269,7 +269,7 @@ def test_mark_false_positive_no_similar(
"""
Test if marking false positive adds detection to list of false positives.
"""
_, false_positive = object_in_world.ObjectInWorld.create(20, 20, 20)
_, false_positive = object_in_world.ObjectInWorld.create(20, 20, 20, 0)
assert false_positive is not None

tracker._LandingPadTracking__unconfirmed_positives = detections_1 # type: ignore
Expand All @@ -296,7 +296,7 @@ def test_mark_false_positive_with_similar(
Test if marking false positive adds detection to list of false positives and removes.
similar landing pads
"""
_, false_positive = object_in_world.ObjectInWorld.create(1, 1, 1)
_, false_positive = object_in_world.ObjectInWorld.create(1, 1, 1, 0)
assert false_positive is not None

tracker._LandingPadTracking__unconfirmed_positives = detections_2 # type: ignore
Expand All @@ -316,10 +316,10 @@ def test_mark_multiple_false_positive(
"""
Test if marking false positive adds detection to list of false positives.
"""
_, false_positive_1 = object_in_world.ObjectInWorld.create(0, 0, 1)
_, false_positive_1 = object_in_world.ObjectInWorld.create(0, 0, 1, 0)
assert false_positive_1 is not None

_, false_positive_2 = object_in_world.ObjectInWorld.create(2, 2, 1)
_, false_positive_2 = object_in_world.ObjectInWorld.create(2, 2, 1, 0)
assert false_positive_2 is not None

tracker._LandingPadTracking__unconfirmed_positives = detections_1 # type: ignore
Expand All @@ -344,7 +344,7 @@ def test_mark_confirmed_positive(
"""
Test if marking confirmed positive adds detection to list of confirmed positives.
"""
_, confirmed_positive = object_in_world.ObjectInWorld.create(1, 1, 1)
_, confirmed_positive = object_in_world.ObjectInWorld.create(1, 1, 1, 0)
assert confirmed_positive is not None

expected = [confirmed_positive]
Expand All @@ -359,10 +359,10 @@ def test_mark_multiple_confirmed_positives(
"""
Test if marking confirmed positive adds detection to list of confirmed positives.
"""
_, confirmed_positive_1 = object_in_world.ObjectInWorld.create(1, 1, 1)
_, confirmed_positive_1 = object_in_world.ObjectInWorld.create(1, 1, 1, 0)
assert confirmed_positive_1 is not None

_, confirmed_positive_2 = object_in_world.ObjectInWorld.create(2, 2, 1)
_, confirmed_positive_2 = object_in_world.ObjectInWorld.create(2, 2, 1, 0)
assert confirmed_positive_2 is not None

expected = [confirmed_positive_1, confirmed_positive_2]
Expand Down Expand Up @@ -469,7 +469,7 @@ def test_run_with_confirmed_positive(
"""
Test run when there is a confirmed positive.
"""
_, confirmed_positive = object_in_world.ObjectInWorld.create(1, 1, 1)
_, confirmed_positive = object_in_world.ObjectInWorld.create(1, 1, 1, 0)
assert confirmed_positive is not None

tracker._LandingPadTracking__confirmed_positives.append(confirmed_positive) # type: ignore
Expand All @@ -488,7 +488,7 @@ def test_run_with_false_positive(
"""
Test to see if run function doesn't add landing pads that are similar to false positives.
"""
_, false_positive = object_in_world.ObjectInWorld.create(1, 1, 1)
_, false_positive = object_in_world.ObjectInWorld.create(1, 1, 1, 0)
assert false_positive is not None

tracker._LandingPadTracking__false_positives.append(false_positive) # type: ignore
Expand Down