...
Expand |
---|
Code Block |
---|
def test_C3DFileAdapter(self):
try:
adapter = osim.C3DFileAdapter()
except AttributeError:
# C3D support not available. OpenSim was not compiled with BTK.
return
tables = adapter.read(os.path.join(test_dir, 'walking2.c3d'), 0)
markers = tables['markers']
forces = tables['forces']
tables = adapter.read(os.path.join(test_dir, 'walking5.c3d'), 1)
# Marker data read from C3D.
markers = tables['markers']
# Flatten marker data.
markersFlat = markers.flatten()
# Make sure flattenned marker data is writable/readable to/from file.
markersFilename = 'markers.sto'
stoAdapter = osim.STOFileAdapter()
stoAdapter.write(markersFlat, markersFilename)
markersDouble = stoAdapter.read(markersFilename)
# Forces data read from C3d.
forces = tables['forces']
fpCalMats = forces.getTableMetaDataVectorMatrix("CalibrationMatrices")
fpCorners = forces.getTableMetaDataVectorMatrix("Corners")
fpOrigins = forces.getTableMetaDataVectorMatrix("Origins")
# Flatten forces data.
forcesFlat = forces.flatten()
# Make sure flattenned forces data is writable/readable to/from file.
forcesFilename = 'forces.sto'
stoAdapter.write(forcesFlat, forcesFilename)
forcesDouble = stoAdapter.read(forcesFilename)
# Clean up.
os.remove(markersFilename)
os.remove(forcesFilename) |
|
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 values.
...