From db860de7ce013163d1faf2d12dd2c35f4d799210 Mon Sep 17 00:00:00 2001 From: Leandro Rodrigues <leandro@h4rdc0r3.abstergo> Date: Mon, 23 Nov 2015 23:32:13 -0200 Subject: [PATCH] Alteracoes no main para gnuplot e arquivo de configuracao --- conf.plt | 20 ++++++++++++++++++++ main.c | 6 +++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 conf.plt diff --git a/conf.plt b/conf.plt new file mode 100644 index 0000000..0c04296 --- /dev/null +++ b/conf.plt @@ -0,0 +1,20 @@ +set terminal png +set output 'simulation.png' + +set xlabel "x/velocidade" + +set autoscale + +set ylabel "y/angulo de deslocamento" +set format y "%s" +set zlabel "Time" + +set title "Simulation" +set key reverse Left outside +set grid + +set style data linespoints + +splot "graph" using 1:2:3 title "Posicao", \ + "table" using 1:2:3 title "Angulo/Velocidade" + diff --git a/main.c b/main.c index 4e722c8..a30979f 100644 --- a/main.c +++ b/main.c @@ -47,7 +47,7 @@ double angleFromOrigin(int x, int y) { double angleFromPoint(int ox, int oy, int x, int y) { //ox e oy são os pontos da nova referência - double hip = distance(o)nx, oy, x, y); + double hip = distance(ox, oy, x, y); return acos((ox-x)/hip) * 180/PI; } @@ -96,13 +96,13 @@ int main(int argc, char const *argv[]) { double angle = angleFromPoint(r.x, r.y, tuplas[i].x, tuplas[i].y); double turn = angle - r.theta; // angulo para girar o robo //printf("DEBUG: %f %f\n", angle, r.theta); - fprintf(graph, "%d %d %d %f\n", tuplas[i].x, tuplas[i].y, frame, angle - r.theta); + fprintf(graph, "%d %d %d\n", tuplas[i].x, tuplas[i].y, frame); // Gira o robô r.theta += turn; // calcula a velocidade para as rodas distancia = distance(r.x, r.y, tuplas[i].x, tuplas[i].y); velocidade = velocity(distancia, tuplas[i].t); - fprintf(graph, "%f\n", velocidade); + fprintf(out, "%f %f %d\n", velocidade, r.theta, frame); moverRobo(&r,tuplas[i].x,tuplas[i].y); } -- GitLab