]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
shape-detect: Plot graphs much faster
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 15 Dec 2010 16:46:17 +0000 (17:46 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 15 Dec 2010 16:46:17 +0000 (17:46 +0100)
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

index 04c3dc096adf27e668f66fbcb56114e310610355..9563d1b439cd995375785900636c9b3a3e570112 100644 (file)
@@ -252,17 +252,23 @@ void shape_detect(const vector<int> &input_data, vector<Line> &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;