diff --git a/OpenSim/Common/XsensDataReader.cpp b/OpenSim/Common/XsensDataReader.cpp index 09adec7112..4b8de37794 100644 --- a/OpenSim/Common/XsensDataReader.cpp +++ b/OpenSim/Common/XsensDataReader.cpp @@ -4,6 +4,7 @@ #include "Exception.h" #include "FileAdapter.h" #include "TimeSeriesTable.h" +#include #include "XsensDataReader.h" namespace OpenSim { @@ -11,7 +12,7 @@ namespace OpenSim { template std::vector uniformTimeSamples(const T offset, const T step_size, const int numEl) { std::vector ivec(numEl); - std::iota(ivec.begin(), ivec.end(), 0); // ivec will become: [0..99] + std::iota(ivec.begin(), ivec.end(), 0); // ivec will become: [0..numEl] std::vector output(ivec.size()); std::transform(ivec.begin(), ivec.end(), output.begin(), [step_size, offset](int value) { @@ -45,8 +46,6 @@ XsensDataReader::extendRead(const std::string& folderName) const { SimTK::Matrix_ linearAccelerationData{ last_size, n_imus }; SimTK::Matrix_ magneticHeadingData{ last_size, n_imus }; SimTK::Matrix_ angularVelocityData{ last_size, n_imus }; - std::vector times; - times.resize(last_size); std::string prefix = _settings.get_trial_prefix(); std::map headersKeyValuePairs; @@ -109,7 +108,6 @@ XsensDataReader::extendRead(const std::string& folderName) const { // For all tables, will create row, stitch values from different files then append,time and timestep // are based on the first file bool done = false; - // int time = 0.0; int rowNumber = 0; while (!done){ // Make vectors one per table @@ -121,7 +119,7 @@ XsensDataReader::extendRead(const std::string& folderName) const { magneto_row_vector{ n_imus, SimTK::Vec3(SimTK::NaN) }; TimeSeriesTableVec3::RowVector gyro_row_vector{ n_imus, SimTK::Vec3(SimTK::NaN) }; - // Cycle through the filles collating values + // Cycle through the files collating values int imu_index = 0; for (std::vector::iterator it = imuStreams.begin(); it != imuStreams.end(); @@ -158,7 +156,6 @@ XsensDataReader::extendRead(const std::string& folderName) const { if (done) break; // append to the tables - // times[rowNumber] = time; if (foundLinearAccelerationData) linearAccelerationData[rowNumber] = accel_row_vector; if (foundMagneticHeadingData) @@ -166,12 +163,10 @@ XsensDataReader::extendRead(const std::string& folderName) const { if (foundAngularVelocityData) angularVelocityData[rowNumber] = gyro_row_vector; rotationsData[rowNumber] = orientation_row_vector; - // time += timeIncrement; rowNumber++; if (std::remainder(rowNumber, last_size) == 0) { // resize all Data/Matrices, double the size while keeping data int newSize = last_size*2; - // times.resize(newSize); // Repeat for Data matrices in use if (foundLinearAccelerationData) linearAccelerationData.resizeKeep(newSize, n_imus); if (foundMagneticHeadingData) magneticHeadingData.resizeKeep(newSize, n_imus); @@ -181,9 +176,7 @@ XsensDataReader::extendRead(const std::string& folderName) const { } } double timeIncrement = 1 / dataRate; - const auto time_vec = uniformTimeSamples(0.0, timeIncrement, rowNumber); - // Trim Matrices in use to actual data and move into tables - // times.resize(rowNumber); + const std::vector times = uniformTimeSamples(0.0, timeIncrement, rowNumber); // Repeat for Data matrices in use and create Tables from them or size 0 for empty linearAccelerationData.resizeKeep(foundLinearAccelerationData? rowNumber : 0, n_imus); @@ -196,7 +189,7 @@ XsensDataReader::extendRead(const std::string& folderName) const { // Now create the tables from matrices // Create 4 tables for Rotations, LinearAccelerations, AngularVelocity, MagneticHeading // Tables could be empty if data is not present in file(s) - DataAdapter::OutputTables tables = createTablesFromMatrices(dataRate, labels, time_vec, + DataAdapter::OutputTables tables = createTablesFromMatrices(dataRate, labels, times, rotationsData, linearAccelerationData, magneticHeadingData, angularVelocityData); return tables; }