For flywheel rig. Interfaces with matlab flywheel interface. 2.007 MIT Biomimetics Robotics Lab. Sangbae Kim. Ben Katz.
Diff: main.cpp
- Revision:
- 8:6ae3c3cd7f55
- Parent:
- 7:1726c40ad774
- Child:
- 9:d8d2778bfbfd
--- a/main.cpp Fri Feb 10 00:04:57 2017 +0000 +++ b/main.cpp Tue Feb 14 20:36:07 2017 +0000 @@ -86,8 +86,8 @@ double publishFrequency = 0.05; /* seconds. rate to publish to matlab */ double samplesPerPublish = (int)(publishFrequency/updatePeriod); /*this improves time response of filter and maintains smoothness*/ int publishCounter = 1; - double filterRatio = 0.045; - double currentFilterRatio = 0.03; + double filterRatio = 0.07; + double currentFilterRatio = 0.035; float currentSensorOffset = 0; int i; for(i=1;i<301;i++){ currentSensorOffset += currentSense.read(); } currentSensorOffset = currentSensorOffset*VREF/300; @@ -128,6 +128,10 @@ while(1) { + // currentSensorOffset = 0; i = 0; TODO: this is not working +// for(i=1;i<201;i++){ currentSensorOffset += currentSense.read(); } //TODO: watch out this could take some time, but this should make things better! +// currentSensorOffset = currentSensorOffset*VREF/300; + green = false; wait(updatePeriod); start = end; @@ -153,8 +157,8 @@ } } if(publishCounter == samplesPerPublish) { - printf("%+8f,%+8f,%+8f,%+8f\n", currentSensed/currentSensorOutputRatio, pwm.read(), velocity, ((double)(end-absoluteStart)/CLOCKS_PER_SEC)); - publishCounter = 1; + printf("%+9.5f,%+8.4f,%+9.5f,%+8.2f\n", currentSensed/currentSensorOutputRatio, pwm.read(), velocity, ((double)(end-absoluteStart)/CLOCKS_PER_SEC)); + publishCounter = 1; // good for 1000 seconds. and room to grow one power of 10 on all other inputs. } publishCounter++;