@@ -90,28 +90,35 @@ void Log::record(DataToLog &aDataToLog) {
90
90
StoredData_.controls [JointID + lref_] = aDataToLog.controls [JointID];
91
91
}
92
92
for (unsigned int axis = 0 ; axis < 3 ; axis++) {
93
- StoredData_.accelerometer [lrefts_ * 3 + axis] =
94
- aDataToLog.accelerometer [axis];
95
- StoredData_.gyrometer [lrefts_ * 3 + axis] = aDataToLog.gyrometer [axis];
93
+ if (StoredData_.accelerometer .size () >= lrefts_ * 3 + 3 )
94
+ StoredData_.accelerometer [lrefts_ * 3 + axis] =
95
+ aDataToLog.accelerometer [axis];
96
+ }
97
+ for (unsigned int axis = 0 ; axis < 3 ; axis++) {
98
+ if (StoredData_.gyrometer .size () >= lrefts_ * 3 + 3 )
99
+ StoredData_.gyrometer [lrefts_ * 3 + axis] = aDataToLog.gyrometer [axis];
96
100
}
97
101
std::size_t width_pad = 6 * profileLog_.nbForceSensors ;
98
102
99
103
for (unsigned int fsID = 0 ; fsID < profileLog_.nbForceSensors ; fsID++) {
100
104
for (unsigned int axis = 0 ; axis < 6 ; axis++) {
101
- StoredData_.force_sensors [lrefts_ * width_pad + fsID * 6 + axis] =
102
- aDataToLog.force_sensors [fsID * 6 + axis];
105
+ if (StoredData_.force_sensors .size () >
106
+ lrefts_ * width_pad + (profileLog_.nbForceSensors - 1 ) * 6 + 5 )
107
+ StoredData_.force_sensors [lrefts_ * width_pad + fsID * 6 + axis] =
108
+ aDataToLog.force_sensors [fsID * 6 + axis];
103
109
}
104
110
}
105
111
106
112
struct timeval current;
107
113
gettimeofday (¤t, 0 );
108
114
109
- StoredData_.timestamp [lrefts_] =
110
- ((double )current.tv_sec + 0.000001 * (double )current.tv_usec ) -
111
- timeorigin_;
112
-
113
- StoredData_.duration [lrefts_] = time_stop_it_ - time_start_it_;
115
+ if (StoredData_.timestamp .size () > lrefts_) {
116
+ StoredData_.timestamp [lrefts_] =
117
+ ((double )current.tv_sec + 0.000001 * (double )current.tv_usec ) -
118
+ timeorigin_;
114
119
120
+ StoredData_.duration [lrefts_] = time_stop_it_ - time_start_it_;
121
+ }
115
122
lref_ += profileLog_.nbDofs ;
116
123
lrefts_++;
117
124
if (lref_ >= profileLog_.nbDofs * profileLog_.length ) {
0 commit comments