From 50157d81e946eb9862ca7701f7a3d2fcc3b7950e Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Wed, 15 Dec 2010 17:46:17 +0100 Subject: [PATCH] shape-detect: Plot graphs much faster This was done by not using "< echo" to draw lines. This spawns shell for each line to be drawn and this is obviously very slow. --- src/hokuyo/shape-detect/main.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hokuyo/shape-detect/main.cc b/src/hokuyo/shape-detect/main.cc index 04c3dc09..9563d1b4 100644 --- a/src/hokuyo/shape-detect/main.cc +++ b/src/hokuyo/shape-detect/main.cc @@ -252,17 +252,23 @@ void shape_detect(const vector &input_data, vector &lines) { fprintf(gnuplot, "set grid\n"); fprintf(gnuplot, "set nokey\n"); fprintf(gnuplot, "set style line 1 lt 2 lc rgb \"red\" lw 3\n"); - fprintf(gnuplot, "plot [-1000:+3000] [-3000:+3000] '-' with points ls 2"); - for (int i = 0; i < (int) lines.size(); i++) { - fprintf(gnuplot, ", \"< echo \'%f %f \\n %f %f\'\" ls 1 with linespoints",lines[i].a.x, lines[i].a.y, lines[i].b.x, lines[i].b.y); - } + fprintf(gnuplot, "plot [-1000:+3000] [-3000:+3000]"); + fprintf(gnuplot, "'-' with points ls 2"); // points + fprintf(gnuplot, ", '-' ls 1 with linespoints"); // lines fprintf(gnuplot, "\n"); + // points data for (int i = 0; i < (int) cartes.size(); i++) { fprintf(gnuplot, "%g %g\n",cartes[i].x, cartes[i].y); } + fprintf(gnuplot, "e\n"); + // lines data + for (int i = 0; i < (int) lines.size(); i++) { + fprintf(gnuplot, "%f %f\n%f %f\n\n", + lines[i].a.x, lines[i].a.y, lines[i].b.x, lines[i].b.y); + } fprintf(gnuplot, "e\n"); fflush(gnuplot); } @@ -278,7 +284,7 @@ void rcv_hokuyo_scan_cb(const ORTERecvInfo *info, void *vinstance, switch (info->status) { case NEW_DATA: { printf("Scan\n"); - if (++count >= 4) { + if (++count >= 1) { printf("Detect\n"); count = 0; -- 2.39.2