Error with computeStateVariableDerivatives

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Akhil Bheemreddy
Posts: 14
Joined: Wed Jul 26, 2017 9:41 am

Error with computeStateVariableDerivatives

Post by Akhil Bheemreddy » Fri Feb 23, 2018 9:49 am

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

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Error with computeStateVariableDerivatives

Post by Christopher Dembia » Fri Feb 23, 2018 10:57 am

The signature of this function changed between 3.3 and 4.0 (GitHub).

User avatar
Akhil Bheemreddy
Posts: 14
Joined: Wed Jul 26, 2017 9:41 am

Re: Error with computeStateVariableDerivatives

Post by Akhil Bheemreddy » Mon Feb 26, 2018 8:05 am

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

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Error with computeStateVariableDerivatives

Post by Christopher Dembia » Mon Feb 26, 2018 2:08 pm

In that case, to help, we need to see the code your code.

User avatar
Akhil Bheemreddy
Posts: 14
Joined: Wed Jul 26, 2017 9:41 am

Re: Error with computeStateVariableDerivatives

Post by Akhil Bheemreddy » Wed Feb 28, 2018 9:07 am

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

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Error with computeStateVariableDerivatives

Post by Christopher Dembia » Wed Feb 28, 2018 1:14 pm

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.

User avatar
Akhil Bheemreddy
Posts: 14
Joined: Wed Jul 26, 2017 9:41 am

Re: Error with computeStateVariableDerivatives

Post by Akhil Bheemreddy » Thu Mar 01, 2018 5:18 pm

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

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Error with computeStateVariableDerivatives

Post by Christopher Dembia » Sun Mar 04, 2018 11:42 pm

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

POST REPLY