Skip to content

feat: adaptive trail sampling for smoother ribbons with less geometry#44

Closed
MikePehel wants to merge 2 commits intomavlink:mainfrom
MikePehel:feat/adaptive-trail-sampling
Closed

feat: adaptive trail sampling for smoother ribbons with less geometry#44
MikePehel wants to merge 2 commits intomavlink:mainfrom
MikePehel:feat/adaptive-trail-sampling

Conversation

@MikePehel
Copy link
Contributor

@MikePehel MikePehel commented Mar 10, 2026

Summary

  • Replace fixed-interval trail sampling (every 16ms) with direction-aware adaptive sampling that records points densely on turns and sparsely on straights
  • Halve trail buffer from 3600 to 1800 points per vehicle since adaptive sampling achieves comparable coverage with fewer points
  • Restore Snow view mode speed ribbon gradient (navy → blue → teal → green → yellow → red) which was falling through to the Grid default

How it works

Three sampling triggers, whichever fires first:

  • Direction change: dot product < 0.995 (~5.7° turn) with minimum distance gate — curves get dense point coverage
  • Max distance: 0.5m cap so straight runs don't gap
  • Time floor: 64ms fallback for slow movement / hover

Impact

  • Smoother ribbon geometry on turns (more points where curvature matters)
  • ~50% less memory and draw cost per vehicle (1800 vs 3600 point buffer)
  • Significant for multi-vehicle scenarios (16 drones = 28,800 fewer points per frame)
  • No API changes, no new dependencies

Test plan

  • Verify trail renders correctly in all three modes (off / directional / speed ribbon)
  • Verify ribbon smoothness on tight turns vs straight runs
  • Verify trail coverage duration is comparable to previous fixed-interval sampling
  • Verify Snow mode speed ribbon uses distinct blue-green-yellow gradient
  • Test with ULog replay (--replay)
  • Test with live MAVLink input

Replace fixed-interval trail sampling (every 16ms) with direction-aware
adaptive sampling. Points are recorded densely on turns (>5.7° direction
change) and sparsely on straights (0.5m max / 64ms floor), producing
smoother ribbon curves where it matters without wasting buffer on
redundant straight-line segments.

Halve TRAIL_MAX from 3600 to 1800 since adaptive sampling achieves
comparable trail coverage with fewer points, reducing per-vehicle memory
and draw cost — significant for multi-vehicle scenarios.
Snow mode was falling through to the Grid default thermal gradient
(purple → white) instead of its dedicated palette (navy → blue →
teal → green → yellow → red).
@mrpollo
Copy link
Member

mrpollo commented Mar 11, 2026

Merged in #46

@mrpollo mrpollo closed this Mar 11, 2026
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