![]() |
Visual Servoing Platform version 3.7.0
|
This tutorial gives some guide lines to explain how to introduce a new class that depends on an external 3rd-party that has its own SDK.
We suppose here that you followed one of the Installation from source code tutorials.
Let us consider the case where we want to implement a new class with name vpDummyWrapper that belongs to visp_robot module and that is a wrapper over a 3rd-party SDK called DummySDK. This SDK contains headers and libraries that are organized like:
To illustrate this tutorial, let us consider that <dummy sdk root path> is equal to /home/user/visp-ws/3rdparty/dummy-sdk folder.
In order that ViSP remains cross-platform, here we should consider that this dummy SDK is used only if VISP_HAVE_DUMMY_SDK macro is defined. We suppose here that this macro is automatically defined (or not) in visp3/core/vpConfig.h file that is located in ViSP build tree, more precisely in $VISP_WS/visp-build/include folder.
The class declaration is implemented in vpDummyWrapper.h. Since we want that the class belongs to visp_robot module, you have to put this file in $VISP_WS/visp/modules/robot/include/visp3/robot/ folder. The content of this file looks like:
The corresponding class definition is implemented in vpDummyWrapper.cpp located for example in a new folder dummy_sdk that belongs to visp_robot module like $VISP_WS/visp/modules/robot/src/real-robot/dummy_sdk/vpDummyWrapper.cpp:
Now you should modify ViSP source code to define VISP_HAVE_DUMMY_SDK macro when DummySDK package is found. We recall that this macro is used to protect the class that should be build only if this macro is defined.
#ifndef vpDummyWrapper_h
#define vpDummyWrapper_h
#include <visp3/core/vpConfig.h>
#ifdef VISP_HAVE_DUMMY_SDK
#include <dummy_sdk_header.h>
/*!
\class vpDummyWrapper Dummy wrapper example.
*/
class VISP_EXPORT vpDummyWrapper
{
public:
vpDummyWrapper();
virtual ~vpDummyWrapper();
...
};
#endif
#endif
where VISP_HAVE_DUMMY_SDK macro is used to ensure that the build doesn't fail when DummySDK package is not detected or not used. There is also the "\class" Doxygen directive that allows to expose vpDummyWrapper class in Doxygen documentation that is generated using make visp_doc.#include <visp3/robot/vpDummyWrapper.h>
#ifdef VISP_HAVE_DUMMY_SDK
/*!
Default constructor.
*/
vpDummyWrapper::vpDummyWrapper() {}
/*!
Default destructor.
*/
vpDummyWrapper::~vpDummyWrapper() {}
#endif
//! \example testForceTorqueIitSensor.cpp
#include <iostream>
#include <visp3/robot/vpDummyWrapper.h>
int main()
{
#ifdef VISP_HAVE_DUMMY_SDK
vpDummyWrapper wrapper;
...
#else
std::cout << "ViSP is not build with DummySDK support" << std::endl;
#endif
return EXIT_SUCCESS;
}
Here we explain how to introduce a new example in ViSP example folder.
//! \example exampleDummy.cpp
#include <iostream>
#include <visp3/robot/vpDummyWrapper.h>
int main()
{
#ifdef VISP_HAVE_DUMMY_SDK
vpDummyWrapper wrapper;
...
#else
std::cout << "ViSP is not build with DummySDK support" << std::endl;
#endif
return EXIT_SUCCESS;
}
This sections explains how to add a new Doxygen tutorial like this one, that may appear in ViSP main page documentation
/**\page tutorial-dummy-robot Tutorial: How to start with dummy robot \tableofcontents \section dummy_intro Introduction Bla Bla... */
\subsection tuto_robot Playing with robots \ref tutorial-dummy-robot <br>This tutorial explains how to start with dummy robot.
/*! \page tutorial_mainpage Tutorials This page references all the tutorials. ... \subpage tutorial_robot */ /*! \page tutorial_robot Playing with robots This page introduces the way toplay with robots. \subpage tutorial-dummy-robot <br>This tutorial explains how to start with dummy robot. */
We suppose here that you Modify ViSP source code and that you want to create your own external project that uses the new dummyWrapper class. This as simple as adding a new example inside ViSP as described in Add a new example.
//! \example exampleDummy.cpp
#include <iostream>
#include <visp3/robot/vpDummyWrapper.h>
int main()
{
#ifdef VISP_HAVE_DUMMY_SDK
vpDummyWrapper wrapper;
...
#else
std::cout << "ViSP is not build with DummySDK support" << std::endl;
#endif
return EXIT_SUCCESS;
}
Bellow we give a list of some Pull Request to illustrate this tutorial with real use cases: