Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit 413e7b1

Browse files
committed
Update test_auto_landing_worker.py
1 parent 26a7ecd commit 413e7b1

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

tests/integration/test_auto_landing_worker.py

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test auto-landing worker process.
33
"""
44

5-
import datetime
65
import multiprocessing as mp
76
import pathlib
87
import time
@@ -17,29 +16,17 @@
1716
from modules.common.modules import orientation
1817
from modules.common.modules import position_local
1918
from modules.common.modules.mavlink import drone_odometry_local
20-
from modules.common.modules.logger import logger
2119
from modules.common.modules.read_yaml import read_yaml
2220
from utilities.workers import queue_proxy_wrapper
2321
from utilities.workers import worker_controller
2422

2523

2624
# Test-specific parameters
2725
WORKER_PERIOD = 0.1 # seconds
28-
LOG_TIMINGS = False # Disable timing logging for the test
2926
CONFIG_FILE_PATH = pathlib.Path("config.yaml")
3027
detection_strategy = auto_landing.DetectionSelectionStrategy.FIRST_DETECTION
3128
# detection_strategy = auto_landing.DetectionSelectionStrategy.HIGHEST_CONFIDENCE
3229

33-
# Ensure logs directory exists and create timestamped subdirectory
34-
LOG_DIR = pathlib.Path("logs")
35-
LOG_DIR.mkdir(parents=True, exist_ok=True)
36-
37-
# Create a timestamped subdirectory for this test session
38-
TIMESTAMP_FORMAT = "%Y-%m-%d_%H-%M-%S"
39-
test_session_dir = LOG_DIR / datetime.datetime.now().strftime(TIMESTAMP_FORMAT)
40-
test_session_dir.mkdir(parents=True, exist_ok=True)
41-
42-
4330
def simulate_detection_input(
4431
input_queue: queue_proxy_wrapper.QueueProxyWrapper,
4532
detections: list,
@@ -114,20 +101,14 @@ def main() -> int:
114101
"""
115102
Main function.
116103
"""
117-
# Logger
118-
test_name = pathlib.Path(__file__).stem
119-
result, local_logger = logger.Logger.create(test_name, LOG_TIMINGS)
120-
assert result # Logger initialization should succeed
121-
assert local_logger is not None
122-
123104
# Read config file
124105
result, config = read_yaml.open_config(CONFIG_FILE_PATH)
125106
assert result and config is not None, "Failed to read config file"
126107

127108
# Check if the feature is enabled in the config
128109
auto_landing_config = config.get("auto_landing", {})
129110
if not auto_landing_config.get("enabled", False):
130-
local_logger.info("Auto-landing is disabled in config.yaml, skipping test.")
111+
print("Auto-landing is disabled in config.yaml, skipping test.")
131112
return 0
132113

133114
# Extract parameters from config
@@ -137,7 +118,7 @@ def main() -> int:
137118
image_height = config["video_input"]["height"]
138119
image_width = config["video_input"]["width"]
139120
except KeyError as e:
140-
local_logger.error(f"Config file missing required key: {e}")
121+
print(f"ERROR: Config file missing required key: {e}")
141122
return -1
142123

143124
# Setup
@@ -170,7 +151,7 @@ def main() -> int:
170151
time.sleep(0.5)
171152

172153
# Test 1: Send a single detection and verify it's processed
173-
local_logger.info("--- Test 1: Processing single detection ---")
154+
print("--- Test 1: Processing single detection ---")
174155
detection1_bbox = [200, 200, 400, 400]
175156
detection1 = create_test_detection(detection1_bbox, 1, 0.9)
176157
simulate_detection_input(
@@ -189,10 +170,10 @@ def main() -> int:
189170
assert hasattr(landing_info, "angle_x")
190171
assert hasattr(landing_info, "angle_y")
191172
assert hasattr(landing_info, "target_dist")
192-
local_logger.info("--- Test 1 Passed ---")
173+
print("--- Test 1 Passed ---")
193174

194175
# Test 2: Verify strategy with multiple detections
195-
local_logger.info(f"--- Test 2: Verifying {detection_strategy.value} strategy ---")
176+
print(f"--- Test 2: Verifying {detection_strategy.value} strategy ---")
196177

197178
# This is the first detection in the list
198179
detection_first_bbox = [100, 100, 200, 200]
@@ -243,7 +224,7 @@ def main() -> int:
243224
assert math.isclose(
244225
landing_info2.angle_y, expected_angle_y, rel_tol=1e-7
245226
), f"Expected angle_y to be {expected_angle_y}, but got {landing_info2.angle_y}"
246-
local_logger.info("--- Test 2 Passed ---")
227+
print("--- Test 2 Passed ---")
247228

248229
# Cleanup
249230
controller.request_exit()
@@ -253,9 +234,7 @@ def main() -> int:
253234

254235
# Wait for worker to finish
255236
worker.join(timeout=5.0)
256-
if worker.is_alive():
257-
worker.terminate()
258-
worker.join()
237+
worker.terminate()
259238

260239
return 0
261240

0 commit comments

Comments
 (0)