int cartes_size = cartes.size();
- gnuplot = popen("gnuplot", "w");
- FILE *p1, *p2;
- p1 = fopen("cartes1", "w");
- p2 = fopen("cartes2", "w");
- int i, end, start = 0;
- int set = 0;
+ int end, start = 0;
while (start < cartes_size) {
end = start + 1;
end--;
- for (i = start; i <= end; i++) {
- fprintf(set == 0 ? p1 : p2, "%g %g\n", cartes[i].x, cartes[i].y);
- }
- fflush(p1);
- fflush(p2);
- set = 1 - set;
-
line_fitting(start, end, cartes, lines);
start = end + 1;
}
- fclose(p1);
- fclose(p2);
-
-
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 'cartes1' with points ls 2, 'cartes2' with points ls 3");
+ 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, "\n");
- fflush(gnuplot);
- pclose(gnuplot);
+ for (int i = 0; i < (int) cartes.size(); i++) {
+ fprintf(gnuplot, "%g %g\n",cartes[i].x, cartes[i].y);
+ }
+
+ fprintf(gnuplot, "e\n");
+ fflush(gnuplot);
}
-//-----------------------------------------------
-/*
struct robottype_orte_data orte;
void rcv_hokuyo_scan_cb(const ORTERecvInfo *info, void *vinstance,
void *recvCallBackParam)
{
struct hokuyo_scan_type *instance = (struct hokuyo_scan_type *)vinstance;
- struct hokuyo_scan_type scan;
+ static int count = 0;
switch (info->status) {
case NEW_DATA: {
- scan = *instance;
-
+ printf("Scan\n");
+ if (++count >= 4) {
+ printf("Detect\n");
+ count = 0;
- vector<int> input(velikost);
+ vector<int> input(HOKUYO_ARRAY_SIZE);
- for(int i = 0; i < velikost; i++)
- input[i] = (int) scan.data[i];
+ for(unsigned i = 0; i < HOKUYO_ARRAY_SIZE; i++)
+ input[i] = (int) instance->data[HOKUYO_ARRAY_SIZE-1-i];
-
-
- vector<Line> output;
- shape_detect(input, output);
-
+ vector<Line> output;
+ shape_detect(input, output);
+ }
break;
}
case DEADLINE:
- robot.status[COMPONENT_HOKUYO] = STATUS_FAILED;
- //system("killall -9 hokuyo");
- //DBG("%s: ORTE deadline occurred\n", __FUNCTION__);
+ printf("Deadline\n");
break;
}
}
int robot_init_orte()
{
int rv = 0;
- robot.orte.strength = 20;
rv = robottype_roboorte_init(&orte);
if (rv) return rv;
robottype_subscriber_hokuyo_scan_create(&orte, rcv_hokuyo_scan_cb, &orte);
return rv;
}
-*/
-//-----------------------------------------------
-// MAIN
+#if 1
int main(int argc, char** argv) {
if (argc < 2) {
return 0;
}
-
+#else
+int main()
+{
+ gnuplot = popen("gnuplot", "w");
+ robot_init_orte();
+ getchar();
+ pclose(gnuplot);
+ return 0;
+}
+#endif