-
Notifications
You must be signed in to change notification settings - Fork 2
/
sensing.cpp
56 lines (49 loc) · 1.23 KB
/
sensing.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include <unistd.h>
#include <stdlib.h>
using namespace std ;
double volatile pitch , yaw , roll ;
double volatile xdotdot,ydotdot, zdotdot;
double volatile pitchdot , yawdot , rolldot;
int main()
{
string readerline;
string myArray[12];
while(1)
{
ifstream reader("/home/pi/Desktop/readings.txt");
//check if the file exist
if(!reader)
{
cout<<"there was a problem openning the file..press any key to close";
cin.get();
return 0;
}
int i=0;
//store reads in array while outputting, skipping blank lines
while(reader.good())
{
//add the contents of the readings.txt to an array"myArray"
for(int i = 0; i < 12; ++i)
{
reader >> myArray[i];
//cout<<myArray[i]<<endl;
}
//use the contents of the array
}
yaw= strtod(myArray[0].c_str(),NULL);
roll=strtod(myArray[1].c_str(),NULL);
pitch=strtod(myArray[2].c_str(),NULL);
xdotdot=strtod(myArray[3].c_str(),NULL);
ydotdot=strtod(myArray[4].c_str(),NULL);
zdotdot=strtod(myArray[5].c_str(),NULL);
pitchdot=strtod(myArray[6].c_str(),NULL);
rolldot=strtod(myArray[7].c_str(),NULL);
yawdot=strtod(myArray[8].c_str(),NULL);
//delay for 2ms
usleep(10000);
}
}