Possible issue with computeStateVariableDerivatives()

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Lars Boers
Posts: 14
Joined: Thu Sep 06, 2018 2:23 am

Possible issue with computeStateVariableDerivatives()

Post by Lars Boers » Tue Jul 30, 2019 7:15 am

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

Tags:

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

Re: Possible issue with computeStateVariableDerivatives()

Post by Nicos Haralabidis » Wed Jul 31, 2019 8:27 am

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

POST REPLY