2008-07-11 20:38:17 +00:00
|
|
|
|
2008-07-11 22:55:36 +00:00
|
|
|
#include "control.h"
|
2008-07-12 00:00:11 +00:00
|
|
|
#include "path.h"
|
2008-07-11 22:55:36 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2008-07-12 21:38:19 +00:00
|
|
|
#define LATENCY 20
|
|
|
|
|
2008-07-12 08:40:15 +00:00
|
|
|
void trial_loop(trial *t) {
|
2008-07-12 14:00:47 +00:00
|
|
|
// path *p;
|
|
|
|
// int offset;
|
2008-07-12 08:40:15 +00:00
|
|
|
do {
|
|
|
|
if (-1 == trial_wait_for_start(t)) return;
|
|
|
|
if (t->finished) break;
|
2008-07-12 14:00:47 +00:00
|
|
|
// p = path_new();
|
2008-07-12 08:40:15 +00:00
|
|
|
/*create trivial path towards the origin*/
|
2008-07-12 15:51:38 +00:00
|
|
|
// offset = path_app_fitseq(p,t,0,400);
|
2008-07-12 14:00:47 +00:00
|
|
|
// offset = path_app_target(p,t,offset,0,0);
|
2008-07-12 08:40:15 +00:00
|
|
|
while (t->alive) {
|
2008-07-12 14:00:47 +00:00
|
|
|
// path_execute(t,p);
|
2008-07-12 21:38:19 +00:00
|
|
|
simulate(t, getcurts(t) + LATENCY);
|
2008-07-12 14:00:47 +00:00
|
|
|
godown(t);
|
2008-07-12 15:50:24 +00:00
|
|
|
if (-1 == trial_check_input(t)) return;
|
2008-07-12 08:40:15 +00:00
|
|
|
}
|
2008-07-12 10:21:49 +00:00
|
|
|
trial_matlab(t);
|
2008-07-12 11:59:35 +00:00
|
|
|
trial_fit(t,0,400);
|
2008-07-12 09:32:10 +00:00
|
|
|
trial_reset_run(t);
|
2008-07-12 14:00:47 +00:00
|
|
|
// path_free(p);
|
2008-07-12 08:40:15 +00:00
|
|
|
} while (!t->finished);
|
|
|
|
}
|
|
|
|
|
2008-07-11 22:24:00 +00:00
|
|
|
int main(int argc, char **argv) {
|
2008-07-11 22:55:36 +00:00
|
|
|
trial *t;
|
|
|
|
|
|
|
|
if (argc <= 2) {
|
|
|
|
fprintf(stderr, "Syntax: %s hostname port\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == (t = trial_new(argv[1], argv[2]))) {
|
|
|
|
return 2;
|
|
|
|
}
|
2008-07-12 00:00:11 +00:00
|
|
|
|
2008-07-12 08:40:15 +00:00
|
|
|
trial_loop(t);
|
2008-07-11 22:55:36 +00:00
|
|
|
|
|
|
|
trial_free(t);
|
|
|
|
|
2008-07-11 20:38:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|