diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38ff91e..f3a9fe1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,9 @@ jobs: elif [[ "$RUNNER_OS" == "macOS" ]]; then echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV fi - echo "LD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV + echo "LD_LIBRARY_PATH=$SoftRobots_ROOT/lib:$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV + echo "SOFA_PLUGIN_PATH=$SoftRobots_ROOT/lib:$WORKSPACE_ARTIFACT_PATH/lib" | tee -a $GITHUB_ENV + # Add execution right on the tests chmod +x $WORKSPACE_BUILD_PATH/bin/*_test${{ steps.sofa.outputs.exe }} diff --git a/src/SoftRobots.Inverse/component/constraint/BarycentricCenterEffector.cpp b/src/SoftRobots.Inverse/component/constraint/BarycentricCenterEffector.cpp index 4f70b31..f40cf4e 100644 --- a/src/SoftRobots.Inverse/component/constraint/BarycentricCenterEffector.cpp +++ b/src/SoftRobots.Inverse/component/constraint/BarycentricCenterEffector.cpp @@ -36,7 +36,6 @@ namespace softrobotsinverse::constraint { using sofa::defaulttype::Vec3Types; using sofa::defaulttype::Rigid3Types; -using sofa::core::RegisterObject ; template<> void BarycentricCenterEffector::draw(const VisualParams* vparams) @@ -62,12 +61,13 @@ void BarycentricCenterEffector::setBarycenter(const Coord& _barycen //////////////////////////////////////////// FACTORY ////////////////////////////////////////////// -int BarycentricCenterEffectorClass = RegisterObject("This component is used to describe one or several desired trajectories " - "for the barycenter of a model, that will be reached by acting on chosen actuator(s).") - .add< BarycentricCenterEffector >(true) - .add< BarycentricCenterEffector >() - - ; +void registerBarycentricCenterEffector(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("This component is used to describe one or several desired trajectories " + "for the barycenter of a model, that will be reached by acting on chosen actuator(s).") + .add< BarycentricCenterEffector >(true) + .add< BarycentricCenterEffector >()); +} template class SOFA_SOFTROBOTS_INVERSE_API BarycentricCenterEffector; template class SOFA_SOFTROBOTS_INVERSE_API BarycentricCenterEffector; diff --git a/src/SoftRobots.Inverse/component/constraint/CableActuator.cpp b/src/SoftRobots.Inverse/component/constraint/CableActuator.cpp index e9efc90..b09f966 100644 --- a/src/SoftRobots.Inverse/component/constraint/CableActuator.cpp +++ b/src/SoftRobots.Inverse/component/constraint/CableActuator.cpp @@ -42,9 +42,11 @@ using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; -int CableActuatorClass = RegisterObject("Simulate cable actuation to solve effector constraint.") -.add< CableActuator >(true) -; +void registerCableActuator(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("Simulate cable actuation to solve effector constraint.") + .add< CableActuator >(true)); +} template class SOFA_SOFTROBOTS_INVERSE_API CableActuator; diff --git a/src/SoftRobots.Inverse/component/constraint/CableEffector.cpp b/src/SoftRobots.Inverse/component/constraint/CableEffector.cpp index 442a1a9..149834e 100644 --- a/src/SoftRobots.Inverse/component/constraint/CableEffector.cpp +++ b/src/SoftRobots.Inverse/component/constraint/CableEffector.cpp @@ -41,9 +41,11 @@ using namespace sofa::core; namespace softrobotsinverse::constraint { -int CableEffectorClass = RegisterObject("Simulate cable sensor to measure lengths.") -.add< CableEffector >(true) -; +void registerCableEffector(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("Simulate cable sensor to measure lengths.") + .add< CableEffector >(true)); +} template class CableEffector; diff --git a/src/SoftRobots.Inverse/component/constraint/CableEquality.cpp b/src/SoftRobots.Inverse/component/constraint/CableEquality.cpp index 4b6ba37..2723ab9 100644 --- a/src/SoftRobots.Inverse/component/constraint/CableEquality.cpp +++ b/src/SoftRobots.Inverse/component/constraint/CableEquality.cpp @@ -42,9 +42,12 @@ using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; -int CableEqualityClass = RegisterObject("Simulate cable actuation to solve effector constraint.") -.add< CableEquality >(true) -; + +void registerCableEquality(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("Simulate cable actuation to solve effector constraint.") + .add< CableEquality >(true)); +} template class SOFA_SOFTROBOTS_INVERSE_API CableEquality; diff --git a/src/SoftRobots.Inverse/component/constraint/CableSensor.cpp b/src/SoftRobots.Inverse/component/constraint/CableSensor.cpp index 8a95099..128b837 100644 --- a/src/SoftRobots.Inverse/component/constraint/CableSensor.cpp +++ b/src/SoftRobots.Inverse/component/constraint/CableSensor.cpp @@ -38,10 +38,11 @@ using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; -int CableSensorClass = RegisterObject("This component simulates a cable sensor that measures its length.") -.add< CableSensor >(true) - -; +void registerCableSensor(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component simulates a cable sensor that measures its length.") + .add< CableSensor >(true)); +} template class CableSensor; diff --git a/src/SoftRobots.Inverse/component/constraint/ForcePointActuator.cpp b/src/SoftRobots.Inverse/component/constraint/ForcePointActuator.cpp index c877ffd..3cea299 100644 --- a/src/SoftRobots.Inverse/component/constraint/ForcePointActuator.cpp +++ b/src/SoftRobots.Inverse/component/constraint/ForcePointActuator.cpp @@ -38,11 +38,12 @@ using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; -int ForcePointActuatorClass = RegisterObject("This component is used to solve an inverse problem by applying a force on a given point of a model.") -.add< ForcePointActuator >(true) -.add< ForcePointActuator >() - -; +void registerForcePointActuator(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component is used to solve an inverse problem by applying a force on a given point of a model.") + .add< ForcePointActuator >(true) + .add< ForcePointActuator >()); +} template class SOFA_SOFTROBOTS_INVERSE_API ForcePointActuator; template class SOFA_SOFTROBOTS_INVERSE_API ForcePointActuator; diff --git a/src/SoftRobots.Inverse/component/constraint/ForceSurfaceActuator.cpp b/src/SoftRobots.Inverse/component/constraint/ForceSurfaceActuator.cpp index a9d8d6c..7d23a40 100644 --- a/src/SoftRobots.Inverse/component/constraint/ForceSurfaceActuator.cpp +++ b/src/SoftRobots.Inverse/component/constraint/ForceSurfaceActuator.cpp @@ -38,11 +38,12 @@ using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; +void registerForceSurfaceActuator(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component is used to solve an inverse problem by applying a force on a given surface of a model.") + .add< ForceSurfaceActuator >(true)); +} -int ForceSurfaceActuatorClass = RegisterObject("This component is used to solve an inverse problem by applying a force on a given surface of a model.") -.add< ForceSurfaceActuator >(true) - -; template class SOFA_SOFTROBOTS_INVERSE_API ForceSurfaceActuator; diff --git a/src/SoftRobots.Inverse/component/constraint/JointActuator.cpp b/src/SoftRobots.Inverse/component/constraint/JointActuator.cpp index 8e1af51..93323a0 100644 --- a/src/SoftRobots.Inverse/component/constraint/JointActuator.cpp +++ b/src/SoftRobots.Inverse/component/constraint/JointActuator.cpp @@ -38,10 +38,12 @@ using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; -int JointActuatorClass = RegisterObject("This component is used to solve an inverse problem by applying force on a joint (Vec1)") -.add< JointActuator >(true) +void registerJointActuator(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component is used to solve an inverse problem by applying force on a joint (Vec1)") + .add< JointActuator >(true)); +} -; template class SOFA_SOFTROBOTS_INVERSE_API JointActuator; diff --git a/src/SoftRobots.Inverse/component/constraint/PositionEffector.cpp b/src/SoftRobots.Inverse/component/constraint/PositionEffector.cpp index 2678831..7980903 100644 --- a/src/SoftRobots.Inverse/component/constraint/PositionEffector.cpp +++ b/src/SoftRobots.Inverse/component/constraint/PositionEffector.cpp @@ -37,29 +37,19 @@ namespace softrobotsinverse::constraint using namespace sofa::defaulttype; using sofa::core::ConstraintParams; - -//////////////////////////////////////////// FACTORY ////////////////////////////////////////////// using namespace sofa::helper; +using namespace sofa::core; -// Registering the component -// see: http://wiki.sofa-framework.org/wiki/ObjectFactory -// 1-RegisterObject("description") + .add<> : Register the component -// 2-.add<>(true) : Set default template - -int PositionEffectorClass = sofa::core::RegisterObject("This component is used to describe one or several desired positions " - "of points of a model, that will be reached by acting on chosen actuator(s).") - .add< PositionEffector >() - .add< PositionEffector >() - .add< PositionEffector >(true) - .add< PositionEffector >() - - ; -//////////////////////////////////////////////////////////////////////////////////////////////////////// +void registerPositionEffector(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component is used to describe one or several desired positions " + "of points of a model, that will be reached by acting on chosen actuator(s).") + .add< PositionEffector >() + .add< PositionEffector >() + .add< PositionEffector >(true) + .add< PositionEffector >()); +} -// Force template specialization for the most common sofa floating point related type. -// This goes with the extern template declaration in the .h. Declaring extern template -// avoid the code generation of the template for each compilation unit. -// see: http://www.stroustrup.com/C++11FAQ.html#extern-templates template class SOFA_SOFTROBOTS_INVERSE_API PositionEffector; template class SOFA_SOFTROBOTS_INVERSE_API PositionEffector; template class SOFA_SOFTROBOTS_INVERSE_API PositionEffector; diff --git a/src/SoftRobots.Inverse/component/constraint/PositionEquality.cpp b/src/SoftRobots.Inverse/component/constraint/PositionEquality.cpp index d8b69d9..50b8992 100644 --- a/src/SoftRobots.Inverse/component/constraint/PositionEquality.cpp +++ b/src/SoftRobots.Inverse/component/constraint/PositionEquality.cpp @@ -40,11 +40,13 @@ using namespace sofa::core; namespace softrobotsinverse::constraint { -int PositionEqualityClass = RegisterObject("In an inverse problem, constrains the given positions on chosen directions.") -.add< PositionEquality >(true) -.add< PositionEquality >() -.add< PositionEquality >() -; +void registerPositionEquality(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("In an inverse problem, constrains the given positions on chosen directions.") + .add< PositionEquality >() + .add< PositionEquality >(true) + .add< PositionEquality >()); +} template class SOFA_SOFTROBOTS_INVERSE_API PositionEquality; template class SOFA_SOFTROBOTS_INVERSE_API PositionEquality; diff --git a/src/SoftRobots.Inverse/component/constraint/PositionEquality.h b/src/SoftRobots.Inverse/component/constraint/PositionEquality.h index e3c65cf..b7a22d9 100644 --- a/src/SoftRobots.Inverse/component/constraint/PositionEquality.h +++ b/src/SoftRobots.Inverse/component/constraint/PositionEquality.h @@ -122,7 +122,9 @@ class PositionEquality : public Equality, public PositionModel; extern template class SOFA_SOFTROBOTS_INVERSE_API PositionEquality; +extern template class SOFA_SOFTROBOTS_INVERSE_API PositionEquality; #endif // SOFTROBOTSINVERSE_CONSTRAINT_POSITIONEQUALITY_CPP } // namespace diff --git a/src/SoftRobots.Inverse/component/constraint/SlidingActuator.cpp b/src/SoftRobots.Inverse/component/constraint/SlidingActuator.cpp index bb2c87c..c7363bd 100644 --- a/src/SoftRobots.Inverse/component/constraint/SlidingActuator.cpp +++ b/src/SoftRobots.Inverse/component/constraint/SlidingActuator.cpp @@ -68,14 +68,14 @@ void SlidingActuator::initData() d_force.setValue(d_initForce.getValue()); } - -int SlidingActuatorClass = RegisterObject("This component simulates a force exerted along a given direction to solve an inverse problem. \n" - "In case of Rigid template, it additionally simulates a force in rotation: the size of 'direction' is equal to 6,\n" - "the three first component give the direction in translation and the three last the axe of rotation.") -.add< SlidingActuator >(true) -.add< SlidingActuator >() - -; +void registerSlidingActuator(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component simulates a force exerted along a given direction to solve an inverse problem. \n" + "In case of Rigid template, it additionally simulates a force in rotation: the size of 'direction' is equal to 6,\n" + "the three first component give the direction in translation and the three last the axe of rotation.") + .add< SlidingActuator >(true) + .add< SlidingActuator >()); +} template class SOFA_SOFTROBOTS_INVERSE_API SlidingActuator; template class SOFA_SOFTROBOTS_INVERSE_API SlidingActuator; diff --git a/src/SoftRobots.Inverse/component/constraint/SurfacePressureActuator.cpp b/src/SoftRobots.Inverse/component/constraint/SurfacePressureActuator.cpp index 759c553..32c15e1 100644 --- a/src/SoftRobots.Inverse/component/constraint/SurfacePressureActuator.cpp +++ b/src/SoftRobots.Inverse/component/constraint/SurfacePressureActuator.cpp @@ -38,11 +38,13 @@ using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; -int SurfacePressureActuatorClass = RegisterObject("This component is used to solve effector constraint " - "by applying pressure on surfaces (for exemple cavities)") -.add< SurfacePressureActuator >(true) +void registerSurfacePressureActuator(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component is used to solve effector constraint " + "by applying pressure on surfaces (for exemple cavities)") + .add< SurfacePressureActuator >(true)); +} -; template class SOFA_SOFTROBOTS_INVERSE_API SurfacePressureActuator; diff --git a/src/SoftRobots.Inverse/component/constraint/SurfacePressureEquality.cpp b/src/SoftRobots.Inverse/component/constraint/SurfacePressureEquality.cpp index e4389d3..d4d6a9d 100644 --- a/src/SoftRobots.Inverse/component/constraint/SurfacePressureEquality.cpp +++ b/src/SoftRobots.Inverse/component/constraint/SurfacePressureEquality.cpp @@ -37,11 +37,14 @@ namespace softrobotsinverse::constraint using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; -int SurfacePressureEqualityClass = RegisterObject("This component is used to solve inverse problem " - "by applying an imposed pressure on surfaces (for exemple cavities)") -.add< SurfacePressureEquality >(true) -; +void registerSurfacePressureEquality(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component is used to solve inverse problem " + "by applying an imposed pressure on surfaces (for exemple cavities)") + .add< SurfacePressureEquality >(true)); +} + template class SOFA_SOFTROBOTS_INVERSE_API SurfacePressureEquality; } // namespace diff --git a/src/SoftRobots.Inverse/component/constraint/SurfacePressureSensor.cpp b/src/SoftRobots.Inverse/component/constraint/SurfacePressureSensor.cpp index a589ec5..ae84df6 100644 --- a/src/SoftRobots.Inverse/component/constraint/SurfacePressureSensor.cpp +++ b/src/SoftRobots.Inverse/component/constraint/SurfacePressureSensor.cpp @@ -37,11 +37,11 @@ using namespace sofa::defaulttype; using namespace sofa::helper; using namespace sofa::core; - -int SurfacePressureSensorClass = RegisterObject("This component simulates a surface pressure sensor that measures its volume growth.") -.add< SurfacePressureSensor >(true) - -; +void registerSurfacePressureSensor(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component simulates a surface pressure sensor that measures its volume growth.") + .add< SurfacePressureSensor >(true)); +} template class SurfacePressureSensor; diff --git a/src/SoftRobots.Inverse/component/constraint/VolumeEffector.cpp b/src/SoftRobots.Inverse/component/constraint/VolumeEffector.cpp index e3da247..3252488 100644 --- a/src/SoftRobots.Inverse/component/constraint/VolumeEffector.cpp +++ b/src/SoftRobots.Inverse/component/constraint/VolumeEffector.cpp @@ -40,12 +40,12 @@ using namespace sofa::core; namespace softrobotsinverse::constraint { -SOFA_DECL_CLASS(VolumeEffector) - -int VolumeEffectorClass = RegisterObject("Simulate behavior of a volume effector to solve an inverse problem.") -.add< VolumeEffector >(true) +void registerVolumeEffector(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("Simulate behavior of a volume effector to solve an inverse problem.") + .add< VolumeEffector >(true)); +} -; template class VolumeEffector; } // namespace diff --git a/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.cpp b/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.cpp index cacdca6..0859890 100644 --- a/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.cpp +++ b/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.cpp @@ -27,37 +27,29 @@ * Contact information: https://project.inria.fr/softrobot/contact/ * ******************************************************************************/ #define SOFTROBOTS_INVERSE_YOUNGMODULUSACTUATOR_CPP -#include "YoungModulusActuator.inl" +#include #include -namespace sofa::component::constraintset +namespace softrobotsinverse::constraint { using namespace sofa::defaulttype; using namespace sofa::helper; +using namespace sofa::core; -//////////////////////////////////////////// FACTORY ////////////////////////////////////////////// -// Registering the component -// see: http://wiki.sofa-framework.org/wiki/ObjectFactory -// 1-RegisterObject("description") + .add<> : Register the component -// 2-.add<>(true) : Set default template -int YoungModulusActuatorClass = core::RegisterObject("This component is used to solve effector constraint " - "by changing young moduli") -.add< YoungModulusActuator >(true) - -; -/////////////////////////////////////////////////////////////////////////////////////////////////////// +void registerYoungModulusActuator(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("This component is used to solve effector constraint " + "by changing young moduli") + .add< YoungModulusActuator >(true)); +} -// Force template specialization for the most common sofa floating point related type. -// This goes with the extern template declaration in the .h. Declaring extern template -// avoid the code generation of the template for each compilation unit. -// see: http://www.stroustrup.com/C++11FAQ.html#extern-templates template class SOFA_SOFTROBOTS_INVERSE_API YoungModulusActuator; -} // namespace sofa::component::constraintset +} // namespace diff --git a/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.h b/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.h index 2eedb54..c4723ce 100644 --- a/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.h +++ b/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.h @@ -34,7 +34,7 @@ #include -namespace sofa::component::constraintset +namespace softrobotsinverse::constraint { using sofa::core::visual::VisualParams ; using sofa::linearalgebra::BaseVector ; @@ -60,12 +60,12 @@ class YoungModulusActuator : public Actuator typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::MatrixDeriv MatrixDeriv; typedef typename Coord::value_type Real; - typedef typename core::behavior::MechanicalState MechanicalState; + typedef typename sofa::core::behavior::MechanicalState MechanicalState; typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; + typedef sofa::Data DataVecCoord; + typedef sofa::Data DataVecDeriv; + typedef sofa::Data DataMatrixDeriv; public: YoungModulusActuator(MechanicalState* object = nullptr); @@ -93,16 +93,16 @@ class YoungModulusActuator : public Actuator ///////////////// Inherited from BaseSoftRobotsConstraint /////////////////////////// - void storeResults(type::vector &lambda, - type::vector &delta) override; + void storeResults(sofa::type::vector &lambda, + sofa::type::vector &delta) override; ///////////////////////////////////////////////////////////////////// protected: - Data d_minYoung; - Data d_maxYoung; - Data d_maxYoungVariationRatio; - Data d_hasVolumeOptimization; + sofa::Data d_minYoung; + sofa::Data d_maxYoung; + sofa::Data d_maxYoungVariationRatio; + sofa::Data d_hasVolumeOptimization; double m_previousYoungValue; Real m_previousVolumeValue; @@ -145,7 +145,7 @@ class YoungModulusActuator : public Actuator extern template class SOFA_SOFTROBOTS_INVERSE_API YoungModulusActuator; #endif -} // namespace sofa::component::constraintset +} // namespace diff --git a/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.inl b/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.inl index 914ff5a..3bb96eb 100644 --- a/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.inl +++ b/src/SoftRobots.Inverse/component/constraint/YoungModulusActuator.inl @@ -28,14 +28,14 @@ ******************************************************************************/ #pragma once -#include "YoungModulusActuator.h" +#include -namespace sofa::component::constraintset +namespace softrobotsinverse::constraint { -using type::vector; -using core::objectmodel::BaseContext; +using sofa::type::vector; +using sofa::core::objectmodel::BaseContext; using sofa::core::objectmodel::ComponentState; template diff --git a/src/SoftRobots.Inverse/component/initSoftRobotsInverse.cpp b/src/SoftRobots.Inverse/component/initSoftRobotsInverse.cpp index e5fe2f0..9af3738 100644 --- a/src/SoftRobots.Inverse/component/initSoftRobotsInverse.cpp +++ b/src/SoftRobots.Inverse/component/initSoftRobotsInverse.cpp @@ -25,12 +25,38 @@ #include #include +#include +using sofa::helper::system::PluginManager; + #include namespace softrobotsinverse { +namespace constraint { + extern void registerBarycentricCenterEffector(sofa::core::ObjectFactory* factory); + extern void registerCableActuator(sofa::core::ObjectFactory* factory); + extern void registerCableEffector(sofa::core::ObjectFactory* factory); + extern void registerCableEquality(sofa::core::ObjectFactory* factory); + extern void registerCableSensor(sofa::core::ObjectFactory* factory); + extern void registerForcePointActuator(sofa::core::ObjectFactory* factory); + extern void registerForceSurfaceActuator(sofa::core::ObjectFactory* factory); + extern void registerJointActuator(sofa::core::ObjectFactory* factory); + extern void registerPositionEffector(sofa::core::ObjectFactory* factory); + extern void registerPositionEquality(sofa::core::ObjectFactory* factory); + extern void registerSlidingActuator(sofa::core::ObjectFactory* factory); + extern void registerSurfacePressureActuator(sofa::core::ObjectFactory* factory); + extern void registerSurfacePressureEquality(sofa::core::ObjectFactory* factory); + extern void registerSurfacePressureSensor(sofa::core::ObjectFactory* factory); + extern void registerVolumeEffector(sofa::core::ObjectFactory* factory); + extern void registerYoungModulusActuator(sofa::core::ObjectFactory* factory); +} + +namespace solver { + extern void registerQPInverseProblemSolver(sofa::core::ObjectFactory* factory); +} + //Here are just several convenient functions to help users know what the plugin contains extern "C" { @@ -40,6 +66,7 @@ extern "C" { SOFA_SOFTROBOTS_INVERSE_API const char* getModuleLicense(); SOFA_SOFTROBOTS_INVERSE_API const char* getModuleDescription(); SOFA_SOFTROBOTS_INVERSE_API const char* getModuleComponentList(); + SOFA_SOFTROBOTS_INVERSE_API void registerObjects(sofa::core::ObjectFactory* factory); } void initExternalModule() @@ -51,6 +78,9 @@ void initExternalModule() first = false; } + // make sure that this plugin is registered into the PluginManager + PluginManager::getInstance().registerPlugin(MODULE_NAME); + } const char* getModuleName() @@ -60,7 +90,7 @@ const char* getModuleName() const char* getModuleVersion() { - return "1.0"; + return MODULE_VERSION; } const char* getModuleLicense() @@ -80,26 +110,27 @@ const char* getModuleComponentList() return classes.c_str(); } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + constraint::registerBarycentricCenterEffector(factory); + constraint::registerCableActuator(factory); + constraint::registerCableEffector(factory); + constraint::registerCableEquality(factory); + constraint::registerCableSensor(factory); + constraint::registerForcePointActuator(factory); + constraint::registerForceSurfaceActuator(factory); + constraint::registerJointActuator(factory); + constraint::registerPositionEffector(factory); + constraint::registerPositionEquality(factory); + constraint::registerSlidingActuator(factory); + constraint::registerSurfacePressureActuator(factory); + constraint::registerSurfacePressureEquality(factory); + constraint::registerSurfacePressureSensor(factory); + constraint::registerVolumeEffector(factory); + constraint::registerYoungModulusActuator(factory); + solver::registerQPInverseProblemSolver(factory); } -SOFA_LINK_CLASS(AnimationEditor) -SOFA_LINK_CLASS(BarycentricCenterEffector) -SOFA_LINK_CLASS(CableActuator) -SOFA_LINK_CLASS(CableEffector) -SOFA_LINK_CLASS(CableSensor) -SOFA_LINK_CLASS(CableEquality) -SOFA_LINK_CLASS(ForcePointActuator) -SOFA_LINK_CLASS(PartialRigidificationConstraint) -SOFA_LINK_CLASS(PartialRigidificationForceField) -SOFA_LINK_CLASS(PREquivalentStiffnessForceField) -SOFA_LINK_CLASS(PositionEffector) -SOFA_LINK_CLASS(QPInverseProblemSolver) -SOFA_LINK_CLASS(SurfacePressureConstraint) -SOFA_LINK_CLASS(SurfacePressureActuator) -SOFA_LINK_CLASS(SurfacePressureEquality) -SOFA_LINK_CLASS(YoungModulusActuator) -SOFA_LINK_CLASS(InteractiveControl) -SOFA_LINK_CLASS(UnilateralPlaneConstraint) -SOFA_LINK_CLASS(VolumeFromTriangles) -SOFA_LINK_CLASS(VolumeFromTetrahedrons) +} // namespace softrobotsinverse + diff --git a/src/SoftRobots.Inverse/component/solver/QPInverseProblemSolver.cpp b/src/SoftRobots.Inverse/component/solver/QPInverseProblemSolver.cpp index 584e108..71914bd 100644 --- a/src/SoftRobots.Inverse/component/solver/QPInverseProblemSolver.cpp +++ b/src/SoftRobots.Inverse/component/solver/QPInverseProblemSolver.cpp @@ -664,15 +664,16 @@ void QPInverseProblemSolver::lockConstraintProblem(sofa::core::objectmodel::Base ////////////////////////////////////////////// FACTORY ///////////////////////////////////////////////// -// Registering the component -// see: http://wiki.sofa-framework.org/wiki/ObjectFactory -// 1-SOFA_DECL_CLASS(componentName) : Set the class name of the component -// 2-RegisterObject("description") + .add<> : Register the component -SOFA_DECL_CLASS(QPInverseProblemSolver) - -int QPInverseProblemSolverClass = RegisterObject("An inverse problem solver using the " - "Quadratic Programing formulation") - .add< QPInverseProblemSolver >(); + +using namespace sofa::core; + +void registerQPInverseProblemSolver(ObjectFactory* factory) +{ + factory->registerObjects(ObjectRegistrationData("An inverse problem solver using the " + "Quadratic Programing formulation") + .add< QPInverseProblemSolver >(true)); +} + //////////////////////////////////////////////////////////////////////////////////////////////////////// } // namespace diff --git a/src/SoftRobots.Inverse/component/solver/QPInverseProblemSolver.h b/src/SoftRobots.Inverse/component/solver/QPInverseProblemSolver.h index afcbdc8..5409fbc 100644 --- a/src/SoftRobots.Inverse/component/solver/QPInverseProblemSolver.h +++ b/src/SoftRobots.Inverse/component/solver/QPInverseProblemSolver.h @@ -29,7 +29,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/tests/component/constraint/YoungModulusActuatorTest.cpp b/tests/component/constraint/YoungModulusActuatorTest.cpp index 44bf1aa..3606280 100644 --- a/tests/component/constraint/YoungModulusActuatorTest.cpp +++ b/tests/component/constraint/YoungModulusActuatorTest.cpp @@ -30,10 +30,10 @@ using sofa::component::statecontainer::MechanicalObject ; using sofa::component::solidmechanics::fem::elastic::TetrahedronFEMForceField ; #include -using sofa::component::constraintset::YoungModulusActuator ; +using softrobotsinverse::constraint::YoungModulusActuator ; -namespace sofa +namespace softrobotsinverse { template @@ -45,6 +45,7 @@ struct YoungModulusActuatorTest : public BaseTest, void simpleScene(){ sofa::simpleapi::importPlugin("Sofa.Component.SolidMechanics.FEM.Elastic"); + sofa::simpleapi::importPlugin("SoftRobots.Inverse"); string scene = "" " "