Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Post
by Brad Humphreys » Wed Feb 27, 2013 1:07 pm
I am trying to complete the customActuator example as a plugin (I can successfully get it to work as an executable). I have created a plugin for the ControllableSpring class. I also created another .dll for PistonActuator class. Both of these compile into .dll properly. Both load as plugins correctly inside the GUI.
When I open the toyLeg.osim file in the gui, I get the following error messages:
Code: Select all
Object::newInstanceOfType(): object type 'PistonActuator' is not a registered Object!
Object type PistonActuator not recognized
Object::newInstanceOfType(): object type 'ControllableSpring' is not a registered Object!
Object type ControllableSpring not recognized
WARN: Controller::setup : Actuator piston was not found and will be ignored.
WARN: Controller::setup : Actuator spring was not found and will be ignored.
Loaded model osimModel from file C:\OpenSimWorkspace\CustomActuatorExample\Model\build\Release\toyLeg.osim
Ideas?
One comment: the INSTALL did not seem to work, so I just copied the .dlls to the C:\OpenSim 3.0.1\plugins directory. I have verified that directory is in the PATH.
-
Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Post
by Brad Humphreys » Wed Feb 27, 2013 3:14 pm
To attempt to address registering the objects, I copied from the plugin examples into the build:
- RegisterTypes_osimPlugin.h
RegisterTypes_osimPlugin.cpp (changing out "BodyDragForce" with "PistonActuator" as needed in RegisterTypes_osimPlugin.cpp as needed)
osimPluginDLL.h
When I build, I get the following error:
- 1>------ Build started: Project: ZERO_CHECK, Configuration: Release Win32 ------
2>------ Build started: Project: Libraries - PistonActuator, Configuration: Release Win32 ------
2> PistonActuator.cpp
2> RegisterTypes_osimPlugin.cpp
2>..\RegisterTypes_osimPlugin.cpp(33): error C2371: 'instantiator' : redefinition; different basic types
2> C:/OpenSim 3.0.1/sdk/include\OpenSim/OpenSim.h(44) : see declaration of 'instantiator'
2> Generating Code...
3>------ Build started: Project: ALL_BUILD, Configuration: Release Win32 ------
3> Build all projects
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
again, builds as an executable, but not as plugin?
-
Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Post
by Brad Humphreys » Thu Feb 28, 2013 10:19 am
I believe I figured it out. I had to do the following:
In PistonActuator.h:
Comment Out:
Add:
Code: Select all
#include <string>
#include "osimPluginDLL.h"
#include <OpenSim/Simulation/Model/Actuator.h>
Apologies for the forum spam.
-
Vishal R
- Posts: 47
- Joined: Wed Oct 29, 2014 4:20 pm
Post
by Vishal R » Mon Jul 29, 2019 8:16 am
Hi,
Sorry to bring this up. Can someone please let me know on how to resolve this problem?
I get the following warning when I try to load the osim file in GUI generated using C++ API example (v4.0)
Also, I dont get to see the actuators in the navigator.
Code: Select all
Object::newInstanceOfType(): object type 'PistonActuator' is not a registered Object!
Object type PistonActuator not recognized
Object::newInstanceOfType(): object type 'ControllableSpring' is not a registered Object!
Object type ControllableSpring not recognized
Loaded model osimModel from file blah\blah\CustomActuatorExample\build\toyLeg.osim
WARN: Controller::connectToModel : Actuator piston was not found and will be ignored.
WARN: Controller::connectToModel : Actuator spring was not found and will be ignored.
If making a dll is the way ahead, please let me know on how to make it as well.
Thanks a lot,
Vishal
-
Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Post
by Ayman Habib » Mon Jul 29, 2019 8:30 am
Hi Vishal,
There's an example exampleCoupledBushingForcePlugin in the source code and distribution to show how to use plugins. It boils down to needing to have a call to Object::registerType() on loading the dll. The call needs to be made with an instance of the class you're adding in the plugin so that mapping between the object and the corresponding XML tag is established.
Please let us know if you can't find the example (should be under the resources directory Code/CPP/Plugins) or have further questions.
Best regards,
-Ayman
-
Vishal R
- Posts: 47
- Joined: Wed Oct 29, 2014 4:20 pm
Post
by Vishal R » Mon Jul 29, 2019 9:50 am
Dear Ayman,
Thanks a lot! I did find the examples and it worked like a charm. Here in this case I had to build two dll files separately and load into GUI.
Best,
Vishal