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
Possible issue with computeStateVariableDerivatives()
- Lars Boers
- Posts: 14
- Joined: Thu Sep 06, 2018 2:23 am
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: Possible issue with computeStateVariableDerivatives()
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
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