Skip to content

Commit

Permalink
fixing last linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ellyokes253 committed Jan 24, 2025
1 parent af13347 commit 6f4c829
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
21 changes: 19 additions & 2 deletions modules/auto_landing/auto_landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from ..common.modules.logger import logger
from .. import detections_and_time

from pymavlink import mavutil


class AutoLanding:
"""
Expand All @@ -29,9 +31,24 @@ def create(
fov_y: The vertical camera field of view in degrees.
im_w: Width of image.
im_h: Height of image.
height_agl: Height above ground level in meters.
Returns an AutoLanding object.
"""
local_logger.info("", True)
return True, AutoLanding(cls.__create_key, fov_x, fov_y, im_w, im_h, local_logger)
vehicle = mavutil.mavlink_connection("tcp:localhost:14550")
try:
height_agl_mm = vehicle.messages[
"GLOBAL_POSITION_INT"
].relative_alt # copied from blue_only.py
height_agl = max(height_agl_mm / 1000, 0.0)
local_logger.info(f"Altitude AGL: {height_agl} ", True)
except (KeyError, AttributeError):
local_logger.error("No GLOBAL_POSITION_INT message received")
return False, None

return True, AutoLanding(
cls.__create_key, fov_x, fov_y, im_h, im_w, height_agl, local_logger
)

def __init__(
self,
Expand Down
5 changes: 4 additions & 1 deletion modules/auto_landing/auto_landing_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def auto_landing_worker(
fov_y: float,
im_h: float,
im_w: float,
height_agl: float,
input_queue: queue_proxy_wrapper.QueueProxyWrapper,
output_queue: queue_proxy_wrapper.QueueProxyWrapper,
controller: worker_controller.WorkerController,
Expand All @@ -39,7 +40,9 @@ def auto_landing_worker(

local_logger.info("Logger initialized", True)

result, auto_lander = auto_landing.AutoLanding.create(fov_x, fov_y, im_h, im_w, local_logger)
result, auto_lander = auto_landing.AutoLanding.create(
fov_x, fov_y, im_h, im_w, height_agl, local_logger
)

if not result:
local_logger.error("Worker failed to create class object", True)
Expand Down

0 comments on commit 6f4c829

Please sign in to comment.