Hi,
Sorry for bringing a old topic.
I am trying to build the tutorial of plugin an Analysis tool and CoupledBushingForce provided by OpenSim.
I am able to use them in OpenSim GUI. But they does not work in Matlab.
Although I have read some other related posts:
viewtopicPhpbb.php?f=91&t=3942&p=8878&h ... tlab#p8878
viewtopicPhpbb.php?f=91&t=5974&p=15163&start=0&view=
http://simtk-confluence.stanford.edu:80 ... ng+Plugins
I am still not able to get it works.
When I used loadlibrary(pathDLL, pathHeader), the error I got for the Analysis plugin is:
"...C:\OpenSim 3.3\sdk\include\OpenSim\Simulation\Model\Analysis.h(32) : fatal error C1083: Cannot open include file:
'OpenSim/Simulation/osimSimulationDLL.h': No such file or directory"
the error with CoupledBushingForce is:
"...C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\eh.h(27) : fatal error C1189: #error : "eh.h is only for
C++!""
I also tried to used Model.LoadOpenSimLibrary(pathtoDLL), although this command runs without showing error, when I try to use the plugin class (eg. force = CoupledBushingForce(); ), it shows "Undefined function or variable 'CoupledBushingForce'."
I have tried to create a simple dll function, and load in Matlab, and it works well
(http://stackoverflow.com/questions/1841 ... and-matlab)
I wonder is there any differences between creating a dll which is a class and dll which is a function.
Thank you for reading my long post.
Vinh
Error load plugin in Matlab
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: Error load plugin in Matlab
The C1083 error ("Cannot open include file: 'OpenSim/Simulation/osimSimulationDLL.h': No such file or directory") points to one problem. Have you added the directory containing the plugin to the "librarypath" in Matlab? See http://simtk-confluence.stanford.edu:80 ... ng+Plugins, point 2 under the "Matlab" heading.
As Ayman explained here viewtopicPhpbb.php?f=91&t=5974&p=15163, you will not be able to create an instance of CoupledBushingForce in Matlab.
As Ayman explained here viewtopicPhpbb.php?f=91&t=5974&p=15163, you will not be able to create an instance of CoupledBushingForce in Matlab.
- Vinh Nguyen
- Posts: 21
- Joined: Fri Sep 26, 2014 8:53 pm
Re: Error load plugin in Matlab
Thank you very much for your response, Tom.
I had added directory containing the plugin to the "librarypath".
For the CoupledBushingForce, if I have OpenSim source code, add the CoupledBushingForce into Actuator folder, use CMake to create the solution and then build the OpenSim. Do you think this way will work?
I had added directory containing the plugin to the "librarypath".
For the CoupledBushingForce, if I have OpenSim source code, add the CoupledBushingForce into Actuator folder, use CMake to create the solution and then build the OpenSim. Do you think this way will work?
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: Error load plugin in Matlab
You would also need to register the object using Object::registerType() (see OpenSim/Simulation/RegisterTypes_osimSimulation.cpp) and may need to modify the SWIG bindings to Java. You could try, but it might not be so straightforward.if I have OpenSim source code, add the CoupledBushingForce into Actuator folder, use CMake to create the solution and then build the OpenSim. Do you think this way will work?
- Vinh Nguyen
- Posts: 21
- Joined: Fri Sep 26, 2014 8:53 pm
Re: Error load plugin in Matlab
I will try and let you know if it works.
Thanks again.
Thanks again.
- Vinh Nguyen
- Posts: 21
- Joined: Fri Sep 26, 2014 8:53 pm
Re: Error load plugin in Matlab
Well, it does not work because OpenSim 3.3 source zip does not contain file for working with Matlab.
http://simtk-confluence.stanford.edu:80 ... rom+Source
Come back to the issue of using plugin with Matlab, my concern is what kind of plugin class that can be used in Matlab?
And if I cannot create a new instance of plugin, could Matlab realize the plugin class by reading a .osim model that uses the plugin class?
Thanks,
Vinh
http://simtk-confluence.stanford.edu:80 ... rom+Source
Come back to the issue of using plugin with Matlab, my concern is what kind of plugin class that can be used in Matlab?
And if I cannot create a new instance of plugin, could Matlab realize the plugin class by reading a .osim model that uses the plugin class?
Thanks,
Vinh
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: Error load plugin in Matlab
Have you tried using Model.LoadOpenSimLibrary()? See viewtopicPhpbb.php?f=91&t=6387.
- Vinh Nguyen
- Posts: 21
- Joined: Fri Sep 26, 2014 8:53 pm
Re: Error load plugin in Matlab
Thank you Tom, I just figured out I always tried to create a new instance of plugin when I tested using Model.LoadOpenSimLibrary() command. That is why I got error. I loaded a .osim file that uses the plugin and try to read, modify it. It works perfectly now!
I think that would be good if I summarize some notes about using plugin with Matlab which I learned here. This may help others quickly get their plugins worked.(My OpenSim version is 3.3)
1. Instructions for setup
http://simtk-confluence.stanford.edu:80 ... ng+Plugins
2. You will not be able to create a new instance of plugin in scripting with Matlab
viewtopicPhpbb.php?f=91&t=5974&p=15163
What you can do is to create a model that already had the plugin, then you can modify and use it.
3. To load the plugin into Matlab, you can use command loadlibrary() or Model.LoadOpenSimLibrary(‘pathtoDLLfile’). I never succeed using loadlibrary(). Using Model.LoadOpenSimLibrary() is much easier.
viewtopicPhpbb.php?f=91&t=6387
4. OpenSim build from source code does not contain the files for working with Matlab.
http://simtk-confluence.stanford.edu:80 ... rom+Source
5. Other related posts:
viewtopicPhpbb.php?f=91&t=3942
viewtopicPhpbb.php?f=91&t=4904&p=11969& ... ary#p11969
viewtopicPhpbb.php?f=91&t=6333&p=16191&start=0&view
Thanks!
I think that would be good if I summarize some notes about using plugin with Matlab which I learned here. This may help others quickly get their plugins worked.(My OpenSim version is 3.3)
1. Instructions for setup
http://simtk-confluence.stanford.edu:80 ... ng+Plugins
2. You will not be able to create a new instance of plugin in scripting with Matlab
viewtopicPhpbb.php?f=91&t=5974&p=15163
What you can do is to create a model that already had the plugin, then you can modify and use it.
3. To load the plugin into Matlab, you can use command loadlibrary() or Model.LoadOpenSimLibrary(‘pathtoDLLfile’). I never succeed using loadlibrary(). Using Model.LoadOpenSimLibrary() is much easier.
viewtopicPhpbb.php?f=91&t=6387
4. OpenSim build from source code does not contain the files for working with Matlab.
http://simtk-confluence.stanford.edu:80 ... rom+Source
5. Other related posts:
viewtopicPhpbb.php?f=91&t=3942
viewtopicPhpbb.php?f=91&t=4904&p=11969& ... ary#p11969
viewtopicPhpbb.php?f=91&t=6333&p=16191&start=0&view
Thanks!