-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (38 loc) · 834 Bytes
/
main.cpp
File metadata and controls
47 lines (38 loc) · 834 Bytes
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
/*
* Copyright (C) 2016 Tolga Ceylan
*
* CopyPolicy: Released under the terms of the GNU GPL v3.0.
*/
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include "robo.h"
int running = 1;
void sig_handler(int signo)
{
if (signo == SIGINT)
running = 0;
}
int main (int argc, char **argv)
{
int demo_num = 0;
if (argc == 2)
demo_num = atoi(argv[1]);
robo::Robot *robot = new robo::Robot(demo_num);
int ret = robot ? robot->initialize() : ENOMEM;
if (!ret)
{
signal(SIGINT, sig_handler);
while ((running == 1) && (ret == 0))
ret = robot->update();
robot->shutdown();
}
// give 40 msecs to components to shutdown
usleep(40000);
delete robot;
robot = 0;
done:
return ret;
}