Skip to content

Fix complementary-filter quaternion interpolation threshold - #234

Open
Daniiiil1 wants to merge 1 commit into
CCNYRoboticsLab:rollingfrom
Daniiiil1:agent/fix-quaternion-interpolation-threshold
Open

Fix complementary-filter quaternion interpolation threshold#234
Daniiiil1 wants to merge 1 commit into
CCNYRoboticsLab:rollingfrom
Daniiiil1:agent/fix-quaternion-interpolation-threshold

Conversation

@Daniiiil1

Copy link
Copy Markdown

What changed

  • use the published 0.9 scalar-component threshold when choosing between SLERP and normalized LERP
  • keep SLERP for corrections at or below the threshold and LERP only for small corrections above it
  • add numerical tests for both interpolation branches
  • wire the new test into the ament test configuration

Why

The complementary-filter paper defines epsilon as 0.9: when the delta quaternion scalar component is greater than epsilon, the correction is small enough for normalized LERP; otherwise the filter uses SLERP. The implementation currently compares against zero, which sends most non-negative, non-small corrections through LERP instead.

Fixes #217.

Reference: Valenti, Dryanovski, and Xiao, Keeping a Good Attitude: A Quaternion-Based Orientation Filter for IMUs and MARGs, equations 48–52.

Validation

  • git diff --check
  • Apple Clang 21 compile of complementary_filter.cpp with C++17 and -Wall -Wextra -Wpedantic
  • standalone numerical probe verifying the exact SLERP result below the threshold and normalized-LERP result above it
  • clang-format --dry-run --Werror on the changed C++ files

A full ament test run was not available locally because this machine does not have a ROS 2 installation; the added gtest is intended to run in the repository CI.

@Daniiiil1
Daniiiil1 marked this pull request as ready for review August 9, 2026 13:17
@Daniiiil1
Daniiiil1 force-pushed the agent/fix-quaternion-interpolation-threshold branch from 3ddda08 to de4b389 Compare August 9, 2026 13:18
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.

complementary_filter implementation uses wrong threshold value in ScaleQuaternion function

1 participant