Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Update code snippet to 4.4, and embed codeblock instead of macro

...

  • 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

Image Added

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
languagecpp
titleUse C3DFileAdapter
collapsetrue
    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

...