Skip to content

refactor(preview): copy detector pointer payload#3

Merged
Jiu-xiao merged 1 commit intomasterfrom
codex/topic-pointer-payload-20260502
May 2, 2026
Merged

refactor(preview): copy detector pointer payload#3
Jiu-xiao merged 1 commit intomasterfrom
codex/topic-pointer-payload-20260502

Conversation

@Jiu-xiao
Copy link
Copy Markdown
Contributor

@Jiu-xiao Jiu-xiao commented May 2, 2026

Summary

  • consume armor_detector/armors_result as a direct detector-packet pointer payload
  • copy detector packets into preview queues during the topic callback
  • keep preview worker queues independent from detector-owned packet lifetime

Boundary

  • detector pointer payloads are same-process only
  • VisionPreview does not store detector pointers; it copies packet contents before queueing

Validation

Summary by Sourcery

Enhancements:

  • Adjust detector message type aliases and topic callback handling to work with pointer-based detector packets while preserving independent preview worker queues.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 2, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors VisionPreview to consume armor detector results as a direct pointer-based packet payload from the detector topic, and copies the underlying packet contents into its own queues to keep preview-side lifetimes independent of detector ownership.

Sequence diagram for detector pointer payload handling in VisionPreview

sequenceDiagram
    participant ArmorDetector
    participant DetectorTopic
    participant VisionPreview
    participant DetectorCallback
    participant PreviewQueue

    ArmorDetector->>DetectorTopic: publish ArmorDetectionsMessage
    DetectorTopic->>DetectorCallback: invoke with RawData
    DetectorCallback->>DetectorCallback: cast data.addr_ to DetectorTopicMessage
    DetectorCallback->>VisionPreview: PushDetector(**message)
    VisionPreview->>PreviewQueue: copy ArmorDetectionsPacket contents into queue
    PreviewQueue-->>VisionPreview: owns independent packet copy
    ArmorDetector-->>DetectorTopic: manages original ArmorDetectionsPacket lifetime
Loading

Class diagram for VisionPreview detector message refactor

classDiagram
    class VisionPreview {
        +ImageFrame
        +ImageTopic
        +ImageData
        +DetectorMessage
        +DetectorTopicMessage
        +DetectorMetrics
        +Tracker
        +TargetMessage
        +PushDetector(DetectorMessage packet)
    }

    class ArmorDetectionsPacket {
    }

    class ArmorDetectionsMessage {
        +ArmorDetectionsPacket* packet
        +operator*() ArmorDetectionsPacket&
        +operator!=(std::nullptr_t other) bool
    }

    class ArmorDetectorMetrics {
    }

    class ArmorTracker {
    }

    class CameraInfoV {
    }

    class SolveTrajectory_Target {
    }

    VisionPreview ..> ArmorDetectionsPacket : uses as DetectorMessage
    VisionPreview ..> ArmorDetectionsMessage : uses as DetectorTopicMessage
    VisionPreview ..> ArmorDetectorMetrics : uses
    VisionPreview ..> ArmorTracker : uses
    ArmorTracker ..> CameraInfoV : template parameter
    VisionPreview ..> SolveTrajectory_Target : uses

    ArmorDetectionsMessage --> ArmorDetectionsPacket : holds pointer

    ArmorTracker <|-- ArmorTracker_CameraInfoV

    class ArmorTracker_CameraInfoV {
    }
Loading

File-Level Changes

Change Details Files
Switch preview to use detector packet type and explicitly dereference/copy packet contents from the topic callback instead of treating the topic payload as a value message.
  • Change DetectorMessage alias to refer to ArmorDetectionsPacket and introduce DetectorTopicMessage alias for the topic-level ArmorDetectionsMessage pointer wrapper.
  • Update detector topic callback to reinterpret the incoming raw data as DetectorTopicMessage, null-check both the wrapper and the inner pointer, then pass the dereferenced packet to PushDetector to copy its contents into preview queues.
VisionPreview.hpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The use of reinterpret_cast<DetectorTopicMessage*>(data.addr_) and double dereference **message relies on implicit assumptions about the raw payload layout; consider documenting or encapsulating this in a small helper (e.g., DecodeDetectorPacket(data)) to make the ownership and pointer semantics explicit and easier to audit.
  • The null checks message != nullptr && *message != nullptr imply that DetectorTopicMessage is a nullable pointer-like type; consider using a stronger type (e.g., a wrapper or reference-like API) or adding an assertion/log when messages are unexpectedly null to surface upstream issues earlier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The use of `reinterpret_cast<DetectorTopicMessage*>(data.addr_)` and double dereference `**message` relies on implicit assumptions about the raw payload layout; consider documenting or encapsulating this in a small helper (e.g., `DecodeDetectorPacket(data)`) to make the ownership and pointer semantics explicit and easier to audit.
- The null checks `message != nullptr && *message != nullptr` imply that `DetectorTopicMessage` is a nullable pointer-like type; consider using a stronger type (e.g., a wrapper or reference-like API) or adding an assertion/log when messages are unexpectedly null to surface upstream issues earlier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Jiu-xiao Jiu-xiao merged commit 94915ff into master May 2, 2026
3 of 4 checks passed
@Jiu-xiao Jiu-xiao deleted the codex/topic-pointer-payload-20260502 branch May 2, 2026 19:00
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.

1 participant