Visualization a model
- hamed kouchebaghi
- Posts: 47
- Joined: Thu Nov 14, 2019 12:11 pm
Visualization a model
hello dear all,
I have difficulty in visualization of a model through MATLAB. could you give me a step by step to-do list or maybe the code which I have to run?
And I'd better say that I have created the interface between the two software.
Thanks and the Best,
Hamed
I have difficulty in visualization of a model through MATLAB. could you give me a step by step to-do list or maybe the code which I have to run?
And I'd better say that I have created the interface between the two software.
Thanks and the Best,
Hamed
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: Visualization a model
There is an example on the GitHub page here: https://github.com/opensim-org/opensim-core (scroll down to the "Simple example" heading and expand the "Matlab" section).
- hamed kouchebaghi
- Posts: 47
- Joined: Thu Nov 14, 2019 12:11 pm
Re: Visualization a model
thank you so much, that was helpful.
I want to visualize Arm26. what should I do at this step?
I want to visualize Arm26. what should I do at this step?
- hamed kouchebaghi
- Posts: 47
- Joined: Thu Nov 14, 2019 12:11 pm
Re: Visualization a model
where can I find the Arm26 model code to visualize in MATLAB ? as the example for arm model you previously sent me.tkuchida wrote: ↑Tue May 05, 2020 5:11 amThere is an example on the GitHub page here: https://github.com/opensim-org/opensim-core (scroll down to the "Simple example" heading and expand the "Matlab" section).
could you please help me ?
thank you
Hamed
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: Visualization a model
You can just adapt the code from the example on GitHub to read in a model file rather than building the model programmatically, something like this:where can I find the Arm26 model code to visualize in MATLAB ?
Code: Select all
import org.opensim.modeling.*
arm = Model('arm26.osim');
arm.setUseVisualizer(true);
state = arm.initSystem();
% etc.
- hamed kouchebaghi
- Posts: 47
- Joined: Thu Nov 14, 2019 12:11 pm
Re: Visualization a model
I replaced the code you sent with the first part of the code on Github, and ran it but nothing will appear and I face this error
what should I do here ? could you help me with this please ?
Code: Select all
Java exception occurred:
java.io.IOException: Object: Cannot open file arm26.osim. It may not exist or you do not have
permission to read it.
Thrown at object.cpp:105 in Object().
at org.opensim.modeling.opensimSimulationJNI.new_Model__SWIG_1(Native Method)
at org.opensim.modeling.Model.<init>(Model.java:783)
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: Visualization a model
Matlab can't find the arm26.osim file. Easiest solution is to copy it into the same directory as your script.Cannot open file arm26.osim. It may not exist or you do not have
permission to read it.
- hamed kouchebaghi
- Posts: 47
- Joined: Thu Nov 14, 2019 12:11 pm
Re: Visualization a model
Hello, hope you having good time.
I copied arm26.osim file to the Current Folder in MATLAB and ran the following code
the problem about java exception didn't appear and the following window opened, but nothing shows in there. what's the problem ?
I copied arm26.osim file to the Current Folder in MATLAB and ran the following code
Code: Select all
import org.opensim.modeling.*
arm = Model('arm26.osim');
arm.setUseVisualizer(true);
state = arm.initSystem();
% etc.
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: Visualization a model
The last line ("etc.") means that you should fill in the rest of the code from the example (sorry if that was not clear). Here is the code in full (my best guess, at least, since I don't have Matlab set up to test it):the problem about java exception didn't appear and the following window opened, but nothing shows in there. what's the problem ?
Code: Select all
import org.opensim.modeling.*
arm = Model('arm26.osim');
arm.setUseVisualizer(true);
state = arm.initSystem();
% Fix the shoulder at its default angle and begin with the elbow flexed.
shoulder.getCoordinate().setLocked(state, true);
elbow.getCoordinate().setValue(state, 0.5 * pi);
arm.equilibrateMuscles(state);
% Configure the visualizer
viz = arm.updVisualizer().updSimbodyVisualizer();
viz.setBackgroundColor(Vec3(0)); % white
viz.setGroundHeight(-2)
% Simulate.
manager = Manager(arm);
state.setTime(0);
manager.initialize(state);
state = manager.integrate(10.0);
- hamed kouchebaghi
- Posts: 47
- Joined: Thu Nov 14, 2019 12:11 pm
Re: Visualization a model
thank you for your help in advance,
I copied the code into the command window of matlab and ran it which you sent me, but I faced the following problem. what's wrong with it ?
I copied the code into the command window of matlab and ran it which you sent me, but I faced the following problem. what's wrong with it ?