Error while registering user-defined plugin

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Arnab Sikidar
Posts: 9
Joined: Thu Sep 21, 2017 1:53 am

Error while registering user-defined plugin

Post by Arnab Sikidar » Sun Sep 02, 2018 11:21 pm

Hi everyone,

I am trying to develop a OpenSim plugin for nonlinear characterstics study of ligaments. I have successfully compiled the code in cmd, however, I am having issue in adding the plugin into OpenSim. The error states as follows

Successfully loaded library C:\OpenSim 3.3\plugins\NonLinearLigament_Plugin.dll.
Object::newInstanceOfType(): object type 'NonLinearLigament' is not a registered Object!
Object type NonLinearLigament not recognized

The class of the plugin is inherited from the Force class. I have referred to the tutorial and discussion in the forum for plugin creation and similar errors but I am unable to detect source of the error.

Kindly help me in this regard.


Thanks and regards

Arnab

Tags:

User avatar
Ayman Habib
Posts: 2236
Joined: Fri Apr 01, 2005 12:24 pm

Re: Error while registering user-defined plugin

Post by Ayman Habib » Mon Sep 03, 2018 10:15 pm

Hello,

Please make sure you have a line similar to

Code: Select all

Object::RegisterType( NonLinearLigament() );
invoked upon loading your dll. This line is necessary to load/parse objects of type "NonLinearLigament" in XML and model files.

Hope this helps,
-Ayman

User avatar
Arnab Sikidar
Posts: 9
Joined: Thu Sep 21, 2017 1:53 am

Re: Error while registering user-defined plugin

Post by Arnab Sikidar » Tue Sep 04, 2018 10:19 pm

Hello,

Thanks for the prompt reply. However, I already have this line in my RegisterTypes_osimPlugin.cpp. Here is the code

Code: Select all


#include <string>
#include <iostream>
#include <OpenSim/Common/Object.h>
#include "RegisterTypes_osimPlugin.h"

#include "NonLinearLigament.h"

using namespace OpenSim;
using namespace std;

//static dllObjectInstantiator instantiator; 
     
//_____________________________________________________________________________
/**
 * The purpose of this routine is to register all class types exported by
 * the Plugin library.
 */
OSIMPLUGIN_API void RegisterTypes_NLLigamentPlugin()
{
	Object::RegisterType( NonLinearLigament() );
}

dllObjectInstantiator::dllObjectInstantiator() 
{ 
        registerDllClasses(); 
} 
    
void dllObjectInstantiator::registerDllClasses() 
{ 
        RegisterTypes_NLLigamentPlugin();
} 
Thank you

Regards

Arnab Sikidar

User avatar
Ayman Habib
Posts: 2236
Joined: Fri Apr 01, 2005 12:24 pm

Re: Error while registering user-defined plugin

Post by Ayman Habib » Wed Sep 05, 2018 8:16 am

Please uncomment the line

static dllObjectInstantiator instantiator;

and let me know how it goes.

-Ayman

User avatar
Arnab Sikidar
Posts: 9
Joined: Thu Sep 21, 2017 1:53 am

Re: Error while registering user-defined plugin

Post by Arnab Sikidar » Thu Sep 06, 2018 9:49 pm

Hi,

I have tried uncommenting the line

Code: Select all

static dllObjectInstantiator instantiator; 
but it is showing me an redefinition error. Here is the details of the error.

Error C2371 'instantiator': redefinition; different basic types Libraries - NLLigament_plugin


Thank you

Regards

Arnab

User avatar
Ayman Habib
Posts: 2236
Joined: Fri Apr 01, 2005 12:24 pm

Re: Error while registering user-defined plugin

Post by Ayman Habib » Fri Sep 07, 2018 10:17 am

Hello,

Since I don't see all your code it's hard to tell where else this is defined, but you can try changing the name of the variable as in

Code: Select all

static dllObjectInstantiator my_instantiator; 
since the whole purpose of instantiating the object is to cause the call to RegisterType, and the variable instantiator is never actually used.

Hope this helps,
-Ayman

User avatar
Arnab Sikidar
Posts: 9
Joined: Thu Sep 21, 2017 1:53 am

Re: Error while registering user-defined plugin

Post by Arnab Sikidar » Sat Sep 08, 2018 12:26 am

Hi

Thanks for the reply. It worked. The .lib and .dll files are getting generated and I am able to load them in OpenSim. However, I am still getting the error:

Object::newInstanceOfType(): object type 'NonLinearLigament' is not a registered Object!
Object type NonLinearLigament not recognized

whenever I am trying to load any object of the type 'NonLinearLigament' in my osim file.

I am attaching the code for registering my class('NonLinearLigament' ). Actually I have a number of user-defined headers in the .cpp file of NonLinearLigament. I have also simulated it in visual studio 17 with custom made tugofwar(of MuscleExample Tutorial) model and its working fine there.


Thank you

Regards

Arnab Sikidar
Attachments
RegisterTypes_NLLigamentPlugin.h
(396 Bytes) Downloaded 21 times
RegisterTypes_NLLigamentPlugin.cpp
(836 Bytes) Downloaded 30 times
NLLigamentPluginDLL.h
(419 Bytes) Downloaded 24 times

POST REPLY