Page 1 of 1

Error while registering user-defined plugin

Posted: Sun Sep 02, 2018 11:21 pm
by arnab.sikidar
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

Re: Error while registering user-defined plugin

Posted: Mon Sep 03, 2018 10:15 pm
by aymanh
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

Re: Error while registering user-defined plugin

Posted: Tue Sep 04, 2018 10:19 pm
by arnab.sikidar
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

Re: Error while registering user-defined plugin

Posted: Wed Sep 05, 2018 8:16 am
by aymanh
Please uncomment the line

static dllObjectInstantiator instantiator;

and let me know how it goes.

-Ayman

Re: Error while registering user-defined plugin

Posted: Thu Sep 06, 2018 9:49 pm
by arnab.sikidar
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

Re: Error while registering user-defined plugin

Posted: Fri Sep 07, 2018 10:17 am
by aymanh
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

Re: Error while registering user-defined plugin

Posted: Sat Sep 08, 2018 12:26 am
by arnab.sikidar
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