Integration of code (not working)
Dependencies: mpu9250_i2c biquadFilter PCA peakdetection Eigen
Revision 7:714b41918ab0, committed 2020-01-16
- Comitter:
- nikoletakuneva
- Date:
- Thu Jan 16 17:48:07 2020 +0000
- Parent:
- 6:4437975b9cf9
- Commit message:
- Final
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4437975b9cf9 -r 714b41918ab0 main.cpp --- a/main.cpp Sat Nov 30 10:35:57 2019 +0000 +++ b/main.cpp Thu Jan 16 17:48:07 2020 +0000 @@ -20,7 +20,6 @@ #include "platform/mbed_thread.h" #include "stats_report.h" #include "MPU9250.h" -//#include <Eigen/Dense.h> #include <iostream> #include <vector> #include <complex> @@ -74,7 +73,6 @@ t.start(callback(&_event_queue, &EventQueue::dispatch_forever)); } void update_step_count() { - //printf("updating step count %d\n\r", step_count); if (_ble.gap().getState().connected) { _ble.gattServer().write(step_count_state.getValueHandle(), (uint8_t *)&step_count, sizeof(int)); } @@ -83,7 +81,6 @@ private: /** Callback triggered when the ble initialization process has finished */ void on_init_complete(BLE::InitializationCompleteCallbackContext *params) { - //printf("on init complete\n\r"); if (params->error != BLE_ERROR_NONE) { print_error(params->error, "Ble initialization failed."); return; @@ -97,7 +94,6 @@ } void start_advertising() { - //printf("start advertising\n\r"); /* Create advertising parameters and payload */ ble::AdvertisingParameters adv_parameters( @@ -214,39 +210,27 @@ bqc.add(&mybq); - //vector<float> res_list; acc_new << 0,0,0; while (true) { - - //Blink LED and wait 1 seconds thread_sleep_for(SLEEP_TIME); //read and convert date mpu->ReadConvertAll(AccRead,GyroRead,TempRead); AccRead[0]= AccRead[0]/1000; AccRead[1]= AccRead[1]/1000; AccRead[2]= AccRead[2]/1000; - printf("acc value is (%f,%f,%f).\n\r",AccRead[0],AccRead[1],AccRead[2]); - //printf("gyro value is (%f,%f,%f).\n\r",GyroRead[0],GyroRead[1],GyroRead[2]); - //printf("temp value is %f.\n\r",TempRead[0]); //append new data to matrix acc_raw //adding the columns acc_previous = acc_new; acc_new << AccRead[0],AccRead[1],AccRead[2]; - //cout << "acc_previous:"<<acc_previous<<"\n\r"; - //printf("\n\r"); acc_raw.conservativeResize(acc_raw.rows(), acc_raw.cols()+1); acc_raw.col(acc_raw.cols()-1) = acc_new; - //////cout << "acc_raw:" << acc_raw << endl; if(number % 10 ==2) { if(number > 2) { - //cout << "acc_raw"<< acc_raw << "\n\r"; - //printf("\n\r"); - //run PCA MatrixXd X1=pca.featurnormail(acc_raw); pca.ComComputeCov(X1, C); @@ -256,24 +240,15 @@ MatrixXd res = -vec.rightCols(dim).transpose()*X1; //show the result after PCA - //////cout << "result" << res << endl; vector<float> res_list={}; - //printf("result of PCA size:%d\n\r",res.cols()); for(int i = 0; i < res.cols(); i++) { res_list.push_back(res(i)); - //res_smooth = bqc.step(res(i)); - //res_list.push_back(res_smooth); - //printf("result%d: %f\n\r",i,res_smooth); - //std::cout << "\t" << bqc.step( ) << std::endl; } int len = res_list.size(); - //printf("len of res:%d\n\r", len); numpeak = peak.findPeaks(res_list,len,threshold); - //printf("height in main: %f\n\r", threshold); step_count += numpeak; - //printf("num of step: %d\n\r", step_count); //clear the matrix to contain new data acc_raw.conservativeResize(3, 0);