C3D export
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
C3D export
Dear Experts,
I have a problem in using python for OpenSim 4.1
My Anaconda is for python 2 (anaconda2),
I created a new environment for OpenSim 4.1 with python 3.7
The 4.1\bin folder is on my system path environment.
The codes are exactly the same as "Reading C3D files through Python"
in addition to importing os, opensim and numpy
But this error appears in that code:
(opensim41) C:\Users\MohammadReza\Desktop>python opensim41.py
Traceback (most recent call last):
File "opensim41.py", line 14, in <module>
tables = C3DFileAdapter.readFile(os.path.join(test_dir, 'walking2.c3d'), 1)
NameError: name 'C3DFileAdapter' is not defined
Would you please help me with this code and error?
Your help would be greatly appreciated.
Cheers
I have a problem in using python for OpenSim 4.1
My Anaconda is for python 2 (anaconda2),
I created a new environment for OpenSim 4.1 with python 3.7
The 4.1\bin folder is on my system path environment.
The codes are exactly the same as "Reading C3D files through Python"
in addition to importing os, opensim and numpy
But this error appears in that code:
(opensim41) C:\Users\MohammadReza\Desktop>python opensim41.py
Traceback (most recent call last):
File "opensim41.py", line 14, in <module>
tables = C3DFileAdapter.readFile(os.path.join(test_dir, 'walking2.c3d'), 1)
NameError: name 'C3DFileAdapter' is not defined
Would you please help me with this code and error?
Your help would be greatly appreciated.
Cheers
Tags:
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: C3D export
Hello,
The interface to C3DFileAdapter has changed, please consult the doxygen documentation here for available methods
https://simtk.org/api_docs/opensim/api_ ... apter.html
The class now uses the generic read method from its base class rather than a custom readFile method as of version 4.1
Best regards,
-Ayman
The interface to C3DFileAdapter has changed, please consult the doxygen documentation here for available methods
https://simtk.org/api_docs/opensim/api_ ... apter.html
The class now uses the generic read method from its base class rather than a custom readFile method as of version 4.1
Best regards,
-Ayman
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: C3D export
Hi Aymen,
Many thanks for your reply.
Is there anything wrong with this new code?
import opensim
C3DFileAdapter c3dFileAdapter;
c3dFileAdapter.setLocationForForceExpression(opensim.C3DFileAdapter.ForceLocation_CenterOfPressure);
tables = c3dFileAdapter.read("walking5.c3d")
markers = tables['markers']
forces = tables['forces']
There is still an error:
(opensim41) C:\Users\MohammadReza\Desktop>python opensim41.py
File "opensim41.py", line 2
C3DFileAdapter c3dFileAdapter;
^
SyntaxError: invalid syntax
I execute this code in Anaconda Prompt and this is my python version:
(opensim41) C:\Users\MohammadReza\Desktop>python --version
Python 3.7.6
I'm grateful for your help
Cheers
Many thanks for your reply.
Is there anything wrong with this new code?
import opensim
C3DFileAdapter c3dFileAdapter;
c3dFileAdapter.setLocationForForceExpression(opensim.C3DFileAdapter.ForceLocation_CenterOfPressure);
tables = c3dFileAdapter.read("walking5.c3d")
markers = tables['markers']
forces = tables['forces']
There is still an error:
(opensim41) C:\Users\MohammadReza\Desktop>python opensim41.py
File "opensim41.py", line 2
C3DFileAdapter c3dFileAdapter;
^
SyntaxError: invalid syntax
I execute this code in Anaconda Prompt and this is my python version:
(opensim41) C:\Users\MohammadReza\Desktop>python --version
Python 3.7.6
I'm grateful for your help
Cheers
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: C3D export
It looks like your code is part C++ and part Python. For reference, there's a related test case here: https://github.com/opensim-org/opensim- ... ter.py#L33. You should have something like this:
Code: Select all
import opensim
c3dFileAdapter = opensim.C3DFileAdapter()
...
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: C3D export
Thanks Tom,
There is an example on doxygen for python: https://simtk.org/api_docs/opensim/api_ ... apter.html
But now it works well
Cheers
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: C3D export
Great. Thanks for reporting- I'll submit a fix.
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: C3D export
Hi,
It would be great if these examples become updated for 4.1 version as well.
https://simtk-confluence.stanford.edu:8 ... d%29+Files
Best Wishes
It would be great if these examples become updated for 4.1 version as well.
https://simtk-confluence.stanford.edu:8 ... d%29+Files
Best Wishes
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: C3D export
Thanks for reporting. I've opened an Issue on GitHub (https://github.com/opensim-org/opensim-core/issues/2673) to investigate.
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: C3D export
Hi again,
In MATLAB, "rotateData" and "convertMillimeters2Meters" were defined
but in python, I can't find them. are there any examples of these
functions in python for "forces"?
adapter = opensim.C3DFileAdapter()
task = adapter.read(os.path.join(output_dir, 'task.c3d'))
forces = adapter.getForcesTable(task)
Your response would be greatly appreciated.
Cheers
In MATLAB, "rotateData" and "convertMillimeters2Meters" were defined
but in python, I can't find them. are there any examples of these
functions in python for "forces"?
adapter = opensim.C3DFileAdapter()
task = adapter.read(os.path.join(output_dir, 'task.c3d'))
forces = adapter.getForcesTable(task)
Your response would be greatly appreciated.
Cheers
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: C3D export
rotateData() and convertMillimeters2Meters() are functions written in Matlab (https://github.com/opensim-org/opensim- ... C3D.m#L138 and https://github.com/opensim-org/opensim- ... C3D.m#L154). You can implement them in Python if you need them there.