Page 1 of 1

Error with computeStateVariableDerivatives

Posted: Fri Feb 23, 2018 9:49 am
by abheemreddy
Hello,

I am trying to compile a c++ program for optimizing muscles on Mac. I use the function computeStateVariableDerivatives within the file. Unfortunately I am receiving an error that says I cannot override the function from a void to a vector. Here is the source code that is getting a compilation error:

SimTK::Vector computeStateVariableDerivatives(const SimTK::State& s) const;

and here is the error I am recieving:

Virtual function 'computeStateVariableDerivatives' has a different return type ('SimTK::Vector' (aka 'Vector_<double>')) than the function it overrides (which has return type 'void')

The documentation shows that this function should be returning a vector, so why am I getting an error that it was originally returning void? This error did not come up when the file was run in visual studio, but now that it is being adapted for Mac there seems to be an issue. Could this possibly be a problem with the Xcode compiler?

Thank you

Re: Error with computeStateVariableDerivatives

Posted: Fri Feb 23, 2018 10:57 am
by chrisdembia
The signature of this function changed between 3.3 and 4.0 (GitHub).

Re: Error with computeStateVariableDerivatives

Posted: Mon Feb 26, 2018 8:05 am
by abheemreddy
Hi,

I believe that both the Mac and Windows versions that we are using are 3.3. I do not think that this is what is causing the issue. Do you have any other ideas on wha the problem may be?

Thanks

Re: Error with computeStateVariableDerivatives

Posted: Mon Feb 26, 2018 2:08 pm
by chrisdembia
In that case, to help, we need to see the code your code.

Re: Error with computeStateVariableDerivatives

Posted: Wed Feb 28, 2018 9:07 am
by abheemreddy
I think it will be difficult for me to post all the code, but I can try to help narrow down what the problem is. The error is occurring with the function

SimTK::Vector computeStateVariableDerivatives(const SimTK::State& s) const,

where Xcode says that

Virtual function 'computeStateVariableDerivatives' has a different return type ('SimTK::Vector' (aka 'Vector_<double>')) than the function it overrides (which has return type 'void').

This issue appears to be due to because the function computeStateVariableDerivatives is defined within the file component.h as

virtual void computeStateVariableDerivatives(const SimTK::State& s) const;

I believe that Xcode is attempting to override this virtual void output, and failing to do so, but instead we would like to override a virtual SimTK vector from the same function. As I mentioned before, on Microsoft, while using visual studio, this error does not occur. Has this issue come up before? Are you aware of any possible solution to this problem?

Thanks

Re: Error with computeStateVariableDerivatives

Posted: Wed Feb 28, 2018 1:14 pm
by chrisdembia
Akhil:

How did you obtain the copy of OpenSim you are using on Mac? The signature for `computeStateVariableDerivatives()` in Component.h is for OpenSim 4.0.

Re: Error with computeStateVariableDerivatives

Posted: Thu Mar 01, 2018 5:18 pm
by abheemreddy
I followed the steps from the README.md file that is within the OpenSim source download for OpenSim 3.3. The read me is located in the simbody-Simbody-3.5.3 zip. Although earlier I had downloaded the OpenSim 4.0 GUI beta for Mac.

Does this mean that the component.h virtual void should not be a part of OpenSim 3.3? What do you suggest that I do?

Thanks,
Akhil Bheemreddy

Re: Error with computeStateVariableDerivatives

Posted: Sun Mar 04, 2018 11:42 pm
by chrisdembia
Akhil:

There is no README.md in the OpenSim 3.3 source code. There *is* a README.md in the Simbody 3.5.3 source code, but this file does not explain how to build OpenSim.

The OpenSim 4.0 GUI beta comes with the OpenSim 4.0 API. You can check which copy of OpenSim is being used by your project by inspecting the value of the OpenSim_DIR CMake variable in your project (open the CMake GUI or open the CMakeCache.txt file in your build directory).
Does this mean that the component.h virtual void should not be a part of OpenSim 3.3?
It *is not* part of OpenSim 3.3.
What do you suggest that I do?
Both the OpenSim 3.3 and 4.0 source code can be used on Mac. I suggest you use whichever version your own code was written for. The instructions for building OpenSim 3.3 from source are here: https://simtk-confluence.stanford.edu/d ... rom+Source