Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ashum68 committed Jun 5, 2024
1 parent 77e430c commit 4eae193
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 28 deletions.
2 changes: 1 addition & 1 deletion modules/flight_interface/flight_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def run(self) -> "tuple[bool, drone_odometry_local.DroneOdometryLocal | None]":

global_position = odometry.position

result, local_position = conversions.global_to_local(global_position, self.home_location)
result, local_position = conversions.position_global_to_local(global_position, self.home_location)
if not result:
return False, 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 @@ -5,8 +5,8 @@
import time

from . import flight_interface
from ..worker import queue_wrapper
from ..worker import worker_controller
from worker import queue_wrapper
from worker import worker_controller


def flight_interface_worker(
Expand Down
11 changes: 5 additions & 6 deletions tests/integration/test_flight_interface_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from modules import drone_odometry_local
from modules.flight_interface import flight_interface_worker

# Constants
QUEUE_MAX_SIZE = 10
FLIGHT_INTERFACE_ADDRESS = "tcp:127.0.0.1:14550"
FLIGHT_INTERFACE_TIMEOUT = 10
Expand All @@ -29,7 +30,7 @@ def main() -> int:
output_queue = queue_wrapper.QueueWrapper(manager, QUEUE_MAX_SIZE)

worker = mp.Process(
target=flight_interface_worker,
target=flight_interface_worker.flight_interface_worker,
args=(
FLIGHT_INTERFACE_ADDRESS,
FLIGHT_INTERFACE_TIMEOUT,
Expand All @@ -45,11 +46,9 @@ def main() -> int:

while True:
try:
input_data: drone_odometry_local.DroneOdometryLocal = output_queue.queue.get()
input_data: drone_odometry_local.DroneOdometryLocal = output_queue.queue.get_nowait()
assert (
str(type(input_data))
== "<class 'modules.drone_odometry_local\
.DroneOdometryLocal'>"
str(type(input_data)) == "<class 'modules.drone_odometry_local.DroneOdometryLocal'>"
)
assert input_data.local_position is not None
assert input_data.drone_orientation is not None
Expand All @@ -76,6 +75,6 @@ def main() -> int:
if __name__ == "__main__":
result_main = main()
if result_main < 0:
print("error: " + result_main)
print(f"Error: Status Code: {result_main}")

print("Done.")
21 changes: 2 additions & 19 deletions tests/unit/test_flight_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Test for flight interface by printing to device.
"""

from modules.common.mavlink.modules import drone_odometry
from modules.flight_interface import flight_interface


Expand All @@ -17,20 +16,6 @@ def create_flight_interface_instance(
return result, flight_interface_instance


def create_drone_position(
latitude: float, longitude: float, altitude: float
) -> drone_odometry.DronePosition:
"""
Contruct a drone position instance.
"""
expected = True
actual, global_position = drone_odometry.DronePosition.create(latitude, longitude, altitude)
assert actual == expected
assert global_position is not None

return global_position


class TestFlightInterface:
"""
Flight interface tests.
Expand All @@ -39,16 +24,14 @@ class TestFlightInterface:
MISSION_PLANNER_ADDRESS = "tcp:127.0.0.1:14550"
TIMEOUT = 1.0

DELAY_TIME = 1.0

def test_create_invalid_address(self) -> None:
"""
Test create method using a valid Mission Planner IP address.
Test create method using an invalid Mission Planner IP address.
"""
expected_result = False
expected_instance = None
actual_result, actual_instance = create_flight_interface_instance(
"tcp:0.0.0.0:0", self.TIMEOUT
"tcp:127.0.0.1:3000", self.TIMEOUT
)
assert actual_result == expected_result
assert actual_instance == expected_instance

0 comments on commit 4eae193

Please sign in to comment.