Compare commits
No commits in common. "6b9de5f457be5917e02b610544af425eb846ce6f" and "1c7d7edaaed0245806ce2b0f5538935709632a03" have entirely different histories.
6b9de5f457
...
1c7d7edaae
|
@ -19,7 +19,9 @@ void averageCalculation(long **p, double averageArray[])
|
||||||
averageArray[i] = 0;
|
averageArray[i] = 0;
|
||||||
while (j < nRowRawData)
|
while (j < nRowRawData)
|
||||||
{
|
{
|
||||||
|
//printf("pij = %ld\n", p[i][j]);
|
||||||
averageArray[i - 1] += (double)p[i][j];
|
averageArray[i - 1] += (double)p[i][j];
|
||||||
|
// printf("%f , %ld\n", averageArray[i], p[i][j]);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
averageArray[i] /= nRowRawData;
|
averageArray[i] /= nRowRawData;
|
||||||
|
|
|
@ -1,29 +1,24 @@
|
||||||
#include "fileGestion.h"
|
#include "fileGestion.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief function that delete nRow lign in the beginning of the file rawData.csv . This function is necessary to not deal with the same ligns over and over
|
* @brief function that delete nRow lign in the beginning of the file rawData.csv . This function is necessary to not deal with the same ligns over and over
|
||||||
*
|
*
|
||||||
* @param nRow number of lign in the beginning of the file rawData.csv that has to be delete
|
* @param nRow number of lign in the beginning of the file rawData.csv that has to be delete
|
||||||
*/
|
*/
|
||||||
void clearRawData(int nRow)
|
void clearRawData(int nRow){
|
||||||
{
|
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
FILE *f = fopen("newFile.csv", "w+");
|
FILE *f = fopen("newFile.csv","w+");
|
||||||
FILE *g = fopen("rawData.csv", "r");
|
FILE *g = fopen("rawData.csv","r");
|
||||||
for (int i = 0; i < nRow; i++)
|
for(int i = 0; i < nRow; i++){ //first the program read the first nRow ligns of the csv file but do nothing
|
||||||
{ // first the program read the first nRow ligns of the csv file but do nothing
|
fgets(buffer , sizeof buffer , g);
|
||||||
fgets(buffer, sizeof buffer, g);
|
|
||||||
}
|
}
|
||||||
while (1)
|
while(1){ //then, till the end of the csv file it copy the lign to a new csv : newFile.csv
|
||||||
{ // then, till the end of the csv file it copy the lign to a new csv : newFile.csv
|
if(!fgets(buffer,sizeof buffer , g)) break;
|
||||||
if (!fgets(buffer, sizeof buffer, g))
|
fprintf(f,"%s",buffer);
|
||||||
break;
|
|
||||||
fprintf(f, "%s", buffer);
|
|
||||||
}
|
}
|
||||||
remove("rawData.csv");
|
remove("rawData.csv"); rename("newFile.csv", "rawData.csv"); //finally we remove the original file and rename the new one to replace rawData.csv
|
||||||
rename("newFile.csv", "rawData.csv"); // finally we remove the original file and rename the new one to replace rawData.csv
|
fclose(f); fclose(g);
|
||||||
fclose(f);
|
|
||||||
fclose(g);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief use to write one lign in the file "fileName"
|
* @brief use to write one lign in the file "fileName"
|
||||||
|
@ -31,17 +26,12 @@ void clearRawData(int nRow)
|
||||||
* @param array array that contaign all the values to write in the file
|
* @param array array that contaign all the values to write in the file
|
||||||
* @param nCol size of the array (correspond to the number of captor used)
|
* @param nCol size of the array (correspond to the number of captor used)
|
||||||
*/
|
*/
|
||||||
void appendDataInFile(char *fileName, double array[], int nCol)
|
void appendDataInFile(char* fileName , double array[], int nCol){
|
||||||
{
|
FILE *f = fopen(fileName,"a+");
|
||||||
FILE *f = fopen(fileName, "a+");
|
for(int i = 0 ; i < nCol ; i++){
|
||||||
for (int i = 0; i < nCol; i++)
|
if( i < nCol-1){
|
||||||
{
|
|
||||||
if (i < nCol - 1)
|
|
||||||
{
|
|
||||||
fprintf(f, "%f , ", array[i]);
|
fprintf(f, "%f , ", array[i]);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(f, "%f\n", array[i]);
|
fprintf(f, "%f\n", array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,6 @@ void printArrayData(long **p)
|
||||||
}
|
}
|
||||||
void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
|
void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
int i = 0, j;
|
|
||||||
=======
|
|
||||||
>>>>>>> 1c7d7edaaed0245806ce2b0f5538935709632a03
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
size_t bufsize = 200;
|
size_t bufsize = 200;
|
||||||
buffer = (char *)malloc(bufsize * sizeof(char));
|
buffer = (char *)malloc(bufsize * sizeof(char));
|
||||||
|
@ -53,131 +49,20 @@ void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
|
||||||
|
|
||||||
FILE *f = fopen(rawDataFileName, "r");
|
FILE *f = fopen(rawDataFileName, "r");
|
||||||
|
|
||||||
long t, c1, c2, c3, c4, c5, c6, c7, c8;
|
|
||||||
switch (M)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
while (fscanf(f, "%ld,%ld[^\n] ", &t, &c1) != EOF)
|
|
||||||
{
|
|
||||||
p[i][0] = t;
|
|
||||||
p[i][1] = c1;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
while (fscanf(f, "%ld,%ld,%ld[^\n] ", &t, &c1, &c2) != EOF)
|
|
||||||
{
|
|
||||||
p[i][0] = t;
|
|
||||||
p[i][1] = c1;
|
|
||||||
p[i][2] = c2;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
while (fscanf(f, "%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3) != EOF)
|
|
||||||
{
|
|
||||||
p[i][0] = t;
|
|
||||||
p[i][1] = c1;
|
|
||||||
p[i][2] = c2;
|
|
||||||
p[i][3] = c3;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4) != EOF)
|
|
||||||
{
|
|
||||||
p[i][0] = t;
|
|
||||||
p[i][1] = c1;
|
|
||||||
p[i][2] = c2;
|
|
||||||
p[i][3] = c3;
|
|
||||||
p[i][4] = c4;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4, &c5) != EOF)
|
|
||||||
{
|
|
||||||
p[i][0] = t;
|
|
||||||
p[i][1] = c1;
|
|
||||||
p[i][2] = c2;
|
|
||||||
p[i][3] = c3;
|
|
||||||
p[i][4] = c4;
|
|
||||||
p[i][5] = c5;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4, &c5, &c6) != EOF)
|
|
||||||
{
|
|
||||||
p[i][0] = t;
|
|
||||||
p[i][1] = c1;
|
|
||||||
p[i][2] = c2;
|
|
||||||
p[i][3] = c3;
|
|
||||||
p[i][4] = c4;
|
|
||||||
p[i][5] = c5;
|
|
||||||
p[i][6] = c6;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4, &c5, &c6, &c7) != EOF)
|
|
||||||
{
|
|
||||||
p[i][0] = t;
|
|
||||||
p[i][1] = c1;
|
|
||||||
p[i][2] = c2;
|
|
||||||
p[i][3] = c3;
|
|
||||||
p[i][4] = c4;
|
|
||||||
p[i][5] = c5;
|
|
||||||
p[i][6] = c6;
|
|
||||||
p[i][7] = c7;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4, &c5, &c6, &c7, &c8) != EOF)
|
|
||||||
{
|
|
||||||
p[i][0] = t;
|
|
||||||
p[i][1] = c1;
|
|
||||||
p[i][2] = c2;
|
|
||||||
p[i][3] = c3;
|
|
||||||
p[i][4] = c4;
|
|
||||||
p[i][5] = c5;
|
|
||||||
p[i][6] = c6;
|
|
||||||
p[i][7] = c7;
|
|
||||||
p[i][8] = c8;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("bad column size -> time + nbr captor\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/************** Debug part **************/
|
|
||||||
// for (int ii = 0; ii < nRowRawData; ii++)
|
|
||||||
// {
|
|
||||||
// for (int y = 0; y < nCol; y++)
|
|
||||||
// {
|
|
||||||
// printf("%ld,", p[ii][y]);
|
|
||||||
// if (y == nCol - 1)
|
|
||||||
// printf("lol\n");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief print all the element of a bidimensionnal array p of shape : N x M
|
|
||||||
*/
|
|
||||||
void printArrayData(long **p, int N, int M)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < N; i++)
|
for (int i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
printf("line n°%d : ", i);
|
long t, c1, c2, c3;
|
||||||
for (int j = 0; j < M; j++)
|
while (fscanf(f, "%ld,%ld,%ld,%ld\n", &t, &c1, &c2, &c3) != EOF)
|
||||||
{
|
{ // séparation valeur par virgule initiale : csv
|
||||||
printf("%ld , ", p[i][j]);
|
//printf("%ld,%ld,%ld,%ld\n", t, c1, c2, c3);
|
||||||
if (j == (M - 1))
|
p[i][0] = t;
|
||||||
printf("\n");
|
p[i][1] = c1;
|
||||||
|
p[i][2] = c2;
|
||||||
|
p[i][3] = c3;
|
||||||
|
}
|
||||||
|
printf("%ld,%ld,%ld,%ld,\n",p[0][0],p[0][1],p[0][2],p[0][3]);
|
||||||
|
for(int j = 0; j < nCol; j++){
|
||||||
|
printf("p[%d][%d] : %ld\n",i,j,p[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printArrayData(p);
|
printArrayData(p);
|
||||||
|
|
|
@ -104,7 +104,7 @@ void *threadCalculGrowthRate(void *vargp)
|
||||||
powerFunction(fileName, dataLignPw);
|
powerFunction(fileName, dataLignPw);
|
||||||
averageFunction(fileName, dataLignAv);
|
averageFunction(fileName, dataLignAv);
|
||||||
growthRateFunction(dataLignPw, "growthRatePw.csv");
|
growthRateFunction(dataLignPw, "growthRatePw.csv");
|
||||||
growthRateFunction(dataLignAv, "growthRateAv.csv");
|
growthRateFunction(dataLignPw, "growthRateAv.csv");
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -126,7 +126,7 @@ void *threadCalculGrowthRate(void *vargp)
|
||||||
growthRateFunction(dataLignPw, "growthRatePw.csv");
|
growthRateFunction(dataLignPw, "growthRatePw.csv");
|
||||||
growthRateFunction(dataLignPw, "growthRateAv.csv");
|
growthRateFunction(dataLignPw, "growthRateAv.csv");
|
||||||
}
|
}
|
||||||
remove(fileName);
|
// remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -176,7 +176,7 @@ bool writeOneRawData(FILE *rawDataFile)
|
||||||
}
|
}
|
||||||
cptData++;
|
cptData++;
|
||||||
|
|
||||||
/************** simul freq here **************/
|
// simul freq here
|
||||||
// struct timespec ts;
|
// struct timespec ts;
|
||||||
// ts.tv_sec = 0;
|
// ts.tv_sec = 0;
|
||||||
// ts.tv_nsec = 4 * 1000000;
|
// ts.tv_nsec = 4 * 1000000;
|
||||||
|
|
13
README.md
13
README.md
|
@ -1,13 +0,0 @@
|
||||||
# [Robot Go West](https://projets.cohabit.fr/redmine/projects/communication-racinaire/wiki/Robot_Go-West)
|
|
||||||
|
|
||||||
### Introduction
|
|
||||||
This projet is a part of larger projet [_Communication Racinaire_](https://projets.cohabit.fr/redmine/projects/communication-racinaire/wiki/Wiki#section-8) which aims to drive plante into the direction of the sun.
|
|
||||||
|
|
||||||
When a plant received the solar radiation, a **difference of potential** will be created inside the plant. This physical reaction interest us to **measure** it and **interpret** the signal to drive the robot.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Embedded C sources
|
|
||||||
|
|
||||||
## Graphic visualization Python script
|
|
||||||
|
|
BIN
chaien.PNG
BIN
chaien.PNG
Binary file not shown.
Before Width: | Height: | Size: 28 KiB |
Loading…
Reference in a new issue