Visualization a model

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Visualization a model

Post by hamed kouchebaghi » Mon May 04, 2020 10:27 am

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

User avatar
Thomas Uchida
Posts: 1777
Joined: Wed May 16, 2012 11:40 am

Re: Visualization a model

Post by Thomas Uchida » Tue May 05, 2020 5:11 am

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).

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: Visualization a model

Post by hamed kouchebaghi » Tue May 05, 2020 9:55 am

thank you so much, that was helpful.
I want to visualize Arm26. what should I do at this step?

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: Visualization a model

Post by hamed kouchebaghi » Thu May 07, 2020 12:14 pm

tkuchida wrote:
Tue May 05, 2020 5:11 am
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).
where can I find the Arm26 model code to visualize in MATLAB ? as the example for arm model you previously sent me.
could you please help me ?

thank you
Hamed

User avatar
Thomas Uchida
Posts: 1777
Joined: Wed May 16, 2012 11:40 am

Re: Visualization a model

Post by Thomas Uchida » Thu May 07, 2020 2:52 pm

where can I find the Arm26 model code to visualize in MATLAB ?
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:

Code: Select all

import org.opensim.modeling.*
arm = Model('arm26.osim');
arm.setUseVisualizer(true);
state = arm.initSystem();
% etc.

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: Visualization a model

Post by hamed kouchebaghi » Sat May 09, 2020 11:49 am

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

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)
what should I do here ? could you help me with this please ?

User avatar
Thomas Uchida
Posts: 1777
Joined: Wed May 16, 2012 11:40 am

Re: Visualization a model

Post by Thomas Uchida » Sun May 10, 2020 7:40 am

Cannot open file arm26.osim. It may not exist or you do not have
permission to read it.
Matlab can't find the arm26.osim file. Easiest solution is to copy it into the same directory as your script.

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: Visualization a model

Post by hamed kouchebaghi » Wed May 13, 2020 10:35 am

Hello, hope you having good time.

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.
the problem about java exception didn't appear and the following window opened, but nothing shows in there. what's the problem ?
Screenshot (24).png
Screenshot (24).png (113.73 KiB) Viewed 422 times

User avatar
Thomas Uchida
Posts: 1777
Joined: Wed May 16, 2012 11:40 am

Re: Visualization a model

Post by Thomas Uchida » Thu May 14, 2020 8:53 am

the problem about java exception didn't appear and the following window opened, but nothing shows in there. what's the problem ?
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):

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);

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: Visualization a model

Post by hamed kouchebaghi » Fri May 15, 2020 11:18 pm

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 ?
Screenshot (25).png
Screenshot (25).png (160.49 KiB) Viewed 390 times

POST REPLY