Page 1 of 1

FeedbackControllerTemplate for plugin

Posted: Tue Mar 29, 2011 4:02 pm
by koobs77
Dear OpenSim developers,

I am trying to build a simple PD controller using plugin in OpenSim2.2.
So, I tried to build a plugin with "FeedbackControllerTemplate.cpp" under /sdk/templates folder.
However, I have got several error messages relating to missing header files. ( e.g. "#include <OpenSim/Common/rdMath.h>" )
I guess this code is not update yet since OpenSim2.0 is released.
Actually, I succeeded in building when I use OpenSim1.9.1 libraries and header files.

Please check this finding is right or not.
Thanks,

RE: FeedbackControllerTemplate for plugin

Posted: Tue Mar 29, 2011 9:13 pm
by aymanh
Hi Bonsung,

The headers have been rearranged since version 2.0 that you'd only need to include OpenSim/OpenSim.h and it pulls in all the needed headers (CMakeLists.txt files were updated accordingly). You can try that but there're many other important changes to the underlying classes. If you can't get this to work, you may want to start from the API example program found in the 2.2 distribution under ${install_dir}\sdk\APIExamples\ControllerExample

Please let me know how that goes,
-Ayman

RE: FeedbackControllerTemplate for plugin

Posted: Wed Mar 30, 2011 7:23 am
by koobs77
Thank you for response, Dr. Habib.

I am trying to build a plugin as you said.
By the way, Do I need to install the latest SimTK libraries for this compile?
I am using 1.5.1 version of SimTK now.
(I have several error relating to SimTK.)
Thank you for your time,
Best,

-Bonsung

RE: FeedbackControllerTemplate for plugin

Posted: Wed Mar 30, 2011 8:01 am
by koobs77
Dear Dr. Habib,

I guess there are some changes since version 2.0 including OpenSim::Model class.

I have several error message as follows.
(These errors are a part of whole errors.)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1>FeedbackControllerTemplate.cpp
1>..\plugin\FeedbackControllerTemplate.cpp(81) : error C2664: 'OpenSim::Controller::Controller(OpenSim::Model &)' : cannot convert parameter 1 from 'OpenSim::Model *' to 'OpenSim::Model &'
1>..\plugin\FeedbackControllerTemplate.cpp(125) : error C2259: 'OpenSim::FeedbackControllerTemplate' : cannot instantiate abstract class
1> due to following members:
1> 'double OpenSim::Controller::computeControl(const SimTK::State &,int) const' : is abstract
1> c:\opensim\opensim2.2\sdk\include\opensim\simulation\control\Controller.h(273) : see declaration of 'OpenSim::Controller::computeControl'
1>..\plugin\FeedbackControllerTemplate.cpp(273) : error C2039: 'getNumActuators' : is not a member of 'OpenSim::Model'
1> C:\OpenSim\OpenSim2.2\sdk\include\OpenSim/Simulation/Model/Model.h(90) : see declaration of 'OpenSim::Model'
1>..\plugin\FeedbackControllerTemplate.cpp(279) : error C2819: type 'OpenSim::AnalysisSet' does not have an overloaded member 'operator ->'
1> c:\opensim\opensim2.2\sdk\include\opensim\simulation\model\AnalysisSet.h(55) : see declaration of 'OpenSim::AnalysisSet'
1> did you intend to use '.' instead?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

If you need, I can send the source code to you.
Thanks,

P.S, If I start from API example to build a plugin for OpenSim, It will take long to modify, I guess.

-Bonsung

RE: FeedbackControllerTemplate for plugin

Posted: Wed Mar 30, 2011 9:10 am
by aymanh
Hi Bonsung,

You shouldn't expect the code based on 2.2 (and SimTK 2.1) to compile against OpenSim 1.5.1 headers and associated SimTK libraries which are way older. Please try 2.2 out of the box and use both headers and libraries from the same distribution and let me know how it goes, I'd be happy to help you resolve any issues releated to that.

Good luck,
-Ayman


RE: FeedbackControllerTemplate for plugin

Posted: Wed Mar 30, 2011 11:36 am
by koobs77
Dear Dr. Habib,

Thank you for your response,
By the way, I think I made you confused.
I did not use OpenSim 1.5.1, I used SimTK 1.5.1.

As you said, I installed SimTK 2.1 and tried to build again the "FeedBackControllerTemplate.cpp".
But I failed with following errors.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2>Compiling...
2>FeedbackControllerTemplate.cpp
2>..\plugin\FeedbackControllerTemplate.cpp(81) : error C2664: 'OpenSim::Controller::Controller(OpenSim::Model &)' : cannot convert parameter 1 from 'OpenSim::Model *' to 'OpenSim::Model &'
2>..\plugin\FeedbackControllerTemplate.cpp(125) : error C2259: 'OpenSim::FeedbackControllerTemplate' : cannot instantiate abstract class
2> due to following members:
2> 'double OpenSim::Controller::computeControl(const SimTK::State &,int) const' : is abstract
2> c:\opensim\opensim2.2\sdk\include\opensim\simulation\control\Controller.h(273) : see declaration of 'OpenSim::Controller::computeControl'
2>..\plugin\FeedbackControllerTemplate.cpp(273) : error C2039: 'getNumActuators' : is not a member of 'OpenSim::Model'
2> C:\OpenSim\OpenSim2.2\sdk\include\OpenSim/Simulation/Model/Model.h(90) : see declaration of 'OpenSim::Model'
2>..\plugin\FeedbackControllerTemplate.cpp(279) : error C2819: type 'OpenSim::AnalysisSet' does not have an overloaded member 'operator ->'
2> c:\opensim\opensim2.2\sdk\include\opensim\simulation\model\AnalysisSet.h(55) : see declaration of 'OpenSim::AnalysisSet'
2> did you intend to use '.' instead?
.......
.......
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I replaced every header files in FeedbackControllerTemplate.cpp to "#include <OpenSim/OpenSim.h>" except [#include "osimPluginDLL.h"]

Thank you for your help and time in advance,
Best,

P.S. If you need these code, please let me know I will send it to you soon.

-Bonsung


RE: FeedbackControllerTemplate for plugin

Posted: Wed Mar 30, 2011 11:45 am
by aymanh
Dear Bonsung,

There should be no need whatsoever to install SimTK libararies separately, they're already included with the OpenSim distribution. Actually it would be error prone since you'd have more than one version of the headers/libraries on your machine and what you get during runtime depends on the Path.

Have you tried the ControllerExample in OpenSim 2.2? I just worry that the FeedbackController would have to undergo significant changes before it's usable again due to API changes but I can try to build that if you submit a bug report and attach the source to it.

Best regards,
-Ayman

RE: FeedbackControllerTemplate for plugin

Posted: Wed Mar 30, 2011 1:19 pm
by koobs77
Thank you for your response.
After removing every duplicated libraries and header files, I tried to build the plugin again.
However, I had the same problem as I got before.

I submit a bug report and attach the source.
Please check it for me.
Thank you so much.
Best,

-Bonsung

RE: FeedbackControllerTemplate for plugin

Posted: Wed Mar 30, 2011 1:24 pm
by koobs77
By the way, I succeeded in building the "ControllerExample.cpp"
Thanks,

But I need a code for plugin contoller.
Sorry about that.

-Bonsung

RE: FeedbackControllerTemplate for plugin

Posted: Wed Mar 30, 2011 2:51 pm
by aymanh
Hi Bonsung,

You didn't attach the source file, can you please do? On another note, can you modify the ControllerExample to do what you want?

Best regards,
-Ayman