frontend: MainView: Limit update rate of model-viewer to 1rad#3791
Open
patrickelectric wants to merge 1 commit intobluerobotics:masterfrom
Open
frontend: MainView: Limit update rate of model-viewer to 1rad#3791patrickelectric wants to merge 1 commit intobluerobotics:masterfrom
patrickelectric wants to merge 1 commit intobluerobotics:masterfrom
Conversation
Reviewer's GuideLimits 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 updatessequenceDiagram
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
Class diagram for MainView orientation handling changesclassDiagram
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
Flow diagram for attitude-based orientation update thresholdingflowchart 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]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
attitudeMessage/lastOrientationlogic 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
1radian 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
27c25ef to
32c5a5e
Compare
Signed-off-by: Patrick José Pereira <[email protected]>
32c5a5e to
b91d27c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Limit updates of the 3D model orientation in MainView to reduce unnecessary renders.
New Features:
Enhancements: