Skip to content

Commit

Permalink
Remove Dead Code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbeattie42 committed Nov 27, 2024
1 parent 8cbe718 commit 9885d1b
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions OpenSim/Common/XsensDataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#include "Exception.h"
#include "FileAdapter.h"
#include "TimeSeriesTable.h"
#include <vector>
#include "XsensDataReader.h"

namespace OpenSim {

template <typename T>
std::vector<T> uniformTimeSamples(const T offset, const T step_size, const int numEl) {
std::vector<int> 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<T> output(ivec.size());
std::transform(ivec.begin(), ivec.end(), output.begin(),
[step_size, offset](int value) {
Expand Down Expand Up @@ -45,8 +46,6 @@ XsensDataReader::extendRead(const std::string& folderName) const {
SimTK::Matrix_<SimTK::Vec3> linearAccelerationData{ last_size, n_imus };
SimTK::Matrix_<SimTK::Vec3> magneticHeadingData{ last_size, n_imus };
SimTK::Matrix_<SimTK::Vec3> angularVelocityData{ last_size, n_imus };
std::vector<double> times;
times.resize(last_size);

std::string prefix = _settings.get_trial_prefix();
std::map<std::string, std::string> headersKeyValuePairs;
Expand Down Expand Up @@ -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
Expand All @@ -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<std::ifstream*>::iterator it = imuStreams.begin();
it != imuStreams.end();
Expand Down Expand Up @@ -158,20 +156,17 @@ 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)
magneticHeadingData[rowNumber] = magneto_row_vector;
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);
Expand All @@ -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<double> 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);
Expand All @@ -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;
}
Expand Down

0 comments on commit 9885d1b

Please sign in to comment.