Skip to content

Clean up circular variable support in rtsdiff#198

Open
pavelkomarov wants to merge 3 commits intomasterfrom
circular-variable-support
Open

Clean up circular variable support in rtsdiff#198
pavelkomarov wants to merge 3 commits intomasterfrom
circular-variable-support

Conversation

@pavelkomarov
Copy link
Collaborator

@pavelkomarov pavelkomarov commented Mar 14, 2026

Summary

Builds on Floris' circular variable work to refine the design:

  • Replaces circular_vars / circular_units parameters on kalman_filter and rtsdiff with a cleaner abstraction:
    • kalman_filter gains innovation_fn=None: an optional callable (y_n, pred) that replaces the standard y[n] - C @ xhat_ subtraction, making the filter fully generic for non-Euclidean measurements without any angle-specific logic inside the filter itself
    • rtsdiff gains circular=False: when True, the appropriate wrapping lambda is constructed internally and passed to both forward and backward filter calls
  • Angle wrapping arithmetic ((y - pred + π) % 2π - π) is inlined directly in the lambda rather than wrapped in a named utility function — it's a one-liner and clear in place
  • Only radians are supported; users should convert with np.deg2rad first (documented in the docstring)
  • Removes ensure_iterable from utility.py, which is no longer needed
  • Adds test_circular_rtsdiff: differentiates a noisy linearly-increasing angle that wraps across ±π boundaries and checks the recovered angular rate is within 0.5 rad/s RMSE of the truth (actual ≈ 0.04 rad/s)

Addresses #178

Test plan

  • All 308 existing tests pass
  • New test_circular_rtsdiff passes

🤖 Generated with Claude Code

Replaces the per-dimension circular_vars/circular_units approach with a generic
innovation_fn parameter on kalman_filter and a simple circular=False boolean on
rtsdiff. Adds wrap_angle (radians-only) to utility.py and a test for wrapping
angle differentiation. Addresses #178.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pavelkomarov pavelkomarov force-pushed the circular-variable-support branch from 25739d7 to 1260e10 Compare March 14, 2026 00:25
pavelkomarov and others added 2 commits March 13, 2026 17:33
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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