fix time gap bug
This commit is contained in:
+10
-5
@@ -5,7 +5,11 @@
|
|||||||
#include "pose_body.h"
|
#include "pose_body.h"
|
||||||
|
|
||||||
Polygon workspace;
|
Polygon workspace;
|
||||||
time_gap_t global_time_gap;
|
time_gap_t global_time_gap = {
|
||||||
|
.in = 0,
|
||||||
|
.size = 0,
|
||||||
|
.periods = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
void dump_polygon_to_file(char *filename) {
|
void dump_polygon_to_file(char *filename) {
|
||||||
FILE *fp = fopen(filename, "w+");
|
FILE *fp = fopen(filename, "w+");
|
||||||
@@ -164,11 +168,11 @@ int should_do_judge_according_time() {
|
|||||||
} else {
|
} else {
|
||||||
// not in
|
// not in
|
||||||
for (int i = 0; i < global_time_gap.size; i++) {
|
for (int i = 0; i < global_time_gap.size; i++) {
|
||||||
if (global_time_gap.periods[i].from > now || global_time_gap.periods[i].to < now) {
|
if (global_time_gap.periods[i].from <= now && global_time_gap.periods[i].to >= now) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,9 +264,10 @@ int get_all_time_period_from_arguments(const char *str) {
|
|||||||
|
|
||||||
char *rest;
|
char *rest;
|
||||||
char *info;
|
char *info;
|
||||||
char *start = origin;
|
char *start = origin+offset;
|
||||||
printf(in ? "in" : "not in ");
|
printf(in ? "in" : "not in ");
|
||||||
|
|
||||||
|
global_time_gap.in = in;
|
||||||
global_time_gap.periods = (time_period_t*) malloc(sizeof(time_period_t)*64);
|
global_time_gap.periods = (time_period_t*) malloc(sizeof(time_period_t)*64);
|
||||||
|
|
||||||
int size = 0;
|
int size = 0;
|
||||||
@@ -273,7 +278,7 @@ int get_all_time_period_from_arguments(const char *str) {
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
global_time_gap.periods[size].from = period->from;
|
global_time_gap.periods[size].from = period->from;
|
||||||
global_time_gap.periods[size].from = period->to;
|
global_time_gap.periods[size].to = period->to;
|
||||||
free(period);
|
free(period);
|
||||||
size++;
|
size++;
|
||||||
if (size >= 64) {
|
if (size >= 64) {
|
||||||
|
|||||||
Reference in New Issue
Block a user