Export Bone Geometry to .STL For Each Frame
- Connor Pyles
- Posts: 20
- Joined: Wed Jul 19, 2017 1:46 pm
Re: Export Bone Geometry to .STL For Each Frame
Not sure if this helps, but it looks like the cmake tests are expecting a "C:\opensim-core\Bindings\Java\Matlab\Utilities" folder, which doesn't exist. I figured this out when trying to run configureOpenSim(), which, by the way, I also had to change because it was expecting the OpenSim_buildinfo.txt file in an "sdk" folder, when it was actually in the root openSimFolder.
Thanks,
Connor Pyles
Thanks,
Connor Pyles
- Connor Pyles
- Posts: 20
- Joined: Wed Jul 19, 2017 1:46 pm
Re: Export Bone Geometry to .STL For Each Frame
Ok, so I did two things, manually removed OpenSim 3.3 API from MATLAB path, including the Java class and library paths, and closed MATLAB before running the ctest again and it worked. Not sure which one was the fix.
Will keep you posted on status, and I'd still appreciate any feedback on loading in 3.x sim results.
Best,
Connor Pyles
Will keep you posted on status, and I'd still appreciate any feedback on loading in 3.x sim results.
Best,
Connor Pyles
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Export Bone Geometry to .STL For Each Frame
In general, backwards compatibility is maintained; old models are updated automatically when opened in 4.0. Any known exceptions will be indicated in the upgrade notes as has been done in the past (e.g., see http://simtk-confluence.stanford.edu:80 ... penSim+3.3). A partial list of major changes between 3.3 and 4.0 can be found in CHANGELOG.md on GitHub (https://github.com/opensim-org/opensim- ... ANGELOG.md).I understand that the 4.0 API will build models for OpenSim 4.0, but can we initialize models from OpenSim 3.x? I.e., could we run "model = Model('C:\OpenSim 3.3\Models\gait2392_thelen2003muscle.osim')" ?
- Connor Pyles
- Posts: 20
- Joined: Wed Jul 19, 2017 1:46 pm
Re: Export Bone Geometry to .STL For Each Frame
Ok, thanks for all of you help, I got 4.0 built and the API is working with the code snippet you posted. Now, assuming I have already run an analysis, which commands do I need to iterate through each model state, rather than setting the pelvis tilt/x-location manually?
- Sina Porsa
- Posts: 5
- Joined: Sun Jul 15, 2018 4:51 pm
Re: Export Bone Geometry to .STL For Each Frame
Hi James.jimmy wrote: ↑Mon Jul 24, 2017 10:07 amDepends on what version of OpenSim you want to use. I would recommend using the 4.0 Beta API since there are convenience methods added to do this. The below code would give you the position and orientation of the OpenSim body in the Global.
Code: Select all
import org.opensim.modeling.* model = Model('gait2392_thelen2003muscle.osim') % get a reference to the state s = model.initSystem() % get a reference to the pelvis body pelvis = model.getBodySet().get(0) p0 = pelvis.getPositionInGround(s); r0 = pelvis.getTransformInGround(s).R; % Change the pelvis tilt model.getCoordinateSet().get(0).setValue(s,-10) % change the pelvis x location model.getCoordinateSet().get(3).setValue(s,2) p1 = pelvis.getPositionInGround(s); r1 = pelvis.getTransformInGround(s).R;
A brief description of what I am trying to solve: In my application, our subjects wear some sort of sensors and perform some daily activities. I have created a model containing our sensors (sensors are fixed to corresponding bodies using WeldJoint). I need to calculate orientation and velocity of sensors as a function of joint angles and joint angular velocities. I can use your proposed method to calculate global orientations, Was wondering if it's any methods available in MATLAB API to calculate velocity of a body in the global frame?
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Export Bone Geometry to .STL For Each Frame
I think you're looking for the getVelocityInGround() method, which is inherited from the Frame class (https://simtk.org/api_docs/opensim/api_ ... 4526ef9629). You can also type methodsview(pelvis) in MATLAB to see all available methods. You may want to see the following pages in the Confluence documentation:Was wondering if it's any methods available in MATLAB API to calculate velocity of a body in the global frame?
- "Common Scripting Commands" (https://simtk-confluence.stanford.edu/d ... g+Commands)
- "Scripting with Matlab" (https://simtk-confluence.stanford.edu/d ... ith+Matlab)
- Sina Porsa
- Posts: 5
- Joined: Sun Jul 15, 2018 4:51 pm
Re: Export Bone Geometry to .STL For Each Frame
That's exactly what I was looking for. Thanks!tkuchida wrote: ↑Wed Oct 17, 2018 7:09 amI think you're looking for the getVelocityInGround() method, which is inherited from the Frame class (https://simtk.org/api_docs/opensim/api_ ... 4526ef9629). You can also type methodsview(pelvis) in MATLAB to see all available methods. You may want to see the following pages in the Confluence documentation:Was wondering if it's any methods available in MATLAB API to calculate velocity of a body in the global frame?
- "Common Scripting Commands" (https://simtk-confluence.stanford.edu/d ... g+Commands)
- "Scripting with Matlab" (https://simtk-confluence.stanford.edu/d ... ith+Matlab)
One more question, is there any thing available to get the gravity vector in a local frame?
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Export Bone Geometry to .STL For Each Frame
See the Frame::expressVectorInAnotherFrame() method: https://simtk.org/api_docs/opensim/api_ ... 696dd48b02.is there any thing available to get the gravity vector in a local frame?
- Jom Pornthep
- Posts: 1
- Joined: Tue Jan 03, 2017 7:57 pm
Re: Export Bone Geometry to .STL For Each Frame
In case anyone stumbles across this thread from Google.
I made a python script to convert VTP to STL and export the default pose of an OpenSim model. It can't export the animation/frames, but you can either extend the script yourself or keep changing the default pose and running the script.
https://github.com/prnthp/opensim-stl-export
Cheers m8
I made a python script to convert VTP to STL and export the default pose of an OpenSim model. It can't export the animation/frames, but you can either extend the script yourself or keep changing the default pose and running the script.
https://github.com/prnthp/opensim-stl-export
Cheers m8