-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
after SSH and SFTP into edison, moved files to github to publish.
- Loading branch information
0 parents
commit c9abbef
Showing
67 changed files
with
3,200 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CC=gcc | ||
LDFLAGS=-lmraa -lfann | ||
CFLAGS=-Wall | ||
SOURCES=collect_neural_net_data.c examine_sensor_data.c test_neural_network.c train_neural_net.c | ||
EXECUTABLES=$(SOURCES:.c=) | ||
|
||
all: collect_neural_net_data examine_sensor_data test_neural_network train_neural_net | ||
|
||
collect_neural_net_data: collect_neural_net_data.c | ||
$(CC) $(CFLAGS) -o collect_neural_net_data collect_neural_net_data.c $(LDFLAGS) | ||
|
||
examine_sensor_data: examine_sensor_data.c | ||
$(CC) $(CFLAGS) -o examine_sensor_data examine_sensor_data.c $(LDFLAGS) | ||
|
||
test_neural_network: test_neural_network.c | ||
$(CC) $(CFLAGS) -o test_neural_network test_neural_network.c $(LDFLAGS) | ||
|
||
train_neural_net: train_neural_net.c | ||
$(CC) $(CFLAGS) -o train_neural_net train_neural_net.c $(LDFLAGS) | ||
|
||
clean: | ||
rm -f collect_neural_net_data examine_sensor_data test_neural_network train_neural_net | ||
rm -f *~ | ||
rm -f TEST.net | ||
rm -f test_data.txt |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <mraa/aio.h> | ||
|
||
int main() | ||
{ | ||
|
||
int i, j, success_flag; | ||
int location; | ||
int output[5]; | ||
int temp0, temp1, temp2; | ||
float v0, v1, v2; | ||
uint16_t value0, value1, value2; | ||
mraa_aio_context lightsensor0, lightsensor1, lightsensor2; | ||
|
||
lightsensor0 = mraa_aio_init(0); | ||
lightsensor1 = mraa_aio_init(1); | ||
lightsensor2 = mraa_aio_init(2); | ||
|
||
// train data store to test_data.txt | ||
FILE *fp; | ||
fp = fopen("./test_data.txt", "wb"); | ||
fprintf(fp, "250\t3\t5\n"); | ||
|
||
// generate the test_data.txt output | ||
for (location = 0; location < 5; location++) { | ||
if (location != 4) { | ||
printf("Please position the Test Object to cast a shadow on region (%d).\n", location); | ||
printf("While you are casting this shadow and while the shadow is stable, please press the return key to capture data.\n"); | ||
} else { | ||
printf("Please do not cast any shadow on the sensors and press the return key\n"); | ||
} | ||
|
||
do { | ||
success_flag = getchar(); | ||
} while (success_flag != '\n'); | ||
|
||
for (i = 0; i < 5; i++) { | ||
output[i] = -1; | ||
} | ||
output[location] = 1; | ||
|
||
// collect 50 data per area | ||
for (j = 0; j < 50; j++) { | ||
|
||
temp0 = 0; | ||
temp1 = 0; | ||
temp2 = 0; | ||
|
||
// accurate the reading by using average of 50 readings | ||
for (i = 0; i < 50; i++) { | ||
temp0 += mraa_aio_read(lightsensor0); | ||
temp1 += mraa_aio_read(lightsensor1); | ||
temp2 += mraa_aio_read(lightsensor2); | ||
usleep(5000); | ||
} | ||
|
||
value0 = temp0 / 50; | ||
value1 = temp1 / 50; | ||
value2 = temp2 / 50; | ||
|
||
printf("%5d, %5d, %5d\n", value0, value1, value2); | ||
|
||
// transfer raw data within in the range 0 - 1, easy for FANN to train | ||
v0 = (float)value0 / 1000; | ||
v1 = (float)value1 / 1000; | ||
v2 = (float)value2 / 1000; | ||
|
||
//write input, output to test_data.txt as training file format | ||
fprintf(fp, "%f\t%f\t%f\n", v0, v1, v2); | ||
fprintf(fp, "%d\t%d\t%d\t%d\t%d\n", output[0], output[1], output[2], output[3], output[4]); | ||
} | ||
} | ||
|
||
// close everything | ||
fclose(fp); | ||
|
||
mraa_aio_close(lightsensor0); | ||
mraa_aio_close(lightsensor1); | ||
mraa_aio_close(lightsensor2); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <mraa/aio.h> | ||
|
||
int main() | ||
{ | ||
|
||
int i, j, success_flag; | ||
int location; | ||
int output[5]; | ||
int temp0, temp1, temp2; | ||
float v0, v1, v2; | ||
uint16_t value0, value1, value2; | ||
mraa_aio_context lightsensor0, lightsensor1, lightsensor2; | ||
|
||
lightsensor0 = mraa_aio_init(0); | ||
lightsensor1 = mraa_aio_init(1); | ||
lightsensor2 = mraa_aio_init(2); | ||
|
||
// train data store to test_data.txt | ||
FILE *fp; | ||
fp = fopen("./test_data.txt", "wb"); | ||
fprintf(fp, "250\t3\t5\n"); | ||
|
||
// generate the test_data.txt output | ||
for (location = 0; location < 5; location++) { | ||
if (location != 4) { | ||
printf("Please position the Test Object to cast a shadow on region (%d).\n", location); | ||
printf("While you are casting this shadow and while the shadow is stable, please press the return key to capture data.\n"); | ||
} else { | ||
printf("Please do not cast any shadow on the sensors and press the return key\n"); | ||
} | ||
|
||
do { | ||
success_flag = getchar(); | ||
} while (success_flag != '\n'); | ||
|
||
for (i = 0; i < 5; i++) { | ||
output[i] = -1; | ||
} | ||
output[location] = 1; | ||
|
||
// collect 50 data per area | ||
for (j = 0; j < 50; j++) { | ||
|
||
temp0 = 0; | ||
temp1 = 0; | ||
temp2 = 0; | ||
|
||
// accurate the reading by using average of 50 readings | ||
for (i = 0; i < 50; i++) { | ||
temp0 += mraa_aio_read(lightsensor0); | ||
temp1 += mraa_aio_read(lightsensor1); | ||
temp2 += mraa_aio_read(lightsensor2); | ||
usleep(5000); | ||
} | ||
|
||
value0 = temp0 / 50; | ||
value1 = temp1 / 50; | ||
value2 = temp2 / 50; | ||
|
||
printf("%5d, %5d, %5d\n", value0, value1, value2); | ||
|
||
// transfer raw data within in the range 0 - 1, easy for FANN to train | ||
v0 = (float)value0 / 1000; | ||
v1 = (float)value1 / 1000; | ||
v2 = (float)value2 / 1000; | ||
|
||
//write input, output to test_data.txt as training file format | ||
fprintf(fp, "%f\t%f\t%f\n", v0, v1, v2); | ||
fprintf(fp, "%d\t%d\t%d\t%d\t%d\n", output[0], output[1], output[2], output[3], output[4]); | ||
} | ||
} | ||
|
||
// close everything | ||
fclose(fp); | ||
|
||
mraa_aio_close(lightsensor0); | ||
mraa_aio_close(lightsensor1); | ||
mraa_aio_close(lightsensor2); | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <mraa/aio.h> | ||
//this one gives us the avg sensor values so we have a good idea on how to scale it down to a value between 0-1 | ||
int main() | ||
{ | ||
int i; | ||
int temp0, temp1, temp2; | ||
uint16_t value0, value1, value2; | ||
mraa_aio_context lightsensor0, lightsensor1, lightsensor2; | ||
//important to notice that the light sensors start off around 700 and should range from 100-500 at some point here | ||
lightsensor0 = mraa_aio_init(0); | ||
lightsensor1 = mraa_aio_init(1); | ||
lightsensor2 = mraa_aio_init(2); | ||
|
||
while(1) { | ||
|
||
temp0 = 0; | ||
temp1 = 0; | ||
temp2 = 0; | ||
|
||
for (i = 0; i < 50; i++) { | ||
temp0 += mraa_aio_read(lightsensor0); | ||
temp1 += mraa_aio_read(lightsensor1); | ||
temp2 += mraa_aio_read(lightsensor2); | ||
usleep(5000); | ||
} | ||
|
||
value0 = temp0 / 50; | ||
value1 = temp1 / 50; | ||
value2 = temp2 / 50; | ||
|
||
printf("Light sensor 0: %5d, Light sensor 1: %5d, Light sensor 2: %5d\n", value0, value1, value2); | ||
|
||
usleep(250000); | ||
} | ||
|
||
mraa_aio_close(lightsensor0); | ||
mraa_aio_close(lightsensor1); | ||
mraa_aio_close(lightsensor2); | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <mraa/aio.h> | ||
//this one gives us the avg sensor values so we have a good idea on how to scale it down to a value between 0-1 | ||
int main() | ||
{ | ||
int i; | ||
int temp0, temp1, temp2; | ||
uint16_t value0, value1, value2; | ||
mraa_aio_context lightsensor0, lightsensor1, lightsensor2; | ||
|
||
lightsensor0 = mraa_aio_init(0); | ||
lightsensor1 = mraa_aio_init(1); | ||
lightsensor2 = mraa_aio_init(2); | ||
|
||
while(1) { | ||
|
||
temp0 = 0; | ||
temp1 = 0; | ||
temp2 = 0; | ||
|
||
for (i = 0; i < 50; i++) { | ||
temp0 += mraa_aio_read(lightsensor0); | ||
temp1 += mraa_aio_read(lightsensor1); | ||
temp2 += mraa_aio_read(lightsensor2); | ||
usleep(5000); | ||
} | ||
|
||
value0 = temp0 / 50; | ||
value1 = temp1 / 50; | ||
value2 = temp2 / 50; | ||
|
||
printf("Light sensor 0: %5d, Light sensor 1: %5d, Light sensor 2: %5d\n", value0, value1, value2); | ||
|
||
usleep(250000); | ||
} | ||
|
||
mraa_aio_close(lightsensor0); | ||
mraa_aio_close(lightsensor1); | ||
mraa_aio_close(lightsensor2); | ||
|
||
return 0; | ||
} | ||
|
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <unistd.h> | ||
#include <mraa/aio.h> | ||
#include <stdio.h> | ||
#include "floatfann.h" | ||
//goal is to input 6 values , we have an array of 6 values as input | ||
//next step is to have an array output of 3 values, 1 for each thing we classify and ultimate goal is to see which one is closest to the correct classification of a certain type of motion. | ||
int main() | ||
{ | ||
int i; | ||
int temp0, temp1, temp2,temp3, temp4, temp5, location; | ||
uint16_t value0, value1, value2, value3, value4, value5; | ||
float max; // | ||
fann_type *calc_out;//object | ||
fann_type input[6];//#of inputs | ||
struct fann *ann; | ||
mraa_aio_context lightsensor0, lightsensor1, lightsensor2; | ||
|
||
ann = fann_create_from_file("TEST.net"); | ||
|
||
lightsensor0 = mraa_aio_init(0); | ||
lightsensor1 = mraa_aio_init(1); | ||
lightsensor2 = mraa_aio_init(2); | ||
|
||
while (1) { | ||
temp0 = 0; | ||
temp1 = 0; | ||
temp2 = 0; | ||
max = -100; | ||
|
||
for (i = 0; i < 50; i++) { | ||
temp0 += mraa_aio_read(lightsensor0); | ||
temp1 += mraa_aio_read(lightsensor1); | ||
temp2 += mraa_aio_read(lightsensor2); | ||
usleep(10000); | ||
} | ||
|
||
value0 = temp0 / 50; | ||
value1 = temp1 / 50; | ||
value2 = temp2 / 50; | ||
|
||
input[0] = (float) value0 / 1000; | ||
input[1] = (float) value1 / 1000; | ||
input[2] = (float) value2 / 1000; | ||
calc_out = fann_run(ann, input); | ||
|
||
for (i = 0; i < 5; i++) { | ||
if (calc_out[i] > max) { //if the location is a specific input of brightness at this location, we "max" and say that is the location, for ever change in max. In other words, max is our way of identifying where our location is in the light sensor case, for the weight lifting, max will determine which type of motion we are closer to: curl or press. | ||
max = calc_out[i]; | ||
location = i; | ||
} | ||
} | ||
//find max value for the light sensors | ||
printf("Light sensor values: %d, %d, %d -> location is %d\n", value0, value1, value2, location); | ||
sleep(1); | ||
} | ||
return 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <unistd.h> | ||
#include <mraa/aio.h> | ||
#include <stdio.h> | ||
#include "floatfann.h" | ||
//goal is to input 6 values , we have an array of 6 values as input | ||
//next step is to have an array output of 3 values, 1 for each thing we classify and ultimate goal is to see which one is closest to the correct classification of a certain type of motion. | ||
int main() | ||
{ | ||
int i; | ||
int temp0, temp1, temp2,temp3, temp4, temp5, location; | ||
uint16_t value0, value1, value2, value3, value4, value5; | ||
float max; // | ||
fann_type *calc_out;//object | ||
fann_type input[6];//#of inputs | ||
struct fann *ann; | ||
mraa_aio_context lightsensor0, lightsensor1, lightsensor2; | ||
|
||
ann = fann_create_from_file("TEST.net"); | ||
|
||
lightsensor0 = mraa_aio_init(0); | ||
lightsensor1 = mraa_aio_init(1); | ||
lightsensor2 = mraa_aio_init(2); | ||
|
||
while (1) { | ||
temp0 = 0; | ||
temp1 = 0; | ||
temp2 = 0; | ||
max = -100; | ||
|
||
for (i = 0; i < 50; i++) { | ||
temp0 += mraa_aio_read(lightsensor0); | ||
temp1 += mraa_aio_read(lightsensor1); | ||
temp2 += mraa_aio_read(lightsensor2); | ||
usleep(10000); | ||
} | ||
|
||
value0 = temp0 / 50; | ||
value1 = temp1 / 50; | ||
value2 = temp2 / 50; | ||
|
||
input[0] = (float) value0 / 1000; | ||
input[1] = (float) value1 / 1000; | ||
input[2] = (float) value2 / 1000; | ||
calc_out = fann_run(ann, input); | ||
|
||
for (i = 0; i < 5; i++) { | ||
if (calc_out[i] > max) { //if the location is a specific input of brightness at this location, we "max" and say that is the location, for ever change in max. In other words, max is our way of identifying where our location is in the light sensor case, for the weight lifting, max will determine which type of motion we are closer to: curl or press. | ||
max = calc_out[i]; | ||
location = i; | ||
} | ||
} | ||
//find max value for the light sensors | ||
printf("Light sensor values: %d, %d, %d -> location is %d\n", value0, value1, value2, location); | ||
sleep(1); | ||
} | ||
return 0; | ||
|
Empty file.
Binary file not shown.
Oops, something went wrong.