currentSeg = begin();
prepared = true;
- #ifdef MOTION_LOG
- char c[200];
- Pos p1, p2;
- for (iterator seg = begin(); seg != end(); seg++) { // logging segment parameters
- (*seg)->getRefPos((*seg)->getT1(), p1);
- (*seg)->getRefPos((*seg)->getT2(), p2);
- sprintf(c, "segment: begin %lf %lf, end %lf %lf, angles %lf %lf, v1 %lf, v2 %lf, t1 %lf, t2 %lf, len %lf\n",
- p1.x, p1.y, p2.x, p2.y, p1.phi, p2.phi,(*seg)->v1, (*seg)->v2, (*seg)->getT1(), (*seg)->getT2(), (*seg)->getLength());
- log(c);
- sprintf(c, "gnuplot: %lf %lf %lf %lf %d\n", (*seg)->getT1(), p1.x, p1.y, p1.phi, 1); //gnuplot start point
- log(c);
- sprintf(c, "gnuplot: %lf %lf %lf %lf %d\n", (*seg)->getT2(), p2.x, p2.y, p2.phi, 3); //gnuplot end point
- log(c);
- }
- iterator end_seg = --end();
- double max_tm = (*end_seg)->getT2();
- // for gnuplot
- for(double tm = 0; tm <= max_tm; tm += 0.05) {
- getRefPos(tm, p1);
- sprintf(c, "gnuplot: %lf %lf %lf %lf %d\n", tm, p1.x, p1.y, p1.phi, 2); // gnuplot middle part
- log(c);
- }
-
- log("trajectory prepared\n");
- #endif
-
return true;
}
};
#endif
+#ifdef MOTION_LOG
+void
+Trajectory::logTraj(double start_time)
+{
+ char c[200];
+ Pos p1, p2;
+ for (iterator seg = begin(); seg != end(); seg++) { // logging segment parameters
+ (*seg)->getRefPos((*seg)->getT1(), p1);
+ (*seg)->getRefPos((*seg)->getT2(), p2);
+ sprintf(c, "segment: begin %lf %lf, end %lf %lf, angles %lf %lf, v1 %lf, v2 %lf, t1 %lf, t2 %lf, len %lf\n",
+ p1.x, p1.y, p2.x, p2.y, p1.phi, p2.phi,(*seg)->v1, (*seg)->v2, (*seg)->getT1(), (*seg)->getT2(), (*seg)->getLength());
+ log(c);
+ sprintf(c, "gnuplot: %lf %lf %lf %lf %d\n", start_time+(*seg)->getT1(), p1.x, p1.y, p1.phi, 1); //gnuplot start point
+ log(c);
+ sprintf(c, "gnuplot: %lf %lf %lf %lf %d\n", start_time+(*seg)->getT2(), p2.x, p2.y, p2.phi, 3); //gnuplot end point
+ log(c);
+ }
+ iterator end_seg = --end();
+ double max_tm = (*end_seg)->getT2();
+ // for gnuplot
+ for(double tm = 0; tm <= max_tm; tm += 0.05) {
+ getRefPos(tm, p1);
+ sprintf(c, "gnuplot: %lf %lf %lf %lf %d\n", start_time+tm, p1.x, p1.y, p1.phi, 2); // gnuplot middle part
+ log(c);
+ }
+}
+#endif