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?
Accessing ThelenMuscle2003 through model class tree
- Anthony Santago
- Posts: 15
- Joined: Mon Feb 15, 2010 11:33 am
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Accessing ThelenMuscle2003 through model class tree
Hi Anthony,
You need to downcast to the correct type that has the methods available using the syntax:
The result of the call will have the type Thelen2003Muscle and so its full set of methods will be available.
Hope this helps,
-Ayman
You need to downcast to the correct type that has the methods available using the syntax:
Code: Select all
Thelen2003Muscle.safeDowncase(Muscle1)
Hope this helps,
-Ayman
- Donald Hume
- Posts: 4
- Joined: Sun Sep 05, 2010 3:24 pm
Re: Accessing ThelenMuscle2003 through model class tree
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);