...
- read a C3D file containing markers and forces,
- get some information about the data (rate, number of markers, and number of forces),
- rotate the data, and
- then write the markers to a .trc file, and the forces to a .mot file.
Expand |
---|
Reading C3D files through Python and C++
...
Example code for using the C3DFileAdapter in C++ is found below. This code is part of a test script that runs the C3D reader and checks for correct valueswrites the resulting tables to files.
OpenSim 4.0
...
OpenSim 4.1
...
4
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
using namespace OpenSim;
using namespace std;
C3DFileAdapter c3dFileAdapter{};
auto tables = c3dFileAdapter.read(filename);
std::shared_ptr<TimeSeriesTableVec3> marker_table = c3dFileAdapter.getMarkersTable(tables);
std::shared_ptr<TimeSeriesTableVec3> force_table = c3dFileAdapter.getForcesTable(tables);
std::shared_ptr<TimeSeriesTable> analog_table = c3dFileAdapter.getAnalogDataTable(tables);
const std::string marker_file = base + "_markers.trc";
const std::string forces_file = base + "_grfs.sto";
const std::string analogs_file = base + "_analog.sto";
TRCFileAdapter trc_adapter{};
trc_adapter.write(*marker_table, marker_file);
force_table->updTableMetaData().setValueForKey("Units",
std::string{"mm"});
STOFileAdapter sto_adapter{};
sto_adapter.write((force_table->flatten()), forces_file);
sto_adapter.write(*analog_table, analogs_file);
|
Importing Force Data: COP and NaNs
...