Skip to content

Tracker service v0.3.2: robot vision integration#968

Merged
saratpoluri merged 14 commits intomainfrom
tracker-service-v0.3.2
Feb 21, 2026
Merged

Tracker service v0.3.2: robot vision integration#968
saratpoluri merged 14 commits intomainfrom
tracker-service-v0.3.2

Conversation

@jdanieck
Copy link
Copy Markdown

@jdanieck jdanieck commented Feb 3, 2026

📝 Description

Replaces the stub tracking in TrackingWorker with Intel RobotVision's Kalman filter library, adds batch coordinate transformation, and hardens the deployment configuration.

Key Changes

RobotVision Integration (tracking_worker.cpp):

  • Replaced stub_tracking() with rv::tracking::MultipleObjectTracker (Kalman filter + Hungarian matching, CV/CA/CTRV motion models)
  • New run_tracking()transform_detections()convert_tracks() pipeline
  • Empty chunks now advance tracker time for track aging; heartbeats always published

New Modules:

  • CoordinateTransformer — batch pixel-to-world via cv::undistortPoints + OpenMP ray-plane intersection (matches Python controller's transform.py)
  • IdMap — maps RobotVision int32_t track IDs to persistent UUID v4 strings at the output boundary
  • uuid.hpp — thread-safe UUID v4 generator (thread_local mt19937_64)
  • time_utils.hpp/cpp — extracted parseTimestamp/formatTimestamp from MessageHandler into standalone module; now requires trailing Z (UTC)

Configuration:

  • Added max_unreliable_time_s, non_measurement_time_dynamic_s, non_measurement_time_static_s to TrackingConfig + JSON schema + env var overrides
  • Default config switched to TLS (broker.scenescape.intel.com, insecure: false, CA cert at /run/secrets/certs/)
  • Added tracking section to tracker.json with all pipeline parameters

Deployment Hardening:

  • Docker Compose: added read_only: true, cap_drop: ALL, no-new-privileges:true for tracker service
  • Service test compose also hardened

Developer Experience:

  • VS Code launch.json: added proxy and TLS environment variables for both native and container debug
  • Makefile run/run-debug: export TRACKER_MQTT_* and TLS vars; mount CA cert for run-image/run-image-debug
  • README updated with SceneScape demo workflow and env override table

Testing:

  • New: coordinate_transformer_test.cpp (position, size, batch, horizon culling), id_map_test.cpp, uuid_test.cpp, time_utils_test.cpp (valid/invalid/round-trip)
  • Updated: tracking_worker_test.cpp (RobotVision multi-detection behavior), message_handler_test.cpp (lag detection, empty batch buffering), time_chunk_scheduler_test.cpp (camera intrinsics in fixtures)
  • New service test: test_tracking_produces_reliable_tracks — sends 20 detections, validates UUID v4 track output
  • Python reference data generator + transformation_reference.json for cross-validation with scipy/numpy
  • Schema validation now uses FormatChecker() to enforce UUID format

Dependencies:

  • Added stduuid/1.2.3 (Conan), OpenMP (system)

Schema:

  • scene-data.schema.json: track ID now "format": "uuid" with updated description

✨ Type of Change

  • 🚀 New feature – RobotVision tracking integration with coordinate transformation
  • 📚 Documentation update
  • 🧪 Tests

🧪 Testing Scenarios

  • ✅ Tested manually with SceneScape demo
  • 🤖 Unit tests pass (including new coordinate transform, ID map, UUID, time utils tests)
  • 🤖 Service tests pass (connection resilience, mTLS, tracking reliability, graceful shutdown)

✅ Checklist

  • 🔍 PR title is clear and descriptive
  • 💬 Code is commented, especially CoordinateTransformer pipeline
  • 📄 Updated implementation documentation
  • ✅ Added comprehensive unit and service tests

✨ Type of Change

  • 🚀 New feature – Non-breaking change which adds functionality
  • 💥 Breaking change – Track ID changed from string to integer
  • 📚 Documentation update
  • 🧪 Tests

🧪 Testing Scenarios

  • ✅ Tested manually with SceneScape demo
  • 🤖 Ran automated unit tests (226 tests pass)
  • 🤖 Ran service tests with MQTT broker

✅ Checklist

  • 🔍 PR title is clear and descriptive
  • 💬 Code is commented, especially CoordinateTransformer pipeline
  • 📄 Updated tracker-service.md design documentation
  • ✅ Added comprehensive unit and service tests

@jdanieck jdanieck self-assigned this Feb 3, 2026
@jdanieck jdanieck requested a review from Copilot February 3, 2026 10:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR integrates RobotVision's Kalman filter tracking library into the tracker service, replacing the previous stub tracking implementation. The change upgrades track IDs from UUID strings to integer IDs produced by RobotVision's tracking system.

Changes:

  • Integrated RobotVision TrackTracker with Kalman filter for multi-object tracking
  • Changed track ID type from string to int32_t to match RobotVision's output
  • Added camera calibration support for pixel-to-world coordinate transformation
  • Updated tests to reflect real tracking behavior (tracks require multiple detections for reliability)

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tracker/src/tracking_worker.cpp Replaced stub tracking with RobotVision TrackTracker integration, added camera calibration handling
tracker/inc/tracking_worker.hpp Added RobotVision headers and member variables for tracker and camera parameters
tracker/inc/tracking_types.hpp Changed Track::id from string to int32_t
tracker/src/track_publisher.cpp Updated JSON serialization to use SetInt() instead of SetString() for track ID
tracker/src/time_chunk_scheduler.cpp Refactored worker creation to build camera map and pass tracking config
tracker/schema/scene-data.schema.json Updated schema to enforce integer track IDs with minimum 0
tracker/test/unit/tracking_worker_test.cpp Added helper functions, new tests for edge cases, updated expectations for RobotVision behavior
tracker/test/unit/track_publisher_test.cpp Updated test data to use integer track IDs
tracker/test/unit/time_chunk_scheduler_test.cpp Added camera intrinsics/distortion to test fixtures
tracker/test/unit/message_handler_test.cpp Added test for lagged message handling
tracker/test/service/test_mqtt.py Added detection sequence helper and new tracking reliability test
Comments suppressed due to low confidence (5)

tracker/test/service/test_mqtt.py:1

  • Test code contains timestamps in January 2026, which is in the future relative to the current date (February 3, 2026). Consider using timestamps that are clearly test data or relative to the current time to avoid confusion.
#!/usr/bin/env python3

tracker/test/service/test_mqtt.py:1

  • Test code contains timestamps in January 2026, which is in the future relative to the current date (February 3, 2026). Consider using timestamps that are clearly test data or relative to the current time to avoid confusion.
#!/usr/bin/env python3

tracker/test/service/test_mqtt.py:1

  • Test code contains timestamps in January 2026, which is in the future relative to the current date (February 3, 2026). Consider using timestamps that are clearly test data or relative to the current time to avoid confusion.
#!/usr/bin/env python3

tracker/test/service/test_mqtt.py:1

  • Test code contains timestamps in January 2026, which is in the future relative to the current date (February 3, 2026). Consider using timestamps that are clearly test data or relative to the current time to avoid confusion.
#!/usr/bin/env python3

tracker/test/service/test_mqtt.py:1

  • Test code contains timestamps in January 2026, which is in the future relative to the current date (February 3, 2026). Consider using timestamps that are clearly test data or relative to the current time to avoid confusion.
#!/usr/bin/env python3

Comment thread tracker/test/unit/message_handler_test.cpp Outdated
@jdanieck jdanieck changed the title Tracker-service-v0.3.2 Tracker service v0.3.2: robot vision integration Feb 3, 2026
@jdanieck jdanieck force-pushed the tracker-service-v0.3.1 branch from d186ad4 to 6fd555a Compare February 6, 2026 09:47
@jdanieck jdanieck force-pushed the tracker-service-v0.3.2 branch from fc4b99c to 70db2a4 Compare February 6, 2026 09:52
@jdanieck jdanieck force-pushed the tracker-service-v0.3.1 branch 2 times, most recently from 7aaba31 to 5fee258 Compare February 6, 2026 15:24
@jdanieck jdanieck force-pushed the tracker-service-v0.3.2 branch 2 times, most recently from d527ff8 to d2031d9 Compare February 9, 2026 10:18
@jdanieck jdanieck requested a review from Copilot February 9, 2026 10:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 10 comments.

Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/inc/coordinate_transformer.hpp Outdated
Comment thread tracker/inc/coordinate_transformer.hpp Outdated
Comment thread tracker/.vscode/launch.json Outdated
Comment thread tracker/src/config_loader.cpp
Comment thread tracker/test/unit/tracking_worker_test.cpp Outdated
Comment thread tracker/test/unit/tracking_worker_test.cpp Outdated
Comment thread tracker/test/unit/tracking_worker_test.cpp Outdated
@jdanieck jdanieck requested a review from Copilot February 9, 2026 11:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 12 comments.

Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/test/unit/tracking_worker_test.cpp
Comment thread tracker/test/unit/message_handler_test.cpp Outdated
Comment thread tracker/Makefile Outdated
Comment thread tracker/test/unit/coordinate_transformer_test.cpp Outdated
Comment thread tracker/test/unit/coordinate_transformer_test.cpp
@jdanieck jdanieck requested a review from Copilot February 9, 2026 14:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 6 comments.

Comment thread tracker/test/unit/tracking_worker_test.cpp
Comment thread tracker/test/unit/tracking_worker_test.cpp
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/test/tools/generate_reference_data.py Outdated
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
Remove unused variables that were computed but never read after the loop.
The batch_timestamp is still used for tracker_.track() calls.

Addresses PR #968 review comment about dead code.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
Change format from '{:%Y-%m-%dT%H:%M:%S}Z' to '{:%Y-%m-%dT%H:%M:%S}.000Z'
to match the ISO 8601 '.fffZ' pattern used by detection messages.
Update test to verify '.' is present in the fallback timestamp.

Addresses PR #968 review comment about missing fractional seconds.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
These headers are used directly (std::optional<int> parse_int, chrono types
in parse_timestamp/process_chunk) but were only included transitively.
Explicit includes follow the include-what-you-use principle.

Addresses PR #968 review comment about missing includes.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
Use CoordinateTransformer (full intrinsics + extrinsics pipeline) instead of
rv::computePixelsToMeterPlane (undistort-only). This changes published
Track.translation from camera-relative normalized coords to actual world
coordinates via the bboxFootToWorld() method (undistort -> pose -> ray-plane
intersection with ground plane z=0).

Changes:
- TrackingWorker stores CoordinateTransformer per camera instead of raw
  intrinsics/distortion matrices
- run_tracking() uses bboxFootToWorld() for pixel-to-world transform
- Remove get_camera_params() method (no longer needed)
- Update test cameras to include extrinsics

Addresses PR #968 review comment about computePixelsToMeterPlane lacking
extrinsics.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
Replace unbounded while loops with deadline-bounded loops that fail with
ASSERT_LT after 5 seconds. Prevents CI from hanging forever if the
worker thread deadlocks.

Addresses PR #968 review comment about unbounded polling in
QueueDepth_ReturnsCorrectSize.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
Replace unbounded while loop with deadline-bounded loop that fails with
ASSERT_LT after 5 seconds. Prevents CI from hanging forever if the
worker thread deadlocks.

Addresses PR #968 review comment about unbounded polling in
QueueFull_IncrementsDroppedCount.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
The cv.wait_for() return value was discarded, so the test would silently
pass even if the callback was never invoked. Wrap in ASSERT_TRUE to
fail explicitly on timeout.

Addresses PR #968 review comment about discarded wait_for result.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
The 1e-9 tolerance leaves very little margin for differences in sin/cos
implementations across compilers, libm versions, and floating-point
optimization flags. 1e-8 is still strict enough to catch real bugs
(wrong rotation order differs by ~0.7) while being robust across
build configurations.

Addresses PR #968 review comment about strict rotation tolerance.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
Use std::format("{:%Y-%m-%dT%H:%M:%S}.000Z", ...) with chrono time_point
instead of POSIX-only gmtime_r + std::put_time. This is consistent with
the approach used in tracking_worker.cpp and uses only standard C++20.

Remove unused <iomanip> and <sstream> includes.

Addresses PR #968 review comment about gmtime_r portability.
jdanieck pushed a commit that referenced this pull request Feb 9, 2026
The run/run-debug targets export TRACKER_MQTT_HOST, TRACKER_MQTT_PORT,
TRACKER_MQTT_INSECURE, and TRACKER_MQTT_TLS_CA_CERT. If a developer
runs 'make run' then 'make test-service' in the same shell, those env
vars would leak into the pytest process. Add explicit unset to isolate
the test environment.

Addresses PR #968 review comment about removed env var isolation.
@jdanieck jdanieck force-pushed the tracker-service-v0.3.2 branch from 26444de to 8bbf97a Compare February 10, 2026 09:31
Comment thread tracker/src/tracking_worker.cpp Outdated
Comment thread tracker/src/tracking_worker.cpp Outdated
Copy link
Copy Markdown
Contributor

@tdorauintc tdorauintc left a comment

Choose a reason for hiding this comment

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

Review in progress

Copy link
Copy Markdown
Contributor

@ltalarcz ltalarcz left a comment

Choose a reason for hiding this comment

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

In review

Comment thread tracker/src/coordinate_transformer.cpp
Comment thread tracker/src/time_utils.cpp Outdated
Comment thread tracker/src/time_utils.cpp Outdated
Józef Daniecki added 4 commits February 20, 2026 11:37
Move valid[i] = 1 outside the if/else block since both branches
set it to the same value. Addresses PR #968 review feedback.
Remove redundant `&& i < 3` in fractional-seconds scaling loop.
Copy-paste artifact. Addresses PR #968 review feedback.
…eTimestamp

Use std::string_view and index-based access instead of const char*
pointer arithmetic for fractional-seconds parsing.
Addresses PR #968 review feedback.
@jdanieck jdanieck requested a review from ltalarcz February 20, 2026 12:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment on lines +4 to +7
#include <gtest/gtest.h>

#include "id_map.hpp"

Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

SequentialGenerator uses std::array, but this test file doesn't include <array>, which can cause a compile failure depending on transitive includes. Add #include <array> (or avoid std::array here) to make the test self-contained.

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +139
const std::vector<YawToQuaternionTestCase> kYawToQuaternionTests = {
{0.0, {0.0, 0.0, 0.0, 1.0}},
{M_PI / 2, {0.0, 0.0, 0.7071067811865475, 0.7071067811865476}},
{M_PI, {0.0, 0.0, 1.0, 6.123233995736766e-17}},
{-M_PI / 2, {0.0, 0.0, -0.7071067811865475, 0.7071067811865476}},
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

This test uses M_PI, which is a non-standard extension and may be undefined on some toolchains (notably MSVC unless _USE_MATH_DEFINES is set). Prefer a portable constant like std::numbers::pi (C++20) to avoid build portability issues.

Copilot uses AI. Check for mistakes.
Comment on lines 67 to 71
TrackingScope scope{"scene-1", "person"};
TrackingWorker worker(scope, "Test Scene", 2, callback);
TrackingWorker worker(scope, "Test Scene", 2, callback, tracking_config_, cameras_);

// Create chunk with detections
Chunk chunk;
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

The tests in this file set DetectionBatch.timestamp_iso on batches they enqueue, but don’t populate the new parsed DetectionBatch.timestamp field. Since TrackingWorker now uses batch.timestamp to advance the RobotVision tracker, these tests end up exercising tracking with a default-constructed epoch time (mismatched with timestamp_iso). Consider setting batch.timestamp (e.g., via parseTimestamp(timestamp_iso) or a helper) when building test batches.

Copilot uses AI. Check for mistakes.
Comment on lines 60 to +63
"id": {
"type": "string",
"description": "Persistent track ID (UUID, stable across frames while tracked)"
"format": "uuid",
"description": "Persistent track ID (UUID v4, stable across frames while tracked)"
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

PR description mentions a breaking change where the track ID changed from string to integer, but the schema (and tests) still define id as a string (now with format: uuid). Please reconcile the PR description with the actual API (or adjust the schema/output if an integer ID is intended).

Copilot uses AI. Check for mistakes.
@saratpoluri saratpoluri dismissed stale reviews from ltalarcz and tdorauintc February 21, 2026 17:53

No changes outside of the tracker folder. Will not be default for another release cycle. Focused on achieving MVP results both functional and performance.

@saratpoluri saratpoluri enabled auto-merge (squash) February 21, 2026 17:54
@saratpoluri saratpoluri merged commit 5f0496c into main Feb 21, 2026
34 checks passed
@saratpoluri saratpoluri deleted the tracker-service-v0.3.2 branch February 21, 2026 17:58
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.

5 participants