UniversalJoint::UniversalJoint(char* axes){ readAxes(axes); minAngleA = 0; maxAngleA = 0; minAngleB = 0; maxAngleB = 0; }
int main() { SystemInit(); initSystick(); initAccelerometer(); initLeds(); AccelerometerDataStruct dat; uint32_t lastTime = 0; while(1) { if (millisecondCounter > lastTime + 100) { readAxes(&dat); // read sensor and store into `dat' setbuf(stdout, NULL); printf("X: %d Y: %d Z: %d\n", dat.X, dat.Y, dat.Z); // the member variables for each direction lastTime = millisecondCounter; // Add extra logic here to light LEDs based on orientation of the board if(dat.X<-500){ GPIOD->BSRRL|=(1<<12); GPIOD->BSRRH|=(1<<13); GPIOD->BSRRH|=(1<<14); GPIOD->BSRRH|=(1<<15); } if(dat.Y<-500){ GPIOD->BSRRL|=(1<<15); GPIOD->BSRRH|=(1<<12); GPIOD->BSRRH|=(1<<13); GPIOD->BSRRH|=(1<<14); } if(dat.Y>500){ GPIOD->BSRRL|=(1<<13); GPIOD->BSRRH|=(1<<12); GPIOD->BSRRH|=(1<<14); GPIOD->BSRRH|=(1<<15); } if(dat.X>500){ GPIOD->BSRRL|=(1<<14); GPIOD->BSRRH|=(1<<12); GPIOD->BSRRH|=(1<<13); GPIOD->BSRRH|=(1<<15); } } } }
BallInSocketJoint::BallInSocketJoint(char* axes){ readAxes(axes); }
int CorrAxesCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } /*************************************************************************************/ // use smart distancing to get right sharedRabund and convert to relabund if needed // /************************************************************************************/ if (sharedfile != "") { InputData* input = new InputData(sharedfile, "sharedfile"); getSharedFloat(input); delete input; if (m->control_pressed) { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } return 0; } if (lookupFloat[0] == NULL) { m->mothurOut("[ERROR] reading relabund file."); m->mothurOutEndLine(); return 0; } }else if (relabundfile != "") { InputData* input = new InputData(relabundfile, "relabund"); getSharedFloat(input); delete input; if (m->control_pressed) { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } return 0; } if (lookupFloat[0] == NULL) { m->mothurOut("[ERROR] reading relabund file."); m->mothurOutEndLine(); return 0; } }else if (metadatafile != "") { getMetadata(); //reads metadata file and store in lookupFloat, saves column headings in metadataLabels for later if (m->control_pressed) { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } return 0; } if (lookupFloat[0] == NULL) { m->mothurOut("[ERROR] reading metadata file."); m->mothurOutEndLine(); return 0; } if (pickedGroups) { eliminateZeroOTUS(lookupFloat); } }else { m->mothurOut("[ERROR]: no file given."); m->mothurOutEndLine(); return 0; } if (m->control_pressed) { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } return 0; } //this is for a sanity check to make sure the axes file and shared file match for (int i = 0; i < lookupFloat.size(); i++) { names.insert(lookupFloat[i]->getGroup()); } /*************************************************************************************/ // read axes file and check for file mismatches with shared or relabund file // /************************************************************************************/ //read axes file map<string, vector<float> > axes = readAxes(); if (m->control_pressed) { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } return 0; } //sanity check, the read only adds groups that are in the shared or relabund file, but we want to make sure the axes file isn't missing anyone if (axes.size() != lookupFloat.size()) { map<string, vector<float> >::iterator it; for (int i = 0; i < lookupFloat.size(); i++) { it = axes.find(lookupFloat[i]->getGroup()); if (it == axes.end()) { m->mothurOut(lookupFloat[i]->getGroup() + " is in your shared of relabund file but not in your axes file, please correct."); m->mothurOutEndLine(); } } m->control_pressed = true; } if (m->control_pressed) { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } return 0; } /*************************************************************************************/ // calc the r values // /************************************************************************************/ string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + method + ".corr.axes"; outputNames.push_back(outputFileName); outputTypes["corr.axes"].push_back(outputFileName); ofstream out; m->openOutputFile(outputFileName, out); out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint); //output headings if (metadatafile == "") { out << "OTU"; } else { out << "Feature"; } for (int i = 0; i < numaxes; i++) { out << '\t' << "axis" << (i+1) << "\tp-value"; } out << "\tlength" << endl; if (method == "pearson") { calcPearson(axes, out); } else if (method == "spearman") { calcSpearman(axes, out); } else if (method == "kendall") { calcKendall(axes, out); } else { m->mothurOut("[ERROR]: Invalid method."); m->mothurOutEndLine(); } out.close(); for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } if (m->control_pressed) { return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); return 0; } catch(exception& e) { m->errorOut(e, "CorrAxesCommand", "execute"); exit(1); } }