Accessing ThelenMuscle2003 through model class tree

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Anthony Santago
Posts: 15
Joined: Mon Feb 15, 2010 11:33 am

Accessing ThelenMuscle2003 through model class tree

Post by Anthony Santago » Wed Mar 06, 2013 8:21 am

I am attempting to access properties of a specific muscle type through the model tree using the Matlab API interface. However, I am unsure how to go from the Muscle class to the ThelenMuscle2003 class. ie

import org.opensim.modeling.*
modelName = Test.osim;
Model = model(modelName);
MuscleSet = Model.getMuscles();
Muscle1 = MuscleSet.get(0);
activationTimeConstant = Muscle1.getActivationTimeConstant();


When I run the line:
activationTimeConstant = Muscle1.getActivationTimeConstant();
I receive the following error:
No appropriate method, property, or field getActivationTimeConstant for class org.opensim.modeling.Muscle

This makes sense considering the muscle class does not have access to the that function. However, I would like to have access to that function. Is there a way to traverse the model tree to obtain access to that class instance?

User avatar
Ayman Habib
Posts: 2236
Joined: Fri Apr 01, 2005 12:24 pm

Re: Accessing ThelenMuscle2003 through model class tree

Post by Ayman Habib » Fri Mar 08, 2013 10:13 am

Hi Anthony,

You need to downcast to the correct type that has the methods available using the syntax:

Code: Select all

Thelen2003Muscle.safeDowncase(Muscle1)
The result of the call will have the type Thelen2003Muscle and so its full set of methods will be available.

Hope this helps,
-Ayman

User avatar
Donald Hume
Posts: 4
Joined: Sun Sep 05, 2010 3:24 pm

Re: Accessing ThelenMuscle2003 through model class tree

Post by Donald Hume » Mon Apr 28, 2014 9:19 am

I ran into this same problem and the syntax was a bit different than Ayman suggested below, but thank you very much for pointing me in the correct direction.

Code: Select all

Muscle1 = Thelen2003Muscle.safeDownCast(Muscle1);

POST REPLY