-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTimeStamp.cpp
More file actions
47 lines (34 loc) · 1.25 KB
/
TimeStamp.cpp
File metadata and controls
47 lines (34 loc) · 1.25 KB
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
#include <iostream>
#include <TimeStamp.h>
#include <stdio.h>
#include <stdlib.h>
#include <AHRS.h>
#include <chrono>
#include <thread>
#include <iomanip>
#include <signal.h>
volatile sig_atomic_t sflag = 0;
void handle_sig(int sig)
{
sflag = 1;
}
int main(int argc, char *argv[]) {
std::cout << "Program Executing\n";
signal(SIGINT, handle_sig);
AHRS com = AHRS("/dev/ttyACM0");
printf("Initializing\n\n");
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout << "Pitch | Roll | Yaw | X-Accel | Y-Accel | Z-Accel | Time |" << std::endl;
while( 1 == 1){
std::cout << std::fixed << std::setprecision(2) << com.GetPitch() << " " << com.GetRoll() << " " << com.GetYaw() << " " <<com.GetWorldLinearAccelX() << " " << com.GetWorldLinearAccelY() << " " << com.GetWorldLinearAccelZ() << " " << com.GetLastSensorTimestamp() << " " << '\r' << std::flush;
std::this_thread::sleep_for(std::chrono::milliseconds(125));
if(sflag){
sflag = 0;
com.Close();
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
break;
}
}
printf("\nExit Caught... Closing device.\n");
return 0;
}