Skip to content

Commit

Permalink
remove kalman local test; reset the modification of pedometer
Browse files Browse the repository at this point in the history
Addresses #647.
  • Loading branch information
PeiMu committed Mar 19, 2023
1 parent 115ed4a commit 4e753a1
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 106 deletions.
46 changes: 46 additions & 0 deletions analysis/statistics/4e417db3d57f23b181521f46393853c150f07026.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

changeset: 1459:4e417db3d57f23b181521f46393853c150f07026
char kNewtonVersion[] = "0.3-alpha-1459 (4e417db3d57f23b181521f46393853c150f07026) (build 03-15-2023-16:[email protected]_64)";
\n./src/noisy/noisy-linux-EN -O0 applications/noisy/helloWorld.n -s
\n./src/newton/newton-linux-EN -v 0 -eP applications/newton/invariants/ViolinWithTemperatureDependence-pigroups.nt

Informational Report:
---------------------
Invariant "ViolinWithTemperatureDependenceForPiGroups" has 2 unique kernels, each with 2 column(s)...

Kernel 0 is a valid kernel:

1 1
-0.5 -0
1 0
0.5 0
0 -1
-0 -1


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 0, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^( 0) P5^(-0)

Pi group 0, Pi 1 is: P0^(-0) P1^( 1) P2^( 0) P3^( 0) P4^(-1) P5^(-1)


Kernel 1 is a valid kernel:

1 0
-0.5 1
1 -2
0.5 -1
-0 -2
0 -2


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 1, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^(-0) P5^( 0)

Pi group 1, Pi 1 is: P0^( 1) P1^( 0) P2^(-1) P3^(-2) P4^(-2) P5^(-2)




3 changes: 0 additions & 3 deletions applications/newton/llvm-ir/c-files/kalman_filter.c

This file was deleted.

66 changes: 0 additions & 66 deletions applications/newton/llvm-ir/kalman_filter.c

This file was deleted.

57 changes: 21 additions & 36 deletions applications/newton/llvm-ir/pedometer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@
#include <printf.h>
#include <string.h>
#include <math.h>
#include "../CHStone_test/soft_float_api/soft_float_api.cpp"

#define SAMPLES_PER_MEASUREMENT 4
#define DC_SAMPLES_FACTOR (12)
#define PRECISION (0.5)

typedef float bmx055xAcceleration;
typedef float bmx055yAcceleration;
typedef float bmx055zAcceleration;

/*
Accelerometer samples at 400 Hz.
Humans walk with frequency 1 Hz to 5 Hz.
Expand Down Expand Up @@ -99,10 +102,6 @@ int main(int argc, char *argv[])
float yDCSamples[DC_SAMPLES_FACTOR * SAMPLES_PER_MEASUREMENT];
float zDCSamples[DC_SAMPLES_FACTOR * SAMPLES_PER_MEASUREMENT];

typedef float bmx055xAcceleration;
typedef float bmx055yAcceleration;
typedef float bmx055zAcceleration;

bmx055xAcceleration acc_x = 3.4;
bmx055yAcceleration acc_y = 3.4;
bmx055zAcceleration acc_z = 3.4;
Expand Down Expand Up @@ -168,35 +167,26 @@ int main(int argc, char *argv[])
fprintf(stderr, "Unable to read row. Possible problem with input data format.\n");
}
// printf("%G,%G,%G,%G\n", timestampSamples[i], xSamples[i], ySamples[i], zSamples[i]);
// timestampAccum += timestamp;
timestampAccum = float64_add(timestampAccum, timestamp);
samplesTaken++;
timestampAccum += timestamp;
samplesTaken++;

/*
Smoothen (Figure 4)
*/
// acc_x += xSamples[i];
acc_x = float64_add(acc_x, xSamples[i]);
// acc_y += ySamples[i];
acc_y = float64_add(acc_y, ySamples[i]);
// acc_z += zSamples[i];
acc_z = float64_add(acc_z, zSamples[i]);
acc_x += xSamples[i];
acc_y += ySamples[i];
acc_z += zSamples[i];
timestamp = timestampSamples[i];
}

// acc_x /= SAMPLES_PER_MEASUREMENT;
acc_x = float64_div(acc_x, SAMPLES_PER_MEASUREMENT);
// acc_y /= SAMPLES_PER_MEASUREMENT;
acc_y = float64_div(acc_y, SAMPLES_PER_MEASUREMENT);
// acc_z /= SAMPLES_PER_MEASUREMENT;
acc_z = float64_div(acc_z, SAMPLES_PER_MEASUREMENT);
// acc_x /= SAMPLES_PER_MEASUREMENT;
// acc_y /= SAMPLES_PER_MEASUREMENT;
// acc_z /= SAMPLES_PER_MEASUREMENT;

/*
Optionally combine all axes together.
*/
// acc_z = acc_z + acc_x + acc_y;
acc_z = float64_add(acc_z, acc_x);
acc_z = float64_add(acc_z, acc_y);
// acc_z = acc_z + acc_x + acc_y;

/*
PROCESSING SECTION
Expand All @@ -218,9 +208,9 @@ int main(int argc, char *argv[])
Uncomment if every sensor measurement is a measurement.
See below.
*/
measurementNew_x = acc_x;
measurementNew_y = acc_y;
measurementNew_z = acc_z;
// measurementNew_x = acc_x;
// measurementNew_y = acc_y;
// measurementNew_z = acc_z;

/*
The next part essentially skips measurements that are not
Expand All @@ -236,7 +226,7 @@ int main(int argc, char *argv[])
/*
Check if change is significant
*/
if (fabsf(float64_add(acc_y, -measurementNew_z)) > PRECISION)
if (fabsf(acc_y - measurementNew_z) > PRECISION)
{
measurementNew_z = acc_y;
// printf("New measurement is %f.\n", measurementNew_z);
Expand Down Expand Up @@ -267,14 +257,11 @@ int main(int argc, char *argv[])
/*
Update threshold value for Z-axis every 30 measurements.
*/
// zRange = max_z - min_z;
zRange = float64_add(max_z, -min_z);
zRange = max_z - min_z;
// printf("zRange=%f\n", zRange);
if (measurementCount < 10 || measurementCount % 50)
{
// threshold_z = (max_z + min_z) / 2;
float tmp_z = float64_add(max_z, min_z);
threshold_z = float64_div(tmp_z, 2);
threshold_z = (max_z + min_z) / 2;

/*
"Reset" min and max so they change at next
Expand All @@ -290,10 +277,9 @@ int main(int argc, char *argv[])
/*
Deterministic steps.
*/
float tmp_time = float64_add(timestamp, -timestampPrevious);
if (measurementOld_z > measurementNew_z
&& threshold_z > measurementNew_z
&& tmp_time > 0.3
&& timestamp - timestampPrevious > 0.3
&& zRange > 2 && zRange < 8)
{
steps++;
Expand All @@ -302,8 +288,7 @@ int main(int argc, char *argv[])
// printf("Deterministic step registered at %f. Step count: %d.\n", timestamp, steps);
}

tmp_time = float64_add(timestamp, -timestampPrevious);
if (tmp_time > 2 && reset == 0)
if (timestamp - timestampPrevious > 2 && reset == 0)
{
/*
Finished a stride.
Expand Down
1 change: 0 additions & 1 deletion applications/newton/llvm-ir/performance_test/auto_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <vector>

const size_t iteration_num = 5;
const size_t result_num = 5;

struct perfData {
int64_t inst_count_avg;
Expand Down

0 comments on commit 4e753a1

Please sign in to comment.