Dave Lu
/
FYDP
IMU and knee angle. No servo yet
Fork of FYDP_Final2 by
Control/PaceDetector.cpp
- Committer:
- tntmarket
- Date:
- 2015-03-25
- Revision:
- 11:425dff6a4af9
- Parent:
- 9:7a8fb72f9a93
File content as of revision 11:425dff6a4af9:
#include "PaceDetector.hpp" void PaceDetector::process(float time, float thigh, float shin) { kneeSmoother.insert(time, shin-thigh); if(atPeak()) { lastPeak = currentPeak; currentPeak = time; peakDetected = true; } lastSmoothKnee = smoothKnee; smoothKnee = kneeSmoother.get(); if(lastDSmoothKnee > 0) { plusDSmoothKneeCount += 1; } else { plusDSmoothKneeCount = 0; } lastDSmoothKnee = dSmoothKnee; dSmoothKnee = smoothKnee-lastSmoothKnee; } bool PaceDetector::atPeak() { return plusDSmoothKneeCount > 4 && lastDSmoothKnee > 0 && dSmoothKnee < 0 && !peakDetected; } float PaceDetector::pace() { if(currentPeak != -1 && lastPeak != -1) { return currentPeak - lastPeak; } else { return 1.0; } } void PaceDetector::lookForPeak() { peakDetected = false; }