Skip to content

Integrate XYZ coordinates with pathing and add test documentation#11

Open
xingyi1145 wants to merge 10 commits into
UWARG:depthai1from
xingyi1145:depthai1
Open

Integrate XYZ coordinates with pathing and add test documentation#11
xingyi1145 wants to merge 10 commits into
UWARG:depthai1from
xingyi1145:depthai1

Conversation

@xingyi1145

Copy link
Copy Markdown

This pull request introduces a two-phase integration testing protocol for the OAK-D vision-to-MAVLink tracking pipeline, along with a new simulation test and reusable velocity control logic. The main changes add a documented testing workflow, a simulation script for validating MAVLink velocity commands, and reusable functions for velocity calculation and command sending.

Integration Testing Protocol and Documentation:

  • Added a new document (documentation/tests/unit/test_remote_integration.md) outlining the two-phase integration testing protocol, including SITL (Software-In-The-Loop) verification steps, prerequisites, execution instructions, and success criteria for validating the velocity controller and MAVLink command construction.

Simulation and Test Code:

  • Added a new simulation script (tests/test_remote_integration.py) that connects to a virtual drone using MAVLink, simulates a sequence of target detections, and sends velocity commands based on the simulated target’s position. This script helps verify the velocity controller logic and MAVLink integration in a controlled environment.

Reusable Velocity Control Functions:

  • Introduced calculate_velocity_commands and send_velocity_command functions in both main_2025.py and the test script, encapsulating the proportional control logic and MAVLink command sending for easier reuse and maintainability. [1] [2]

Qstrich and others added 10 commits March 16, 2026 21:19
…proach

- Brings in ultralytics + depthai into requirements.txt from stereodepth
- Drops depthai_detector.py (Pipeline 2.0 class) in favour of existing
  spatial_detection_node.py / object_tracker_node.py functional approach
- Removes tests/unit/test_pipeline_nodes.py

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie Meng <yujiemengca@gmail.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
- Fix dead xout_rgb: switch color_cam.video → preview so bbox coords align
- Add rgb_queue read + cv2 bbox overlay and imshow in main loop
- Make model_path required in create_spatial_detection_network (no fallback)
- Drop blobconverter dep; add opencv-python to requirements-pytorch.txt
- Update config.yaml: model_path now required, documents conversion path

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie Meng <yujiemengca@gmail.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
Replace deprecated MonoCamera/ColorCamera with Camera.build(),
YoloSpatialDetectionNetwork with SpatialDetectionNetwork.build()
using Luxonis model zoo, XLinkOut with createOutputQueue(), and
dai.Device with dai.Pipeline context manager.

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie Meng <yujiemengca@gmail.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
Resolves missing-function-docstring warning causing CI exit code 16.

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
…estimate

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie Meng <yujiemengca@gmail.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces the two-bucket constant offset (27/74mm split at 750mm) with a
piecewise-linear interpolation over 4 measured anchors (0.5/1.0/1.5/2.0m)
that tapers smoothly to zero past 2.2m, where the camera's factory
calibration is trusted. The previous scheme over-corrected at 2m,
turning a -31mm raw bias into -105mm; the new one avoids this by
capturing the genuine non-monotonicity of the bias profile.

Residual bias after calibration (vs. raw):

| Distance | Raw    | Calibrated |
|----------|--------|------------|
| 0.5m     | +27.5  | -0.14      |
| 1.0m     | +75.1  | +0.12      |
| 1.5m     | +73.2  | +0.48      |
| 2.0m     | -48.7  | -3.61      |

Also commits the underlying test logs (2026-04-30, 2026-05-07) and the
calibration visualization for reproducibility.

![calibration](https://github.com/UWARG/ML-CV-Target-Tracking/raw/depthai1/documentation/accuracy/calibration.png)

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie Meng <yujiemengca@gmail.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
CI failed black --check on the previous commit (column-aligned tuples
and an extra blank line). Reformat to satisfy the checker; no semantic
change.

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie Meng <yujiemengca@gmail.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
@xingyi1145 xingyi1145 self-assigned this May 18, 2026
Copilot AI review requested due to automatic review settings May 18, 2026 02:25
@xingyi1145 xingyi1145 requested a review from SophieYuen0924 May 18, 2026 02:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a documented, manual SITL-based integration test workflow for validating MAVLink velocity control logic, and introduces helper functions intended to compute and send velocity commands.

Changes:

  • Added a new SITL integration testing protocol document under documentation/tests/unit/.
  • Added a new MAVLink/SITL simulation script (tests/test_remote_integration.py) that sends velocity commands based on a simulated target path.
  • Added velocity calculation + MAVLink command helpers to main_2025.py for reuse.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
tests/test_remote_integration.py Adds a manual SITL simulation script for sending MAVLink velocity commands.
main_2025.py Introduces shared velocity-control helper functions intended for the main tracking pipeline.
documentation/tests/unit/test_remote_integration.md Documents how to run the SITL-based integration validation.
Comments suppressed due to low confidence (2)

main_2025.py:55

  • send_velocity_command references mavutil but main_2025.py does not import it anywhere, so this is a runtime NameError and a pylint undefined-variable. Add the appropriate pymavlink import (or move it inside the function) and add required type annotations for flake8-annotations.
def send_velocity_command(master, vx, vy, vz, yaw_rate):
    type_mask = 0b010111000111
    master.mav.set_position_target_local_ned_send(
        0,
        master.target_system,
        master.target_component,
        mavutil.mavlink.MAV_FRAME_BODY_NED,
        type_mask,

tests/test_remote_integration.py:17

  • calculate_velocity_commands takes target_y_m but never uses it, which will raise pylint unused-argument. Use the parameter (e.g., for vertical/altitude control) or rename it to _target_y_m / remove it from the signature and update callers.
def calculate_velocity_commands(target_x_m, target_y_m, target_z_m):
    desired_z = 2.0
    desired_x = 0.0
    kp_z = 0.5
    kp_x = 0.5

    error_z = target_z_m - desired_z
    error_x = target_x_m - desired_x

    vx = max(-2.0, min(2.0, kp_z * error_z))
    vy = max(-2.0, min(2.0, kp_x * error_x))

    return vx, vy, 0.0, 0.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main_2025.py
Comment on lines +32 to +36
def calculate_velocity_commands(target_x_m, target_y_m, target_z_m):
desired_z = 2.0 # Stop 2 meters away
desired_x = 0.0 # Center horizontally

kp_z = 0.5
Comment on lines +1 to +6
import time
from pymavlink import mavutil


def calculate_velocity_commands(target_x_m, target_y_m, target_z_m):
desired_z = 2.0
```
2. Run the mock integration script:
```bash
python3 test_remote_integration.py
@@ -0,0 +1,24 @@
# Target Tracking: Integration Testing Protocol

This document outlines the two-phase testing protocol for the OAK-D vision-to-MAVLink tracking pipeline.
@tqmsh tqmsh force-pushed the depthai1 branch 5 times, most recently from 9dba12f to a4d5d0e Compare June 15, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants