Documentation
¶
Overview ¶
Package detector implements vibration detection, orientation tracking (Mahony AHRS), and experimental heartbeat (BCG) detection from IMU data.
Index ¶
Constants ¶
const SampleRate = 100
SampleRate is the expected input sample rate in Hz.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Detector ¶
type Detector struct {
SampleCount int
FS int
// Latest raw values
LatestRaw [3]float64
LatestMag float64
// Waveform history
Waveform *RingFloat
WaveformXYZ *RingVec3
STALTAActive [3]bool
STALTALatest [3]float64
STALTARings [3]*RingFloat
CUSUMVal float64
Kurtosis float64
Crest float64
RMS float64
Peak float64
MADSigma float64
// RMS trend
RMSTrend *RingFloat
// Events
Events []Event
// Gyro latest
GyroLatest [3]float64
// Mahony AHRS quaternion
Q [4]float64 // w, x, y, z
HRBPM float64
HRConf float64
HRValid bool
// Periodicity
Period float64
PeriodFreq float64
PeriodCV float64
PeriodSTD float64
PeriodValid bool
ACorrRing []float64
// contains filtered or unexported fields
}
Detector processes accelerometer and gyroscope data to detect vibrations, compute orientation, and estimate heartbeat.
func (*Detector) DetectHeartbeat ¶
func (d *Detector) DetectHeartbeat()
DetectHeartbeat uses autocorrelation of the bandpassed signal to estimate BPM.
func (*Detector) DetectPeriodicity ¶
func (d *Detector) DetectPeriodicity()
DetectPeriodicity computes autocorrelation to find periodic vibration patterns.
func (*Detector) GetOrientation ¶
func (d *Detector) GetOrientation() Orientation
GetOrientation returns the current Euler angles from the AHRS quaternion.
func (*Detector) Process ¶
Process ingests one accelerometer sample and returns the dynamic magnitude.
func (*Detector) ProcessGyro ¶
ProcessGyro updates the latest gyroscope reading (deg/s).
type Event ¶
type Event struct {
Time time.Time
Severity string
Symbol string
Label string
Amplitude float64
Sources []string
Bands []string
}
Event represents a detected vibration event.
type Orientation ¶
type Orientation struct {
Roll, Pitch, Yaw float64 // degrees
}
Orientation holds Euler angles derived from quaternion AHRS.
type RingFloat ¶
type RingFloat struct {
// contains filtered or unexported fields
}
RingFloat is a fixed-capacity ring buffer for float64 values.
func NewRingFloat ¶
NewRingFloat creates a RingFloat with the given capacity.