Skip to content

Commit

Permalink
Made fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishA26 authored and maxlou05 committed Nov 2, 2024
1 parent caf435d commit 4b65ad5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
20 changes: 6 additions & 14 deletions modules/communications/communications.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from modules.common.logger.modules import logger
from modules.common.mavlink.modules.drone_odometry import DronePosition
from modules.detection_in_world import DetectionInWorld
from modules.flight_interface.local_global_conversion import drone_position_global_from_local
from modules.flight_interface.local_global_conversion import detection_in_world_global_from_local


class Communications:
Expand Down Expand Up @@ -37,22 +37,14 @@ def run(
self, detections_in_world: list[DetectionInWorld], home_location: DronePosition
) -> tuple[bool, list[DetectionInWorld] | None]:
for detection_in_world in detections_in_world:
if len(detection_in_world.centre) == 3:
result, detection_in_world_global = drone_position_global_from_local(
home_location,
detection_in_world.centre[0],
detection_in_world.centre[1],
detection_in_world.centre[2],
)
elif len(detection_in_world.centre) == 2:
result, detection_in_world_global = drone_position_global_from_local(
home_location, detection_in_world.centre[0], detection_in_world.centre[1], 0
)
result, detection_in_world_global = detection_in_world_global_from_local(
home_location, detection_in_world
)

if not result:
self.__logger.error("conversion failed")
return False, detections_in_world

self.__logger.info(time.time() + ": " + str(detection_in_world_global))
self.__logger.info(str(time.time()) + ": " + str(detection_in_world_global))

return True, detections_in_world
2 changes: 1 addition & 1 deletion modules/communications/communications_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import pathlib

from modules.communications import communications
from . import communications
from utilities.workers import queue_proxy_wrapper
from utilities.workers import worker_controller
from ..common.logger.modules import logger
Expand Down
2 changes: 1 addition & 1 deletion modules/flight_interface/flight_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run(self) -> "tuple[bool, odometry_and_time.OdometryAndTime | None, drone_od
"""
result, odometry = self.controller.get_odometry()
if not result:
return False, None
return False, None, None

# Get Pylance to stop complaining
assert odometry is not None
Expand Down
4 changes: 2 additions & 2 deletions modules/flight_interface/flight_interface_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def flight_interface_worker(
period: float,
input_queue: queue_proxy_wrapper.QueueProxyWrapper,
output_queue: queue_proxy_wrapper.QueueProxyWrapper,
communications_ouutput_queue: queue_proxy_wrapper.QueueProxyWrapper,
communications_output_queue: queue_proxy_wrapper.QueueProxyWrapper,
controller: worker_controller.WorkerController,
) -> None:
"""
Expand Down Expand Up @@ -66,7 +66,7 @@ def flight_interface_worker(

output_queue.queue.put(value)
if not home_location_sent:
communications_ouutput_queue.put(home_location)
communications_output_queue.queue.put(home_location)

# Check for decision commands
if not input_queue.queue.empty():
Expand Down

0 comments on commit 4b65ad5

Please sign in to comment.