Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ca5bd48

Browse files
Fix MPU6050 in Gesture classification example
1 parent 1779ad8 commit ca5bd48

File tree

12 files changed

+146
-315
lines changed

12 files changed

+146
-315
lines changed

‎.idea/workspace.xml‎

Lines changed: 41 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/MicromlGestureIdentificationExample/MicromlGestureIdentificationExample.ino‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
#include "imu.h"
2-
//#include "model.h"
1+
#include "imu_6050.h"
2+
#include "pca.h"
3+
#include "model.h"
34

45
#define NUM_SAMPLES 30
56
#define NUM_AXES 3
67
#define TRUNCATE 20
78
#define ACCEL_THRESHOLD 5
89
#define INTERVAL 30
910

10-
double baseline[NUM_AXES];
11-
double features[NUM_SAMPLES * NUM_AXES];
11+
float baseline[NUM_AXES];
12+
float features[NUM_SAMPLES * NUM_AXES];
13+
Eloquent::ML::Port::PCA pca;
14+
Eloquent::ML::Port::SVM clf;
1215

1316

1417
void setup() {
@@ -34,7 +37,7 @@ void loop() {
3437
recordIMU();
3538
printFeatures();
3639
// un-comment to run classification
37-
// classify();
40+
classify();
3841
delay(2000);
3942
}
4043

@@ -87,7 +90,7 @@ void recordIMU() {
8790
* Dump the feature vector to Serial monitor
8891
*/
8992
void printFeatures() {
90-
const uint16_t numFeatures = sizeof(features) / sizeof(double);
93+
const uint16_t numFeatures = sizeof(features) / sizeof(float);
9194

9295
for (int i = 0; i < numFeatures; i++) {
9396
Serial.print(features[i]);
@@ -99,6 +102,7 @@ void printFeatures() {
99102
*
100103
*/
101104
void classify() {
105+
pca.transform(features);
102106
Serial.print("Detected gesture: ");
103-
Serial.println(classIdxToName(predict(features)));
107+
Serial.println(clf.predictLabel(features));
104108
}

‎examples/MicromlGestureIdentificationExample/imu_6550.h‎ renamed to ‎examples/MicromlGestureIdentificationExample/imu_6050.h‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ void imu_setup() {
1111
}
1212

1313
void imu_read(float *ax, float *ay, float *az) {
14-
floatgx, gy, gz;
14+
int16_t_ax, _ay, _az, _gx, _gy, _gz;
1515

16-
imu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
17-
}
16+
imu.getMotion6(&_ax, &_ay, &_az, &_gx, &_gy, &_gz);
17+
18+
*ax = _ax;
19+
*ay = _ay;
20+
*az = _az;
21+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /