Access EOM/ ODE to perform FWD outside Opensim

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Lars Boers
Posts: 14
Joined: Thu Sep 06, 2018 2:23 am

Access EOM/ ODE to perform FWD outside Opensim

Post by Lars Boers » Wed Jan 23, 2019 11:52 am

Hi Guys,

I want to perform FWD within Matlab and change performance criteria/ constraints. Is it possible to do this and access EOM of .osim models through Matlab?

Thanks in advance,

Lars Boers

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Dimitar Stanev » Sat Jan 26, 2019 8:53 am

It depends on the variables that you need to access; some quantities cannot be accessed using the Matlab API.

viewtopicPhpbb.php?f=91&t=9804&p=27088&start=0&view=

User avatar
Lars Boers
Posts: 14
Joined: Thu Sep 06, 2018 2:23 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Lars Boers » Tue Feb 19, 2019 9:13 pm

Hi Dimitar,
(using your instructions in the other post) I have succeeded in making a MEX wrapper for my project, however, during the setup of my .osim model it is stated that the object: Coordinateactuator is not recognized. Is this a problem of the simbody installation progress or an issue somewhere else?

Thanks!

Lars Boers

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Dimitar Stanev » Wed Feb 20, 2019 1:39 am

Make sure to include

Code: Select all

include <OpenSim/Actuators/CoordinateActuator.h>
The actual name of the object is CoordinateActuator

User avatar
Lars Boers
Posts: 14
Joined: Thu Sep 06, 2018 2:23 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Lars Boers » Sat Feb 23, 2019 3:51 pm

Hi Dimitar,

Thanks for the tips, however after adding the given code (with a # is presumed), I still get the following error:

Object::newInstanceOfType(): object type 'CoordinateActuator' is not a registered Object!
Object type CoordinateActuator not recognized

I was unable to find the answer for this problem online, so do you have any more information on the error code?

Regards,

Lars Boers

User avatar
Lars Boers
Posts: 14
Joined: Thu Sep 06, 2018 2:23 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Lars Boers » Sat Feb 23, 2019 4:30 pm

After trying a few tries, I tried reconstructing the mex file in CMake. I got the following errors after trying (your) base CmakeList:

CMake Error at C:/Simbody/cmake/SimbodyConfig.cmake:104 (add_library):
add_library cannot create imported target "blas" because another target
with the same name already exists.
Call Stack (most recent call first):
C:/OpenSim 4.0/cmake/OpenSimConfig.cmake:102 (find_package)
CMakeLists.txt:50 (FIND_PACKAGE)

I was (again) unable to find information on this error online, so could you explain what this means?

Regards,

Lars Boers

User avatar
Lars Boers
Posts: 14
Joined: Thu Sep 06, 2018 2:23 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Lars Boers » Sat Feb 23, 2019 8:14 pm

One last question,

How do I add the OpenSIm Include directory to the CmakeList. I tried using the link_direcotry/Include_directory command but this doesnt work


Thanks!

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Dimitar Stanev » Sun Feb 24, 2019 10:35 am

For some reason CoordinateActuator is not register. Try this:

Code: Select all

Object::registerType( CoordinateActuator());
This version will probably not work with v4.0. Try modifying your CMake according to the sample provided by the developers:

https://github.com/opensim-org/opensim- ... eLists.txt

After finding the OpenSim library

Code: Select all

find_package(OpenSim)
OpenSim_* variables are defined for the include directory, library directory and libraries:

Code: Select all

include_directories(${OpenSim_INCLUDE_DIRS})
link_directories(${OpenSim_LIB_DIR}) 
target_link_libraries(target ${OpenSim_LIBRARIES}) 

User avatar
Lars Boers
Posts: 14
Joined: Thu Sep 06, 2018 2:23 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Lars Boers » Sun Feb 24, 2019 11:29 am

Hi Dimitar,

Thanks for the tips, I will try this out!

What exactly do you mean with:

This version will probably not work with v4.0. Try modifying your CMake according to the sample provided by the developers:

Do I modify the OpenSim CMake file or do I modify the CMake file that I am using for the MEX wrapper? I'm guessing the prior because the target_include_drectories now gives the following error:

CMake Error at CMakeLists.txt:16 (target_link_libraries):
Cannot specify link libraries for target "target" which is not built by
this project.

Also, do I need to pass the same statements for mexplus which I am now passing for OpenSim (find/locate etc.)?

Again, many thanks!


Regards,

Lars Boers

User avatar
Lars Boers
Posts: 14
Joined: Thu Sep 06, 2018 2:23 am

Re: Access EOM/ ODE to perform FWD outside Opensim

Post by Lars Boers » Sun Feb 24, 2019 11:45 am

Hi Dimitar,

Another question (since I am a C++ rookie), where do I place the object registration code for the CoordinateActuator? In the .h/.cpp file or in the CMake file?


Regards,

Lars Boers

POST REPLY