#include <roboorte_robottype.h>
#include <unistd.h>
#include <time.h>
-
+#include <signal.h>
#define HOKUYO_DEVICE "/dev/ttyACM0" // /dev/ttyACM0
#define COMPILE_TIME_ASSERT(cond, msg) \
static urg_t urg;
static long *scan;
static int scan_max;
+int interrupt = 0;
struct robottype_orte_data orte;
}
}
+static void sig_handler(int sig)
+{
+ interrupt = 1;
+}
+
+
int main(int argc, char **argv)
{
int ret;
urg_parameter_t parameter;
struct timespec next;
+ signal(SIGINT, sig_handler);
+ signal(SIGTERM, sig_handler);
+
ret = hokuyo_init(HOKUYO_DEVICE);
if (ret < 0)
return ret;
clock_gettime(CLOCK_MONOTONIC, &next);
- while (1) {
+ while (!interrupt) {
int i;
int average = 0, errors[19];
memset(errors, 0, sizeof(errors));
ORTEPublicationSend(orte.publication_hokuyo_scan);
}
+ printf("Swithing off laser\n");
urg_disconnect(&urg);
robottype_roboorte_destroy(&orte);