Dave Lu / Mbed 2 deprecated FYDP

Dependencies:   mbed

Fork of FYDP_Final2 by Dave Lu

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PaceDetector.cpp Source File

PaceDetector.cpp

00001 #include "PaceDetector.hpp"
00002 
00003 void PaceDetector::process(float time, float thigh, float shin) {
00004    kneeSmoother.insert(time, shin-thigh);
00005 
00006    if(atPeak()) {
00007       lastPeak = currentPeak;
00008       currentPeak = time;
00009       peakDetected = true;
00010    }
00011 
00012    lastSmoothKnee = smoothKnee;
00013    smoothKnee = kneeSmoother.get();
00014 
00015    if(lastDSmoothKnee > 0) {
00016       plusDSmoothKneeCount += 1;
00017    } else {
00018       plusDSmoothKneeCount = 0;
00019    }
00020    lastDSmoothKnee = dSmoothKnee;
00021    dSmoothKnee = smoothKnee-lastSmoothKnee;
00022 }
00023 
00024 bool PaceDetector::atPeak() {
00025    return
00026       plusDSmoothKneeCount > 4 &&
00027       lastDSmoothKnee > 0 &&
00028       dSmoothKnee < 0 &&
00029       !peakDetected;
00030 }
00031 
00032 float PaceDetector::pace() {
00033    if(currentPeak != -1 && lastPeak != -1) {
00034       return currentPeak - lastPeak;
00035    } else {
00036       return 1.0;
00037    }
00038 }
00039 
00040 void PaceDetector::lookForPeak() {
00041    peakDetected = false;
00042 }
00043