-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
36 lines (33 loc) · 989 Bytes
/
main.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
#include <csignal>
#include "lidar/RPLidar.hpp"
bool running=true; //Variable to manage stops when signals are received
void signal_handler(int signo){
if(signo==SIGTERM || signo==SIGINT)
running = false;
}
int main(int argc, char** argv){
/* ************************************
* SETUP LIDAR & CHECK STATUS *
**************************************/
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
RPLidar lidar; //Connects to lidar
running = lidar.init(argc>1?argv[argc - 1]:"/dev/ttyUSB0");
/* ************************************
* START *
**************************************/
if(running) {
lidar.print_status();
running = lidar.start();
}
while(running){
//Update current scan (one turn of measurements)
lidar.update();
lidar.print_scan();
lidar.print_deltas();
}
/* ***********************************
* STOP ALL *
*************************************/
return 0;
}