Compute magnitude of ExpressionBasedCoordinateForce
Posted: Fri Apr 23, 2021 3:24 pm
Hi all,
I'm trying to compute the magnitude of an ExpressionBasedCoordinateForce in my model in Matlab, given the model's state. I can extract the force object of interest like this, for the case of the EBCF that defines the passive hip flexion moment:
and try to compute the force magnitude for a certain state:
This produces an error "Check for missing argument or incorrect argument data type in call to function 'computeForce'.", which sounds like I'm missing arguments that computeForce wants. I checked the documentation and it looks like computeForce wants the following inputs: state, bodyForces, generalizedForces, and I'm unsure what to input for the latter two arguments.
From the documentation, it also looks like ExpressionBasedCoordinateForce has a function "getForceMagnitude" with state as its only input, which sounds like what I want and makes sense for this type of force (its inputs are a generalized coordinate and the associated generalized speed), but when I run force.getForceMagnitude(state), I get an error "Unrecognized function or variable 'getForceMagnitude'." I think it's because my force object is of variable type "Force" and not "ExpressionBasedCoordinateForce".
Summary questions:
(1) What inputs is computeForce expecting for bodyForces and generalizedForces arguments?
(2) Can an ExpressionBasedCoordinateForce be extracted from the model with variable type "ExpressionBasedCoordinateForce" so that it knows about getForceMagnitude?
Thanks much,
Ross
I'm trying to compute the magnitude of an ExpressionBasedCoordinateForce in my model in Matlab, given the model's state. I can extract the force object of interest like this, for the case of the EBCF that defines the passive hip flexion moment:
Code: Select all
forceSet = model.getForceSet();
force = forceSet.get('PasMom_hip_flexion_r');
Code: Select all
current_force_mag = force.computeForce(state)
From the documentation, it also looks like ExpressionBasedCoordinateForce has a function "getForceMagnitude" with state as its only input, which sounds like what I want and makes sense for this type of force (its inputs are a generalized coordinate and the associated generalized speed), but when I run force.getForceMagnitude(state), I get an error "Unrecognized function or variable 'getForceMagnitude'." I think it's because my force object is of variable type "Force" and not "ExpressionBasedCoordinateForce".
Summary questions:
(1) What inputs is computeForce expecting for bodyForces and generalizedForces arguments?
(2) Can an ExpressionBasedCoordinateForce be extracted from the model with variable type "ExpressionBasedCoordinateForce" so that it knows about getForceMagnitude?
Thanks much,
Ross