fixed compilation except parser

This commit is contained in:
Johannes Reinhardt 2008-07-12 02:25:19 +02:00
parent b477e64c3e
commit 12bd232d2a
1 changed files with 12 additions and 9 deletions

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "path.h"
@ -8,6 +9,7 @@ command *command_new(timestamp ts, accel_t a, turn_t t){
res->ts = ts;
res->accel = a;
res->turn = t;
return res;
}
void command_free(command* c){
@ -22,25 +24,26 @@ path *path_new(map* m,vehicle *v){
/* Calculate a trivial path to the origin*/
/* 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;
if(angle - v->dir > 0){
/*clockwise/left turn*/
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);
g_push_tail(res-commands,tmp);
else {
g_queue_push_tail(res->commands,tmp);
} else {
/*counterclockwise/right turn*/
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);
g_push_tail(res-commands,tmp);
g_queue_push_tail(res->commands,tmp);
}
/*start driving*/
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){
@ -73,7 +76,7 @@ void path_free(path* p){
length = g_queue_get_length(p->commands);
if(length > 0){
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);
command_free(tmp);
}