Hello Christopher,
Thanks for your response here.
My initial approach was basically following the ControllerExample where I write a new class (PDController) based on the Controller class as part of my main program. Then I add the controller to the model using these calls:
Code: Select all
PDController *controller = new PDController(kp, kv);
controller->setActuators(osimModel.updActuators());
osimModel.addController(controller);
I didn't need to write a separate plug-in as in the AnalysisPluginExample. This compiled and ran properly like I said, but the controller was not 'registered' when I tried to open up the model in the OpenSim GUI.
I tried several things after reading your response:
1) Added this function to my main program:
Code: Select all
OpenSim::Object::registerType(PDController(kp, kv));
Result: This compiled and ran properly, but when I loaded the model (which has the controller included), it showed the same error as the first time.
Am I doing something wrong here with this approach?
2) I went through the AnalysisPluginExample as you suggested and implemented it correctly. Then I edited the existing template .cpp and .h files to fit my PDController class. When I ran this, it didn't build successfully. Here's the error:
Code: Select all
Creating library C:/Users/Kenechukwu/Documents/PC Files/OpenSim/OpenSimWorkspace/PDController_Plugin-build/RelWithDebInfo/PDControl.lib and object C:/Users/Kenechukwu/Documents/PC Files/OpenSim/OpenSimWorkspace/PDController_Plugin-build/RelWithDebInfo/PDControl.exp
1>PDController.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl OpenSim::Controller::Controller(class OpenSim::Controller &&)" (__imp_??0Controller@OpenSim@@QEAA@$$QEAV01@@Z) referenced in function "public: __cdecl OpenSim::PDController::PDController(class OpenSim::PDController &&)" (??0PDController@OpenSim@@QEAA@$$QEAV01@@Z)
1>RegisterTypes_osimPlugin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl OpenSim::Controller::Controller(class OpenSim::Controller &&)" (__imp_??0Controller@OpenSim@@QEAA@$$QEAV01@@Z)
1>PDController.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class OpenSim::Controller & __cdecl OpenSim::Controller::operator=(class OpenSim::Controller &&)" (__imp_??4Controller@OpenSim@@QEAAAEAV01@$$QEAV01@@Z) referenced in function "public: class OpenSim::PDController & __cdecl OpenSim::PDController::operator=(class OpenSim::PDController &&)" (??4PDController@OpenSim@@QEAAAEAV01@$$QEAV01@@Z)
1>RegisterTypes_osimPlugin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class OpenSim::Controller & __cdecl OpenSim::Controller::operator=(class OpenSim::Controller &&)" (__imp_??4Controller@OpenSim@@QEAAAEAV01@$$QEAV01@@Z)
1>C:\Users\Kenechukwu\Documents\PC Files\OpenSim\OpenSimWorkspace\PDController_Plugin-build\RelWithDebInfo\PDControl.dll : fatal error LNK1120: 2 unresolved externals
I am not sure what the problem is with approach #2 and why it is not building.
Is my approach here valid for what I want to achieve? Can you help me make sense of this error and what to possible rectify?
My Goal: Write a custom controller (like the ControllerExample) and register it to OpenSim so I can perform forward simulation with the model (with controller included) in OpenSim GUI and/or MATLAB API.
Thank you so much. I really appreciate your support here.
Kenechukwu