Skip to content

Add rolling speed and turn-rate metrics to debug HUD#1680

Closed
Coldaine wants to merge 1 commit intointrolab:masterfrom
Coldaine:feature/debug-hud-speed-metrics
Closed

Add rolling speed and turn-rate metrics to debug HUD#1680
Coldaine wants to merge 1 commit intointrolab:masterfrom
Coldaine:feature/debug-hud-speed-metrics

Conversation

@Coldaine
Copy link
Copy Markdown

Adds two rolling metrics to the debug HUD overlay in ViewController.swift:

  • linearMetersPerSecond — rolling 2-second average from cumulative distanceTravelled delta
  • turnDegreesPerSecond — rolling 2-second average from accumulated yaw deltas (rad→deg), with shortestAngleDeltaRadians() handling ±π wrapping

Both computed in updateDebugMotionMetrics() and rendered in statsUpdated.

Copilot AI review requested due to automatic review settings March 28, 2026 01:13
Copy link
Copy Markdown

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

Adds rolling motion metrics to the iOS debug HUD so developers can see recent (windowed) speed and turn rate while mapping/visualizing.

Changes:

  • Introduces a small rolling sample buffer (MotionSample) and a 2-second window constant for debug motion metrics.
  • Computes rolling average linear speed and turn rate in updateDebugMotionMetrics().
  • Renders the new metrics in the statsUpdated debug HUD text.

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

yaw: Float)
{
let now = Date().timeIntervalSince1970
let motionMetrics = self.updateDebugMotionMetrics(timestamp: now, distanceTravelled: distanceTravelled, yaw: yaw)
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

updateDebugMotionMetrics() is called on every statsUpdated callback even when debugShown is false, but the resulting metrics are only used inside the debug HUD block. Consider gating the sampling/metric computation behind debugShown (and optionally clearing debugMotionSamples when debug is hidden) to avoid extra per-frame work on the native callback thread.

Suggested change
let motionMetrics = self.updateDebugMotionMetrics(timestamp: now, distanceTravelled: distanceTravelled, yaw: yaw)
let motionMetrics = self.debugShown ? self.updateDebugMotionMetrics(timestamp: now, distanceTravelled: distanceTravelled, yaw: yaw) : nil

Copilot uses AI. Check for mistakes.
pitch: Float,
yaw: Float)
{
let now = Date().timeIntervalSince1970
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

The rolling window uses Date().timeIntervalSince1970 as the sample timestamp. Since wall-clock time can jump (NTP/manual change), deltaTime and the purge window can become incorrect (including negative deltas clamped to 0.001, or samples not being purged for a while). Use a monotonic clock (e.g., ProcessInfo.processInfo.systemUptime or CACurrentMediaTime()) for these motion metrics instead.

Suggested change
let now = Date().timeIntervalSince1970
let now = ProcessInfo.processInfo.systemUptime

Copilot uses AI. Check for mistakes.
- Add MotionSample struct with timestamp, distanceTravelled, yaw
- Rolling 2-second window buffer debugMotionSamples
- updateDebugMotionMetrics() computes:
  - linearMetersPerSecond from distance delta over window
  - turnDegreesPerSecond from accumulated yaw deltas (rad→deg)
- shortestAngleDeltaRadians() handles ±π wrapping
- Render both in statsUpdated debug label
@Coldaine Coldaine force-pushed the feature/debug-hud-speed-metrics branch from fae4a66 to bb17ccb Compare March 28, 2026 04:15
@Coldaine Coldaine closed this Mar 28, 2026
@Coldaine Coldaine deleted the feature/debug-hud-speed-metrics branch March 28, 2026 04:53
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