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

redo of integrating cluster estimation worker into main #209

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c517762
implemented string field for ObjectInWorld class to specify which typ…
Cyuber Sep 26, 2024
3aad8c7
fixed mistakenly changed annotation in ClusterElimination.run
Cyuber Sep 26, 2024
2dfe21b
fixed linters
Cyuber Sep 27, 2024
b9043b0
fixed black --check issues
Cyuber Sep 27, 2024
2577104
fixed pylint issues
Cyuber Sep 27, 2024
209d372
fixed linters in test_landing_pad_tracking.py
Cyuber Sep 27, 2024
c40ddbd
fixed linter issues in test_decision.py
Cyuber Sep 27, 2024
99140d9
fixed black --check issue with test_decision.py
Cyuber Sep 27, 2024
4b1424d
fixed test_cluster_detection failed test case
Cyuber Sep 27, 2024
676bcd1
changed object_type: string to label: int, also made it keyword param…
Cyuber Sep 30, 2024
647f73a
went back to old version of main
Cyuber Sep 30, 2024
360a6ce
initial commit for branch, work in progress
Cyuber Oct 2, 2024
eff5831
implemented string field for ObjectInWorld class to specify which typ…
Cyuber Sep 26, 2024
451e0e5
fixed mistakenly changed annotation in ClusterElimination.run
Cyuber Sep 26, 2024
c4f3cb9
fixed linters
Cyuber Sep 27, 2024
bc2c6f6
fixed black --check issues
Cyuber Sep 27, 2024
cf55400
fixed pylint issues
Cyuber Sep 27, 2024
7dd1e9f
fixed linters in test_landing_pad_tracking.py
Cyuber Sep 27, 2024
a5da749
fixed linter issues in test_decision.py
Cyuber Sep 27, 2024
96618fb
fixed black --check issue with test_decision.py
Cyuber Sep 27, 2024
b3f068d
fixed test_cluster_detection failed test case
Cyuber Sep 27, 2024
0916b10
changed object_type: string to label: int, also made it keyword param…
Cyuber Sep 30, 2024
652e1da
initial commit for branch, work in progress
Cyuber Oct 2, 2024
7476ddb
used black --preview to reformat the code
Cyuber Oct 4, 2024
adddd92
Merge branch 'integrating-cluster-estimation-worker' of https://githu…
Cyuber Oct 4, 2024
bc65465
ran black . to reformat
Cyuber Oct 4, 2024
4b6abb6
changed label annotation
Cyuber Oct 4, 2024
808c4a2
syntax error
Cyuber Oct 4, 2024
a58c56a
added values back for label
Cyuber Oct 4, 2024
c74a1f4
fixed errors that formatter made
Cyuber Oct 4, 2024
4f0968a
reformated test_decisions.py
Cyuber Oct 4, 2024
4df05c8
redo of integrating cluster estimation worker into main
Aleksa-M Oct 9, 2024
9ec46f2
implemented changes from review
Cyuber Oct 11, 2024
fb28972
fixed formatting issue
Aleksa-M Oct 31, 2024
62e5b7a
implemented reviewed changes
Aleksa-M Nov 1, 2024
d6183f0
fixed review changes
Aleksa-M Nov 2, 2024
617ae90
redo of integrating cluster estimation worker into main
Aleksa-M Oct 9, 2024
05fdf63
redo of integrating cluster estimation worker into main
Aleksa-M Oct 9, 2024
d86f7ce
implemented changes from review
Cyuber Oct 11, 2024
a203f42
fixed formatting issue
Aleksa-M Oct 31, 2024
4e0602f
implemented reviewed changes
Aleksa-M Nov 1, 2024
c84fe86
fixed review changes
Aleksa-M Nov 2, 2024
f0aaaa9
rebased
Aleksa-M Nov 7, 2024
db684fa
Merge branch 'cluster-estimation-worker-integration-redo' of https://…
Aleksa-M Nov 7, 2024
3f799e0
Merge branch 'cluster-estimation-worker-integration-redo' of https://…
Aleksa-M Nov 7, 2024
5001a51
Merge branch 'cluster-estimation-worker-integration-redo' of https://…
Aleksa-M Nov 10, 2024
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: 5 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ geolocation:
camera_orientation_yaw: 0.0
camera_orientation_pitch: -1.57079632679
camera_orientation_roll: 0.0

cluster_estimation:
min_activation_threshold: 25
min_new_points_to_run: 5
random_state: 0
71 changes: 50 additions & 21 deletions main_2024.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from modules.data_merge import data_merge_worker
from modules.geolocation import geolocation_worker
from modules.geolocation import camera_properties
from modules.cluster_estimation import cluster_estimation_worker
from modules.common.logger.modules import logger
from modules.common.logger.modules import logger_setup_main
from modules.common.logger.read_yaml.modules import read_yaml
Expand Down Expand Up @@ -85,8 +86,8 @@ def main() -> int:
VIDEO_INPUT_SAVE_PREFIX = str(pathlib.Path(logging_path, VIDEO_INPUT_SAVE_NAME_PREFIX))

DETECT_TARGET_WORKER_COUNT = config["detect_target"]["worker_count"]
detect_target_option_int = config["detect_target"]["option"]
DETECT_TARGET_OPTION = detect_target_factory.DetectTargetOption(detect_target_option_int)
DETECT_TARGET_OPTION_INT = config["detect_target"]["option"]
DETECT_TARGET_OPTION = detect_target_factory.DetectTargetOption(DETECT_TARGET_OPTION_INT)
DETECT_TARGET_DEVICE = "cpu" if args.cpu else config["detect_target"]["device"]
DETECT_TARGET_MODEL_PATH = config["detect_target"]["model_path"]
DETECT_TARGET_OVERRIDE_FULL_PRECISION = args.full
Expand All @@ -111,6 +112,10 @@ def main() -> int:
GEOLOCATION_CAMERA_ORIENTATION_YAW = config["geolocation"]["camera_orientation_yaw"]
GEOLOCATION_CAMERA_ORIENTATION_PITCH = config["geolocation"]["camera_orientation_pitch"]
GEOLOCATION_CAMERA_ORIENTATION_ROLL = config["geolocation"]["camera_orientation_roll"]

MIN_ACTIVATION_THRESHOLD = config["cluster_estimation"]["min_activation_threshold"]
MIN_NEW_POINTS_TO_RUN = config["cluster_estimation"]["min_new_points_to_run"]
RANDOM_STATE = config["cluster_estimation"]["random_state"]
# pylint: enable=invalid-name
except KeyError as exception:
main_logger.error(f"Config key(s) not found: {exception}", True)
Expand Down Expand Up @@ -139,14 +144,18 @@ def main() -> int:
mp_manager,
QUEUE_MAX_SIZE,
)
geolocation_to_main_queue = queue_proxy_wrapper.QueueProxyWrapper(
geolocation_to_cluster_estimation_queue = queue_proxy_wrapper.QueueProxyWrapper(
mp_manager,
QUEUE_MAX_SIZE,
)
flight_interface_decision_queue = queue_proxy_wrapper.QueueProxyWrapper(
mp_manager,
QUEUE_MAX_SIZE,
)
cluster_estimation_to_main_queue = queue_proxy_wrapper.QueueProxyWrapper(
mp_manager,
QUEUE_MAX_SIZE,
)

result, camera_intrinsics = camera_properties.CameraIntrinsics.create(
GEOLOCATION_RESOLUTION_X,
Expand Down Expand Up @@ -266,7 +275,7 @@ def main() -> int:
camera_extrinsics,
),
input_queues=[data_merge_to_geolocation_queue],
output_queues=[geolocation_to_main_queue],
output_queues=[geolocation_to_cluster_estimation_queue],
controller=controller,
local_logger=main_logger,
)
Expand All @@ -277,6 +286,22 @@ def main() -> int:
# Get Pylance to stop complaining
assert geolocation_worker_properties is not None

result, cluster_estimation_worker_properties = worker_manager.WorkerProperties.create(
count=1,
target=cluster_estimation_worker.cluster_estimation_worker,
work_arguments=(MIN_ACTIVATION_THRESHOLD, MIN_NEW_POINTS_TO_RUN, RANDOM_STATE),
input_queues=[geolocation_to_cluster_estimation_queue],
output_queues=[cluster_estimation_to_main_queue],
controller=controller,
local_logger=main_logger,
)
if not result:
main_logger.error("Failed to create arguments for Cluster Estimation", True)
return -1

# Get Pylance to stop complaining
assert cluster_estimation_worker_properties is not None

# Create managers
worker_managers = []

Expand Down Expand Up @@ -345,6 +370,19 @@ def main() -> int:

worker_managers.append(geolocation_manager)

result, cluster_estimation_manager = worker_manager.WorkerManager.create(
worker_properties=cluster_estimation_worker_properties,
local_logger=main_logger,
)
if not result:
main_logger.error("Failed to create manager for Cluster Estimation", True)
return -1

# Get Pylance to stop complaining
assert cluster_estimation_manager is not None

worker_managers.append(cluster_estimation_manager)

# Run
for manager in worker_managers:
manager.start_workers()
Expand All @@ -357,24 +395,14 @@ def main() -> int:
return -1

try:
geolocation_data = geolocation_to_main_queue.queue.get_nowait()
cluster_estimation_data = cluster_estimation_to_main_queue.queue.get_nowait()
except queue.Empty:
geolocation_data = None

if geolocation_data is not None:
for detection_world in geolocation_data:
main_logger.debug("Detection in world:", True)
main_logger.debug(
"geolocation vertices: " + str(detection_world.vertices.tolist()), True
)
main_logger.debug(
"geolocation centre: " + str(detection_world.centre.tolist()), True
)
main_logger.debug("geolocation label: " + str(detection_world.label), True)
main_logger.debug(
"geolocation confidence: " + str(detection_world.confidence), True
)
cluster_estimation_data = None

if cluster_estimation_data is not None:
for object_in_world in cluster_estimation_data:
main_logger.debug("Cluster in world: ", True)
main_logger.debug(str(object_in_world))
if cv2.waitKey(1) == ord("q"): # type: ignore
main_logger.info("Exiting main loop", True)
break
Expand All @@ -386,8 +414,9 @@ def main() -> int:
detect_target_to_data_merge_queue.fill_and_drain_queue()
flight_interface_to_data_merge_queue.fill_and_drain_queue()
data_merge_to_geolocation_queue.fill_and_drain_queue()
geolocation_to_main_queue.fill_and_drain_queue()
geolocation_to_cluster_estimation_queue.fill_and_drain_queue()
flight_interface_decision_queue.fill_and_drain_queue()
cluster_estimation_to_main_queue.fill_and_drain_queue()

for manager in worker_managers:
manager.join_workers()
Expand Down
6 changes: 6 additions & 0 deletions modules/object_in_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ def __init__(
self.location_x = location_x
self.location_y = location_y
self.spherical_variance = spherical_variance

def __str__(self) -> str:
"""
To string.
"""
return f"{self.__class__}, location x: {self.location_x}, location y: {self.location_y}, spherical variance: {self.spherical_variance}, label: {self.label}"