dualsense-ts
Version:
The natural interface for your DualSense and DualSense Access controllers, with Typescript
41 lines • 1.58 kB
TypeScript
/**
* Madgwick AHRS (Attitude and Heading Reference System) filter.
*
* Fuses 3-axis gyroscope and 3-axis accelerometer data into a stable
* orientation quaternion using gradient-descent-based correction.
*
* Reference: Sebastian Madgwick, "An efficient orientation filter for
* inertial and inertial/magnetic sensor arrays" (2010).
*
* Zero dependencies. The algorithm is ~40 lines of arithmetic.
*/
import { type Quaternion } from "./quaternion";
export declare class MadgwickFilter {
/** Current orientation estimate. */
q: Quaternion;
/**
* Filter gain. Higher values trust the accelerometer more — less
* drift but more high-frequency noise. Lower values give smoother
* tracking but allow more gyro drift.
*
* Typical range: 0.01 (very smooth) to 0.5 (aggressive correction).
* Default 0.1 is a good general-purpose starting point.
*/
beta: number;
constructor(beta?: number);
/** Reset to identity orientation. */
reset(): void;
/**
* Incorporate one IMU sample.
*
* @param gx Gyroscope X (pitch) in **rad/s**
* @param gy Gyroscope Y (yaw) in **rad/s**
* @param gz Gyroscope Z (roll) in **rad/s**
* @param ax Accelerometer X (any consistent unit — normalized internally)
* @param ay Accelerometer Y
* @param az Accelerometer Z
* @param dt Time delta in **seconds** since last sample
*/
update(gx: number, gy: number, gz: number, ax: number, ay: number, az: number, dt: number): void;
}
//# sourceMappingURL=madgwick.d.ts.map