File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,40 @@ using namespace std;
34
34
using namespace dynamicgraph ::sot;
35
35
namespace po = boost::program_options;
36
36
37
+ struct DataToLog
38
+ {
39
+ const std::size_t N;
40
+ std::size_t idx;
41
+
42
+ std::vector<double > times;
43
+
44
+ DataToLog (std::size_t N_)
45
+ : N (N_)
46
+ , idx (0 )
47
+ , times (N, 0 )
48
+ {}
49
+
50
+ void record (const double t)
51
+ {
52
+ times[idx] = t;
53
+ ++idx;
54
+ if (idx == N) idx = 0 ;
55
+ }
56
+
57
+ void save (const char * prefix)
58
+ {
59
+ std::ostringstream oss;
60
+ oss << prefix << " -times.log" ;
61
+
62
+ std::ofstream aof (oss.str ().c_str ());
63
+ if (aof.is_open ()) {
64
+ for (std::size_t k = 0 ; k < N; ++k) {
65
+ aof << times[ (idx + k) % N ] << ' \n ' ;
66
+ }
67
+ }
68
+ aof.close ();
69
+ }
70
+ };
37
71
38
72
39
73
void workThreadLoader (SotLoader *aSotLoader)
@@ -59,10 +93,12 @@ void workThreadLoader(SotLoader *aSotLoader)
59
93
gettimeofday (&stop,0 );
60
94
61
95
unsigned long long dt = 1000000 * (stop.tv_sec - start.tv_sec ) + (stop.tv_usec - start.tv_usec );
96
+ dataToLog.record ((double )dt * 1e-6 );
62
97
if (period > dt) {
63
98
usleep (period - (unsigned )dt);
64
99
}
65
100
}
101
+ dataToLog.save (" /tmp/geometric_simu" );
66
102
cond.notify_all ();
67
103
ros::waitForShutdown ();
68
104
}
You can’t perform that action at this time.
0 commit comments