Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply new registration mechanism #311

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ endif()

# COMMUNICATION CONTROLLER
if(SOFTROBOTS_COMMUNICATIONCONTROLLER)
set(SOFTROBOTS_USES_COMMUNICATIONCONTROLLER ON)
list(APPEND HEADER_FILES
${SOFTROBOTS_SOURCE_DIR}/component/controller/CommunicationController.h
${SOFTROBOTS_SOURCE_DIR}/component/controller/CommunicationController.inl
Expand All @@ -129,6 +130,7 @@ endif()

# GAMETRAK CONTROLLER
if(SOFTROBOTS_GAMETRAKCONTROLLER)
set(SOFTROBOTS_USES_GAMETRAKCONTROLLER ON)
list(APPEND HEADER_FILES
${SOFTROBOTS_SOURCE_DIR}/component/controller/GameTrakController.h

Expand Down Expand Up @@ -158,6 +160,7 @@ endif()

# ROBOTINO CONTROLLER
if(SOFTROBOTS_ROBOTINOCONTROLLER)
set(SOFTROBOTS_USES_ROBOTINOCONTROLLER ON)
list(APPEND HEADER_FILES
${SOFTROBOTS_SOURCE_DIR}/component/controller/DataControllerRobot.h
)
Expand All @@ -168,6 +171,7 @@ endif()

# CAMERA
if (SOFTROBOTS_WITH_CAMERA)
set(SOFTROBOTS_USES_WITH_CAMERA ON)
list(APPEND HEADER_FILES
${SOFTROBOTS_SOURCE_DIR}/component/camera/PointCloudProcessing.h
${SOFTROBOTS_SOURCE_DIR}/component/camera/PointCloudStreaming.h
Expand All @@ -180,6 +184,7 @@ endif(SOFTROBOTS_WITH_CAMERA)

# INTERACTIVECONTROL
if (SOFTROBOTS_INTERACTIVECONTROL)
set(SOFTROBOTS_USES_INTERACTIVECONTROL ON)
find_package(Qt5 REQUIRED COMPONENTS Network)
if(WIN32)
sofa_copy_libraries(TARGETS Qt5::Network)
Expand Down
8 changes: 5 additions & 3 deletions src/SoftRobots/component/camera/PointCloudProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,10 @@ void PointCloudProcessing::handleEvent(sofa::core::objectmodel::Event *event)

using namespace sofa::defaulttype;

static int PointCloudProcessingClass = sofa::core::RegisterObject("Exposing a RealSense RGBD camera in the Sofa Scene")
.add<PointCloudProcessing>();

void registerPointCloudProcessing(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Exposing a RealSense RGBD camera in the Sofa Scene")
.add< PointCloudProcessing>());
}

} // namespace
11 changes: 7 additions & 4 deletions src/SoftRobots/component/constraint/CableConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@ void CableForceConstraintResolution::resolution(int line, SReal** w, SReal* d, S

//////////////////////////////////////////////////////////////////////////////////////////////////////////

int CableConstraintClass = RegisterObject("Simulate a cable.")
.add< CableConstraint<Vec3Types> >(true)
.add< CableConstraint<Vec2Types> >()
void registerCableConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(ObjectRegistrationData("Simulate a cable.")
.add< CableConstraint<Vec3Types> >(true)
.add< CableConstraint<Vec2Types> >());
}


;
template class SOFA_SOFTROBOTS_API CableConstraint<Vec3Types>;
template class SOFA_SOFTROBOTS_API CableConstraint<Vec2Types>;

Expand Down
8 changes: 5 additions & 3 deletions src/SoftRobots/component/constraint/JointConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ void JointForceConstraintResolution::resolution(int line, double** w, double* d,


//////////////////////////////////////////// FACTORY //////////////////////////////////////////////
int JointConstraintClass = RegisterObject("Lagrange multiplier approach to apply a force/displacement on a Joint (Vec1)")
.add< JointConstraint<Vec1Types> >(true)
;
void registerJointConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(ObjectRegistrationData("Lagrange multiplier approach to apply a force/displacement on a Joint (Vec1)")
.add< JointConstraint<Vec1Types> >(true));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////

template class SOFA_SOFTROBOTS_API JointConstraint<Vec1Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ PartialRigidificationConstraintResolution6Dof::PartialRigidificationConstraintRe
{
}

int PartialRigidificationConstraintClass = sofa::core::RegisterObject("PartialRigidificationConstraint")
.add< PartialRigidificationConstraint<Rigid3Types> >(true)
void registerPartialRigidificationConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("PartialRigidificationConstraint")
.add< PartialRigidificationConstraint<Rigid3Types> >(true));
}

;
template class SOFA_SOFTROBOTS_API PartialRigidificationConstraint<Rigid3Types>;


Expand Down
12 changes: 7 additions & 5 deletions src/SoftRobots/component/constraint/PositionConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,14 @@ void PositionForceConstraintResolution::resolution(int line, double** w, double*


//////////////////////////////////////////// FACTORY //////////////////////////////////////////////
int PositionConstraintClass = RegisterObject("Simulate a Position.")
.add< PositionConstraint<Vec3Types> >(true)
.add< PositionConstraint<Vec2Types> >()
.add< PositionConstraint<Rigid3Types> >()
void registerPositionConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Simulate a Position.")
.add< PositionConstraint<Vec3Types> >(true)
.add< PositionConstraint<Vec2Types> >()
.add< PositionConstraint<Rigid3Types> >());
}

;
////////////////////////////////////////////////////////////////////////////////////////////////////////

template class SOFA_SOFTROBOTS_API PositionConstraint<Vec3Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ void VolumeGrowthConstraintResolution::resolution(int line, SReal** w, SReal* d,


///////////////////////////////////////// FACTORY //////////////////////////////////////////////////
int SurfacePressureConstraintClass = sofa::core::RegisterObject("This component constrains a model by applying "
"pressure on surfaces (for exemple cavities)")
.add< SurfacePressureConstraint<Vec3Types> >(true)//Set Vec3d to default template
void registerSurfacePressureConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("This component constrains a model by applying "
"pressure on surfaces (for example cavities)")
.add< SurfacePressureConstraint<Vec3Types> >(true));
}

;
/////////////////////////////////////////////////////////////////////////////////////////////////////
template class SOFA_SOFTROBOTS_API SurfacePressureConstraint<Vec3Types>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,18 @@ void UnilateralPlaneConstraintResolution::resolution(int line, SReal**w, SReal*d

//////////////////////////////////////////// FACTORY //////////////////////////////////////////////
using namespace sofa::helper;
int UnilateralPlaneConstraintClass = sofa::core::RegisterObject("This component is a simple point plane collision model. \n"

void registerUnilateralPlaneConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("This component is a simple point plane collision model. \n"
"By providing 4 points to the component, the first point will \n"
"be constrained to stay in one side of the plane described \n"
"by the three other points (in the direction of the plane normal). \n"
"All the four points, the triangle and the normal can be \n"
"seen by allowing the 'Collision Model' in the 'View' tab.")
.add< UnilateralPlaneConstraint<Vec3Types> >(true)
;
.add< UnilateralPlaneConstraint<Vec3Types> >(true));
}

template class SOFA_SOFTROBOTS_API UnilateralPlaneConstraint<sofa::defaulttype::Vec3Types>;


Expand Down
14 changes: 6 additions & 8 deletions src/SoftRobots/component/controller/AnimationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ void AnimationEditor<Rigid3Types>::drawTrajectory(const VisualParams* vparams)


//////////////////////////////////////////// FACTORY ////////////////////////////////////////////
using sofa::core::RegisterObject ;
int AnimationEditorClass = RegisterObject("Build an animation from key points motion: \n"
void registerAnimationEditor(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Build an animation from key points motion: \n"
"ctrl+a: add keyframe \n"
"ctrl+d: delete keyframe \n"
"ctrl+c: copy keyframe \n"
Expand All @@ -127,12 +128,9 @@ int AnimationEditorClass = RegisterObject("Build an animation from key points mo
"ctrl+m: play/pause animation \n"
"ctrl+(left/right)arrow: move the cursor along the timeline \n"
"ctrl+(pgDn/pgUp): move the cursor to the next/previous keyframe")
///////////////////////////////////////////////////////////////////////////////////////////////////////

.add< AnimationEditor<Vec3Types> >(true)
.add< AnimationEditor<Rigid3Types> >()

;
.add< AnimationEditor<Vec3Types> >(true)
.add< AnimationEditor<Rigid3Types> >());
}

template class SOFA_SOFTROBOTS_API AnimationEditor<Vec3Types>;
template class SOFA_SOFTROBOTS_API AnimationEditor<Rigid3Types>;
Expand Down
28 changes: 14 additions & 14 deletions src/SoftRobots/component/controller/CommunicationController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,24 @@ std::string CommunicationController<vector<Rigid3fTypes::Coord>>::GetCustomTempl


//////////////////////////////////////////// FACTORY ////////////////////////////////////////////
using sofa::core::RegisterObject ;
using sofa::defaulttype::Rigid3Types;
using sofa::defaulttype::Vec3Types;
using sofa::defaulttype::Vec1Types;

int CommunicationControllerClass = RegisterObject("This component is used to build a communication between two simulations")

.add< CommunicationController<double> >(true)
.add< CommunicationController<vector<Vec3Types::Coord>> >()
.add< CommunicationController<vector<Vec1Types::Coord>> >()
.add< CommunicationController<vector<Rigid3Types::Coord>> >()

.add< CommunicationController<int> >()
.add< CommunicationController<unsigned int> >()
.add< CommunicationController<vector<Vec<2,int>>> >()
.add< CommunicationController<vector<Vec<1,unsigned int>>> >()
.add< CommunicationController<vector<Vec<2,unsigned int>>> >()
;
void registerCommunicationController(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("This component is used to build a communication between two simulations")
.add< CommunicationController<double> >(true)
.add< CommunicationController<vector<Vec3Types::Coord>> >()
.add< CommunicationController<vector<Vec1Types::Coord>> >()
.add< CommunicationController<vector<Rigid3Types::Coord>> >()

.add< CommunicationController<int> >()
.add< CommunicationController<unsigned int> >()
.add< CommunicationController<vector<Vec<2,int>>> >()
.add< CommunicationController<vector<Vec<1,unsigned int>>> >()
.add< CommunicationController<vector<Vec<2,unsigned int>>> >());
}

template class CommunicationController<double>;
template class CommunicationController<vector<Vec3Types::Coord>>;
Expand Down
8 changes: 5 additions & 3 deletions src/SoftRobots/component/controller/DataControllerRobot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ using namespace sofa::defaulttype;
SOFA_DECL_CLASS(DataControllerRobot)

// Register in the Factory
int DataControllerRobotClass = core::RegisterObject(" ")
.add< DataControllerRobot >()
;
void registerDataControllerRobot(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData(" ")
.add< DataControllerRobot>());
}


DataControllerRobot::DataControllerRobot():
Expand Down
8 changes: 5 additions & 3 deletions src/SoftRobots/component/controller/DataControllerRobot2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ using namespace sofa::defaulttype;
SOFA_DECL_CLASS(DataControllerRobot)

// Register in the Factory
int DataControllerRobotClass = core::RegisterObject(" ")
.add< DataControllerRobot >()
;
void registerDataControllerRobot(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData(" ")
.add< DataControllerRobot>());
}


DataControllerRobot::DataControllerRobot():
Expand Down
21 changes: 11 additions & 10 deletions src/SoftRobots/component/controller/DataVariationLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ namespace softrobots::controller

using namespace sofa::defaulttype;
using namespace sofa::type;
using sofa::core::RegisterObject;

int DataVariationLimiterClass = RegisterObject("This component interpolates between two consecutive inputs when a jump is detected.")
.add< DataVariationLimiter<Vec3Types::Coord> >(true)
.add< DataVariationLimiter<Vec2Types::Coord> >()
.add< DataVariationLimiter<Vec1Types::Coord> >()

.add< DataVariationLimiter<sofa::type::Vec1i> >()
.add< DataVariationLimiter<sofa::type::Vec2i> >()
.add< DataVariationLimiter<sofa::type::Vec3i> >()
;
void registerDataVariationLimiter(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("This component interpolates between two consecutive inputs when a jump is detected.")
.add< DataVariationLimiter<Vec3Types::Coord> >(true)
.add< DataVariationLimiter<Vec2Types::Coord> >()
.add< DataVariationLimiter<Vec1Types::Coord> >()

.add< DataVariationLimiter<sofa::type::Vec1i> >()
.add< DataVariationLimiter<sofa::type::Vec2i> >()
.add< DataVariationLimiter<sofa::type::Vec3i> >());
}

template class SOFA_SOFTROBOTS_API DataVariationLimiter<Vec3Types::Coord>;
template class SOFA_SOFTROBOTS_API DataVariationLimiter<Vec2Types::Coord>;
Expand Down
8 changes: 5 additions & 3 deletions src/SoftRobots/component/controller/GameTrakController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ using sofa::core::RegisterObject ;

SOFA_DECL_CLASS(GameTrakController)

int GameTrakControllerClass = RegisterObject("Interface for GameTrak device.")
.add< GameTrakController >()
;
void registerGameTrakController(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Interface for GameTrak device.")
.add< GameTrakController>());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////

using namespace gametrak ;
Expand Down
8 changes: 5 additions & 3 deletions src/SoftRobots/component/controller/InteractiveControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ namespace softrobots::controller
using namespace sofa::defaulttype;
using namespace sofa::helper;


int InteractiveControlClass = sofa::core::RegisterObject("InteractiveControl (Controls external motors via network)")
.add< InteractiveControl >();
void registerInteractiveControl(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("InteractiveControl (Controls external motors via network)")
.add< InteractiveControl>());
}

InteractiveControl::InteractiveControl()
: d_motorIndex(initData(&d_motorIndex, (unsigned int)0, "motorIndex", "index of controlled motor (0 to 255 max)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ using sofa::type::Vec;
using sofa::helper::WriteAccessor;
using sofa::core::objectmodel::ComponentState;

int SerialPortBridgeGenericClass = sofa::core::RegisterObject("Send data (ex: force, displacement, pressure…) through the usb port. \n"
void registerSerialPortBridgeGeneric(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Send data (ex: force, displacement, pressure…) through the usb port. \n"
"Usually used to send data to an Arduino card to control the real robot.")
.add< SerialPortBridgeGeneric >()
;
.add< SerialPortBridgeGeneric >());
}

SerialPortBridgeGeneric::SerialPortBridgeGeneric()
: d_port(initData(&d_port, "port", "Serial port name"))
Expand Down
9 changes: 5 additions & 4 deletions src/SoftRobots/component/engine/CenterOfMass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ namespace softrobots::engine

using namespace sofa::defaulttype;
using namespace sofa::helper;
using sofa::core::RegisterObject;

int CenterOfMassClass = RegisterObject("This class computes the center of mass of the object in its context.")
.add< CenterOfMass<Vec3Types> >(true)
void registerCenterOfMass(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("This class computes the center of mass of the object in its context.")
.add< CenterOfMass<Vec3Types> >(true));
}

;

template class SOFA_SOFTROBOTS_API CenterOfMass<Vec3Types>;

Expand Down
10 changes: 5 additions & 5 deletions src/SoftRobots/component/engine/VolumeFromTetrahedrons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ namespace softrobots::engine

using namespace sofa::defaulttype;
using namespace sofa::helper;
using sofa::core::RegisterObject;

int VolumeFromTetrahedronsClass = RegisterObject("This class computes the volume of a given volumetric mesh.")
.add< VolumeFromTetrahedrons<Vec3Types> >(true)

;
void registerVolumeFromTetrahedrons(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("This class computes the volume of a given volumetric mesh.")
.add< VolumeFromTetrahedrons<Vec3Types> >(true));
}

template class SOFA_SOFTROBOTS_API VolumeFromTetrahedrons<Vec3Types>;

Expand Down
10 changes: 5 additions & 5 deletions src/SoftRobots/component/engine/VolumeFromTriangles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ namespace softrobots::engine

using namespace sofa::defaulttype;
using namespace sofa::helper;
using sofa::core::RegisterObject;

int VolumeFromTrianglesClass = RegisterObject("This class computes the volume of a given closed surfacic mesh.")
.add< VolumeFromTriangles<Vec3Types> >(true)

;
void registerVolumeFromTriangles(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("This class computes the volume of a given closed surfacic mesh.")
.add< VolumeFromTriangles<Vec3Types> >(true));
}

template class SOFA_SOFTROBOTS_API VolumeFromTriangles<Vec3Types>;

Expand Down
Loading
Loading