Page 1 of 1

Possible issue with computeStateVariableDerivatives()

Posted: Tue Jul 30, 2019 7:15 am
by lsboers
Hi Guys,

I have an issue with the computeStateVariableDerivatives command. Both in C++ and Matlab, and only for certain states, the handle returns NaNs or -1.#IND. It will return these values for ALL acceleration values within the resulting state derivatives variable.

Therefore I am wondering when this function returns NaNs, is it an issue with too small/ big nrs, or something else entirely?

Hope someone can give me some details on this function!

Regards,

Lars Boers

Re: Possible issue with computeStateVariableDerivatives()

Posted: Wed Jul 31, 2019 8:27 am
by nicos1993
Hi Lars,

Are you initializing the system and setting the state variables prior to calling computeStateVariableDerivatives?

I do something like this in Matlab:

% Import the OpenSim modeling classes
import org.opensim.modeling.*

% Read in the osim model
osimModel = Model('aModel.osim');

% Initialize the model
osimState = osimModel.initSystem();

% Get the number of states;
nStates = osimModel.getNumStateVariables();

for i = 0:nStates-1
osimState.updY().set(i,states(i+1,1)); % 'i' is the index of a particular state variable & states is a vector of
% state variable values which you want to set
end

% Calculate derivatives
osimModel.computeStateVariableDerivatives(osimState);

Hope that helps!

Nicos