uav.vision_nodes.PayloadColorSquareNode#

Attributes#

Classes#

Functions#

_detect_tape_following(→ tuple[bool, float, float])

Find the center of the combined tape strip (orange + blue) in the processing

_detect_current_color(→ str)

Determine dominant tape color across the full processing strip.

_red_mask(→ numpy.ndarray)

OR the two hue ranges required to detect red in OpenCV HSV.

_get_strip(→ tuple[numpy.ndarray, int])

Return the bottom-1/3 strip and its y-offset in the full frame.

_preprocess_color_crop(→ numpy.ndarray)

Light denoising before HSV thresholding to stabilize tape masks.

main(→ None)

Module Contents#

_LOWER_A1#
_UPPER_A1#
_LOWER_A2#
_UPPER_A2#
_LOWER_B#
_UPPER_B#
_STRIP_START_FRAC = 0.6666666666666666#
_MIN_COLOR_PIXELS = 20#
_COLOR_RATIO = 1.5#
_MIN_ROW_PIXELS = 3#
_COLOR_BLUR_KERNEL = (5, 5)#
_detect_tape_following(orange_mask: numpy.ndarray, blue_mask: numpy.ndarray) tuple[bool, float, float]#

Find the center of the combined tape strip (orange + blue) in the processing strip and return steering metrics.

Returns:

  • boundary_detected: True if tape is visible.

  • lateral_error_px: Tape centre x minus frame centre x (positive = tape is to the right, steer right to re-centre).

  • boundary_angle: Tilt of the tape’s centre line in the frame (radians from vertical; positive = leans right at the bottom).

Return type:

A (boundary_detected, lateral_error_px, boundary_angle) tuple

_detect_current_color(orange_mask: numpy.ndarray, blue_mask: numpy.ndarray) str#

Determine dominant tape color across the full processing strip. Returns “A” (orange), “B” (blue), or “none”.

_red_mask(hsv: numpy.ndarray) numpy.ndarray#

OR the two hue ranges required to detect red in OpenCV HSV.

_get_strip(bgr: numpy.ndarray) tuple[numpy.ndarray, int]#

Return the bottom-1/3 strip and its y-offset in the full frame.

_preprocess_color_crop(bgr: numpy.ndarray) numpy.ndarray#

Light denoising before HSV thresholding to stabilize tape masks.

class PayloadColorSquareNode#

Bases: vehicle_common.base.VisionNode

srv#
_debug_pub: Any | None = None#
service_callback(request: uav_interfaces.srv.PayloadColorSquareState.Request, response: uav_interfaces.srv.PayloadColorSquareState.Response) uav_interfaces.srv.PayloadColorSquareState.Response#
_debug_timer_callback() None#
draw_debug(bgr: numpy.ndarray, strip: numpy.ndarray, strip_start: int, orange_mask: numpy.ndarray, blue_mask: numpy.ndarray, current_color: str, boundary_detected: bool, lateral_error_px: float, boundary_angle: float) None#
main() None#