Skip to content

frontend: MainView: Limit update rate of model-viewer to 1rad#3791

Open
patrickelectric wants to merge 1 commit intobluerobotics:masterfrom
patrickelectric:update-rate-digital-twin
Open

frontend: MainView: Limit update rate of model-viewer to 1rad#3791
patrickelectric wants to merge 1 commit intobluerobotics:masterfrom
patrickelectric:update-rate-digital-twin

Conversation

@patrickelectric
Copy link
Member

@patrickelectric patrickelectric commented Feb 11, 2026

Summary by Sourcery

Limit updates of the 3D model orientation in MainView to reduce unnecessary renders.

New Features:

  • Introduce a dedicated Orientation type and lastOrientation state to track attitude data for the model viewer.

Enhancements:

  • Add a computed attitudeMessage and watcher that only updates orientation when any axis changes by more than 1 radian.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 11, 2026

Reviewer's Guide

Limits how frequently the 3D model viewer orientation is updated by caching the last attitude and only applying changes when any axis changes by more than 1 radian, to reduce unnecessary updates.

Sequence diagram for limited model viewer orientation updates

sequenceDiagram
  participant MavlinkStore
  participant MainView
  participant ModelViewer

  MavlinkStore->>MainView: update ATTITUDE_messageData_message
  MainView->>MainView: recompute attitudeMessage
  MainView->>MainView: attitudeMessage_watcher(msg)
  alt any axis change > 1 rad
    MainView->>MainView: update lastOrientation
    MainView->>ModelViewer: update orientation binding
  else change <= 1 rad
    MainView->>ModelViewer: no orientation update
  end
Loading

Class diagram for MainView orientation handling changes

classDiagram
  class Orientation {
    +number roll
    +number pitch
    +number yaw
  }

  class AppItem {
    +string icon
    +string title
    +string description
    +string route
    +boolean enabled
  }

  class MainView {
    +number windowHeight
    +number windowWidth
    +OneMoreTime fetch_streams_task
    +Orientation lastOrientation
    +AppItem[] apps()
    +boolean has_internet()
    +Orientation attitudeMessage()
    +string orientation()
    +void attitudeMessage_watcher(msg)
  }

  MainView o-- Orientation
  MainView o-- AppItem
Loading

Flow diagram for attitude-based orientation update thresholding

flowchart TD
  A[New ATTITUDE message received] --> B{Message defined?}
  B -- No --> C[Return without changes]
  B -- Yes --> D[Extract roll, pitch, yaw]
  D --> E[Read lastOrientation]
  E --> F{Any axis delta > 1 rad?}
  F -- No --> C
  F -- Yes --> G[Update lastOrientation with roll, pitch, yaw]
  G --> H[orientation computed from lastOrientation]
Loading

File-Level Changes

Change Details Files
Introduce orientation caching and threshold-based updates for the ATTITUDE-driven model viewer orientation
  • Define a typed Orientation interface for roll, pitch, and yaw values
  • Add lastOrientation to component data and use it in the orientation computed property instead of reading ATTITUDE directly
  • Add an attitudeMessage computed property that fetches the ATTITUDE message from the MAVLink store
  • Add a watcher on attitudeMessage that updates lastOrientation only when roll, pitch, or yaw changes by more than 1 radian
core/frontend/src/views/MainView.vue

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

@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 new attitudeMessage/lastOrientation logic changes semantics to "only update when delta > 1 rad" rather than "limit update rate to 1 rad"; if the intent is to cap per-update change rather than skip small changes, consider clamping deltas or renaming the threshold/logic to better reflect the behavior.
  • The 1 radian threshold is currently an inline magic number in the watcher; consider extracting it to a named constant (e.g. ORIENTATION_UPDATE_THRESHOLD_RAD) to make the purpose and units clearer and easier to adjust.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `attitudeMessage`/`lastOrientation` logic changes semantics to "only update when delta > 1 rad" rather than "limit update rate to 1 rad"; if the intent is to cap per-update change rather than skip small changes, consider clamping deltas or renaming the threshold/logic to better reflect the behavior.
- The `1` radian threshold is currently an inline magic number in the watcher; consider extracting it to a named constant (e.g. `ORIENTATION_UPDATE_THRESHOLD_RAD`) to make the purpose and units clearer and easier to adjust.

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.

@patrickelectric patrickelectric force-pushed the update-rate-digital-twin branch from 32c5a5e to b91d27c Compare February 11, 2026 19:41
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.

2 participants