Our university has a wireless motion capture system that exports data in CSV format. I’ve learned from elsewhere that AnyBody software can also perform inverse dynamic simulations on CSV files, but I don’t yet know what the CSV table should look like. Is it enough to include joint-motion data for the upper limbs, lower limbs and trunk? How do you drive AnyBody with a CSV file? Are there any websites or documents where I can find detailed tutorials?
Hi Shanhai,
I still do not see your affiliation I see only some number, please update this ![]()
AnyBody can read a csv file using AnyInputFile, this allows you to read the raw data.
The mocap models in AnyBody are built to expect a C3D file or a BVH file, and then the entire workflow is built around that. So the path of least resistances are these
- Convert CVS to C3D outside AnyBody
- Read the CSV file into AnyBody then reconstruct a model structure like you would see from loading a C3D. So load a mocap model using a C3D file then look at the C3D file data structure in the ModelTree and try to make you own similar folder structure in the script. Once it is all recreated you can point the Mocap model to use these data instead of the data from the C3D file.
Best regards
Søren
Hi @shanhai
If you have MoCap marker data in a CSV file then I would convert the file to a "c3d" file using the ezc3d python library:
Let us assume we have columns in our csv file with x-y-z components of our markers, then a script to generate a c3d file could be as simple as this:
import pandas as pd
import numpy as np
import ezc3d
# Load an empty c3d structure
c3d = ezc3d.c3d()
df = pd.read_excel("somefile.xlsx")
df = pd.read_csv("somefile.csv")
c3d['parameters']['POINT']['UNITS']['value'] = ['m']
c3d['parameters']['POINT']['RATE']['value'] = 26.51204
markerlist = set([ col[:-2] for col in df.columns if col[-2:] in [' X', ' Y', ' Z'] ])
c3d['parameters']['POINT']['LABELS']['value'] = tuple(markerlist)
c3d['data']['points'] = np.ones((4, len(markerlist), len(df)))
for idx, marker in enumerate(markerlist):
c3d['data']['points'][0:3,idx,:] = df[[marker + ' X', marker + ' Y', marker + ' Z']].values.T
c3d.write("./test.c3d")
Thank you for your insightful guidance, Professor. I would like to ask if my affiliation has been successfully updated. If not, I will attempt to make the change again. Thank you very much.
Hi all,
I’ve converted my CSV to C3D as suggested. The data come from a markerless system, so the C3D only contains virtual markers like LAnkle, LBigToe, LHeel,LKnee,LShoudler,LWrist,LHand,Neck,chin....
Can I feed this directly into AnyBody?
Which model should I use and what’s the exact import workflow?
If it’s not possible, I only have joint-center positions, linear/angular velocities and accelerations—how should I proceed to run inverse dynamics?
Thanks for your help!
Hi Shanhai
To use a C3D for driving the model please these pages.
The AnyMoCap Framework — AMMR v3.1.4 Documentation
If your data only has joint centers it might be that you will need to extra drivers, e.g. for forearm pronation, but this also possible.
The Steps
- Start with one of the Mocap models in AMMR
- Open the MarkerProtocol.any file and start adding your own markers, you can look at the existing markers and rename/copy from these.
- In the Extradrivers.any add drivers for DOF which the markers does not cover.
Hope it helps
Best regards
Søren
5.
Thank you for your answer and guidance, Professor. Thanks to your guidance, I've been able to avoid many detours and learn things much faster.
