Visual servoing experiment on 4 points with a display.
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpDebug.h>
#if defined(VISP_HAVE_DISPLAY)
#include <visp3/core/vpCameraParameters.h>
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/core/vpTime.h>
#include <visp3/gui/vpDisplayFactory.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/core/vpMath.h>
#include <visp3/robot/vpSimulatorCamera.h>
#include <visp3/vision/vpPose.h>
#include <visp3/visual_features/vpFeatureBuilder.h>
#include <visp3/visual_features/vpFeaturePoint.h>
#include <visp3/vs/vpServo.h>
#include <visp3/vs/vpServoDisplay.h>
int main()
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
#else
#endif
try {
wMc = wMo * cMo.inverse();
robot.setPosition(wMc);
unsigned int height = 360;
unsigned int width = 480;
#if defined(VISP_HAVE_DISPLAY)
disp->init(I, 100, 100, "Simulation display");
#endif
for (int i = 0; i < 4; i++)
point[i].project(cMo_d);
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
point[i].project(cMo);
for (int i = 0; i < 4; i++)
task.set_cVe(cVe);
robot.get_eJe(eJe);
task.set_eJe(eJe);
for (int i = 0; i < 4; i++)
task.addFeature(p[i], pd[i]);
task.setLambda(1.0);
task.print();
int k = 0;
while (k++ < 200) {
for (int i = 0; i < 4; i++) {
}
robot.get_eJe(eJe);
task.set_eJe(eJe);
wMc = robot.getPosition();
task.print();
}
#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
if (disp != nullptr) {
delete disp;
}
#endif
return EXIT_SUCCESS;
}
std::cout << "Catch an exception: " << e << std::endl;
#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
if (disp != nullptr) {
delete disp;
}
#endif
return EXIT_FAILURE;
}
}
#else
int main()
{
std::cout
<< "You do not have X11, GTK, or OpenCV, or GDI (Graphical Device Interface) functionalities to display images..."
<< std::endl;
std::cout << "Tip if you are on a unix-like system:" << std::endl;
std::cout << "- Install X11, configure again ViSP using cmake and build again this example" << std::endl;
std::cout << "Tip if you are on a windows-like system:" << std::endl;
std::cout << "- Install GDI, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
}
#endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Class that defines generic functionalities for display.
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
error that can be emitted by ViSP classes.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
Definition of the vpImage class member functions.
static double rad(double deg)
Implementation of a matrix and operations on matrices.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void setWorldCoordinates(double oX, double oY, double oZ)
virtual void setSamplingTime(const double &delta_t)
static void display(const vpServo &s, const vpCameraParameters &cam, const vpImage< unsigned char > &I, vpColor currentColor=vpColor::green, vpColor desiredColor=vpColor::red, unsigned int thickness=1)
Class that defines the simplest robot: a free flying camera.
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.
VISP_EXPORT double measureTimeMs()
VISP_EXPORT int wait(double t0, double t)