Luke Plummer
/
JesusLizard
lizard leg trajectory pd control code for 2.s994
Revision 4:af5440b3af19, committed 2013-12-01
- Comitter:
- lukeplummer
- Date:
- Sun Dec 01 17:33:41 2013 +0000
- Parent:
- 3:6f00e4876cab
- Child:
- 5:9f31c55179d7
- Commit message:
- added filewriting
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 25 21:54:30 2013 +0000 +++ b/main.cpp Sun Dec 01 17:33:41 2013 +0000 @@ -22,6 +22,8 @@ Ticker ctrlTicker; // creates an instance of the ticker class, which can be used for running functions at a specified frequency. Ticker trajTicker; Serial mySerial(USBTX, USBRX); // create a serial connection to the computer over the tx/rx pins +LocalFileSystem local("local"); +FILE *fp = fopen("/local/out.csv", "w"); float a1_t0 = 0; //motor angle 1 from previous time step float a1_t1 = 0; //motor angle 1 from current time step @@ -93,6 +95,16 @@ } } +void fileWriter(float in1, float in2) { + n++; + if(n<3000){ + fprintf(fp, "%f,%f\n",in1, in2); + } + else{ + fclose(fp); + } +} + int main() { mDir1_A = 1; mDir1_B = 0; @@ -108,8 +120,12 @@ trajTicker.attach(setTraj, 1/fTraj); ctrlTicker.attach(pdControl, 1/fPWM); //while (!done) {mySerial.printf("targets 1: %f 2: %f \n\r", aD[0], aD[1]);} - while (!done) {mySerial.printf("motor 2: %f \n\r", a2_t1);} + while (!done) { + mySerial.printf("motor 2: %f \n\r", a2_t1); + fprintf(fp, "%f, %f\n",a1_t1, a2_t1); + } mySerial.printf("Done\n\r"); + fclose(fp); mDir1_A = 0; mDir1_B = 0; mDir2_A = 0;