fixed compilation except parser
This commit is contained in:
parent
b477e64c3e
commit
12bd232d2a
21
src/path.c
21
src/path.c
@ -1,4 +1,5 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
@ -8,6 +9,7 @@ command *command_new(timestamp ts, accel_t a, turn_t t){
|
|||||||
res->ts = ts;
|
res->ts = ts;
|
||||||
res->accel = a;
|
res->accel = a;
|
||||||
res->turn = t;
|
res->turn = t;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void command_free(command* c){
|
void command_free(command* c){
|
||||||
@ -22,25 +24,26 @@ path *path_new(map* m,vehicle *v){
|
|||||||
/* Calculate a trivial path to the origin*/
|
/* Calculate a trivial path to the origin*/
|
||||||
|
|
||||||
/* Turn towards origin, take shorter direction*/
|
/* Turn towards origin, take shorter direction*/
|
||||||
angle = atan(v->y/y->x);
|
angle = atan(v->y/v->x);
|
||||||
stop = abs(angle - v->dir)/m->max_turn;
|
stop = abs(angle - v->dir)/m->max_turn;
|
||||||
if(angle - v->dir > 0){
|
if(angle - v->dir > 0){
|
||||||
/*clockwise/left turn*/
|
/*clockwise/left turn*/
|
||||||
tmp = command_new(0,BREAK,TURN_LEFT);
|
tmp = command_new(0,BREAK,TURN_LEFT);
|
||||||
g_push_tail(res-commands,tmp);
|
g_queue_push_tail(res->commands,tmp);
|
||||||
tmp = command_new(stop,BREAK,TURN_RIGHT);
|
tmp = command_new(stop,BREAK,TURN_RIGHT);
|
||||||
g_push_tail(res-commands,tmp);
|
g_queue_push_tail(res->commands,tmp);
|
||||||
else {
|
} else {
|
||||||
/*counterclockwise/right turn*/
|
/*counterclockwise/right turn*/
|
||||||
tmp = command_new(0,BREAK,TURN_RIGHT);
|
tmp = command_new(0,BREAK,TURN_RIGHT);
|
||||||
g_push_tail(res-commands,tmp);
|
g_queue_push_tail(res->commands,tmp);
|
||||||
tmp = command_new(stop,BREAK,TURN_LEFT);
|
tmp = command_new(stop,BREAK,TURN_LEFT);
|
||||||
g_push_tail(res-commands,tmp);
|
g_queue_push_tail(res->commands,tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*start driving*/
|
/*start driving*/
|
||||||
tmp = command_new(stop,ACCEL,TURN_STRAIGHT);
|
tmp = command_new(stop,ACCEL,TURN_STRAIGHT);
|
||||||
g_push_tail(res-commands,tmp);
|
g_queue_push_tail(res->commands,tmp);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void path_execute(trial* t,path* p){
|
void path_execute(trial* t,path* p){
|
||||||
@ -73,7 +76,7 @@ void path_free(path* p){
|
|||||||
length = g_queue_get_length(p->commands);
|
length = g_queue_get_length(p->commands);
|
||||||
if(length > 0){
|
if(length > 0){
|
||||||
fprintf(stderr,"freeing non-empty path\n");
|
fprintf(stderr,"freeing non-empty path\n");
|
||||||
while(g_queue_get_length(p->commands > 0)){
|
while(g_queue_get_length(p->commands) > 0){
|
||||||
tmp = g_queue_pop_head(p->commands);
|
tmp = g_queue_pop_head(p->commands);
|
||||||
command_free(tmp);
|
command_free(tmp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user