Create a custom muscle model with subcomponents

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Giuseppe Scaccuto
Posts: 20
Joined: Mon Sep 24, 2018 9:32 am

Create a custom muscle model with subcomponents

Post by Giuseppe Scaccuto » Thu Oct 18, 2018 4:40 am

Hi all,
I'm trying to compile a custom muscle model class with OpenSim 4.0 API but it seems it doesn't add two subcomponents related to the main class.

I used this: https://simtk.org/projects/afferents

This muscle extends Millard2012EquilibriumMuscle class and it adds two subcomponents which extend ModelComponent class.

My questions are:
1. For subcomponents class, I have to override ModelComponent methods calling Super::method() within them or it's useless?
2. For main component class, I can execute adoptSubComponent() method in the constructor for each subcomponent or I should use a different approach?

With these choices, It seems I can't load this muscle model in MATLAB as a plugin. It returns this error:

Code: Select all

Java exception occurred:
java.io.IOException: Model::equilibrateMuscles() Component has no underlying System.
You must call initSystem() on the top-level Component (i.e. Model) first.
	In Object '<no-name>' of type Mileusnic06Spindle.
	Thrown at component.cpp:798 in getStateVariableValue().

	at org.opensim.modeling.opensimActuatorsAnalysesToolsJNI.ForwardTool_run(Native Method)

	at org.opensim.modeling.ForwardTool.run(ForwardTool.java:117)
Thanks for your support.

Tags:

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

Re: Create a custom muscle model with subcomponents

Post by Thomas Uchida » Thu Oct 18, 2018 10:21 am

There may be some helpful information in the API Guide (in the doxygen documentation here: https://simtk.org/api_docs/opensim/api_ ... Guide.html). See, in particular, the "Writing your own Component" section (https://simtk.org/api_docs/opensim/api_ ... components).

User avatar
Giuseppe Scaccuto
Posts: 20
Joined: Mon Sep 24, 2018 9:32 am

Re: Create a custom muscle model with subcomponents

Post by Giuseppe Scaccuto » Fri Oct 19, 2018 4:21 am

I read it but I don't understand how test my component with program in testComponents.cpp

How can I use this tool?

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

Re: Create a custom muscle model with subcomponents

Post by Thomas Uchida » Fri Oct 19, 2018 8:12 am

I don't understand how test my component
If you are creating a new muscle and compiling from source, you could add test cases to testMuscles.cpp (https://github.com/opensim-org/opensim- ... uscles.cpp), as has been done for the other muscles.

User avatar
Giuseppe Scaccuto
Posts: 20
Joined: Mon Sep 24, 2018 9:32 am

Re: Create a custom muscle model with subcomponents

Post by Giuseppe Scaccuto » Tue Nov 06, 2018 5:05 am

I have a problem with connection between model components.

I read API Guide on "Writing your own component" and it seems it need a socket to establish this connection. So I created a socket for both subcomponents and I connect it to the main component and when I compile and load the model plugin in OpenSim GUI it works but when I open the .osim model file, I got this error:

error.png
error.png (10.23 KiB) Viewed 687 times

I can't understand if there's something wrong with it, so I report XML code related to the .osim file too.

error2.png
error2.png (45.72 KiB) Viewed 687 times

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

Re: Create a custom muscle model with subcomponents

Post by Thomas Uchida » Tue Nov 06, 2018 6:14 pm

The "Hopper Device" example on GitHub demonstrates some of the new features of the 4.0 API and might be helpful: https://github.com/opensim-org/opensim- ... pperDevice

User avatar
Giuseppe Scaccuto
Posts: 20
Joined: Mon Sep 24, 2018 9:32 am

Re: Create a custom muscle model with subcomponents

Post by Giuseppe Scaccuto » Wed Nov 07, 2018 8:53 am

Well, when I load the hopper .osim model in OpenSim GUI, It returns same error while it works correctly on MATLAB.

Also my .osim model seems to work on MATLAB.

It should be a problem with OpenSim? :|

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

Re: Create a custom muscle model with subcomponents

Post by Thomas Uchida » Wed Nov 07, 2018 11:40 am

It is very surprising for a model to work in MATLAB but not in the GUI. Are the MATLAB and GUI versions you are using derived from the same 4.0 beta? Did you use an installer or build from source?

User avatar
Giuseppe Scaccuto
Posts: 20
Joined: Mon Sep 24, 2018 9:32 am

Re: Create a custom muscle model with subcomponents

Post by Giuseppe Scaccuto » Thu Nov 08, 2018 2:46 am

I used the Installer (4.0 Beta) for OpenSim GUI but I configured MATLAB with OpenSim Libraries builded from source core SDK (4.0 Beta).

User avatar
Giuseppe Scaccuto
Posts: 20
Joined: Mon Sep 24, 2018 9:32 am

Re: Create a custom muscle model with subcomponents

Post by Giuseppe Scaccuto » Wed Nov 14, 2018 4:30 am

UPDATE: Ok, It works now!

The problem was in the socket tag on xml code in the .osim model file.

As reported in: viewtopicPhpbb.php?f=91&t=9636&p=26386&start=0&view=

Every tag should be contain the suffix "_connectee_name".

POST REPLY