46#include <visp3/core/vpConfig.h>
47#include <visp3/core/vpDebug.h>
48#if (defined(VISP_HAVE_AFMA6) && defined(VISP_HAVE_REALSENSE2))
50#include <visp3/blob/vpDot.h>
51#include <visp3/core/vpDisplay.h>
52#include <visp3/core/vpException.h>
53#include <visp3/core/vpHomogeneousMatrix.h>
54#include <visp3/core/vpImage.h>
55#include <visp3/core/vpImagePoint.h>
56#include <visp3/core/vpIoTools.h>
57#include <visp3/core/vpMath.h>
58#include <visp3/core/vpPoint.h>
59#include <visp3/gui/vpDisplayFactory.h>
60#include <visp3/robot/vpRobotAfma6.h>
61#include <visp3/sensor/vpRealSense2.h>
62#include <visp3/visual_features/vpFeatureBuilder.h>
63#include <visp3/visual_features/vpFeatureSegment.h>
64#include <visp3/vs/vpServo.h>
65#include <visp3/vs/vpServoDisplay.h>
69#ifdef ENABLE_VISP_NAMESPACE
84 std::string logdirname;
85 logdirname =
"/tmp/" + username;
94 std::cerr << std::endl <<
"ERROR:" << std::endl;
95 std::cerr <<
" Cannot create " << logdirname << std::endl;
99 std::string logfilename;
100 logfilename = logdirname +
"/log.dat";
103 std::ofstream flog(logfilename.c_str());
105#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
106 std::shared_ptr<vpDisplay> display;
118 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
119 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
120 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
124 for (
size_t i = 0;
i < 10; ++
i) {
128#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
137 std::vector<vpDot> dot_d(2), dot(2);
145 robot.getCameraParameters(cam, I);
147 std::cout <<
"Define the initial segment" << std::endl;
149 for (std::vector<vpDot>::iterator i = dot.begin(); i != dot.end(); ++i) {
150 std::cout <<
"Click on a dot..." << std::endl;
159 std::cout <<
"define the destination segment" << std::endl;
160 for (std::vector<vpDot>::iterator i = dot_d.begin(); i != dot_d.end(); ++i) {
179 task.addFeature(seg, seg_d);
190 std::cout <<
"\nHit CTRL-C to stop the loop...\n" << std::flush;
200 for (std::vector<vpDot>::iterator i = dot.begin(); i != dot.end(); ++i) {
209 v =
task.computeControlLaw();
219 flog << (
task.getError()).t() << std::endl;
235#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
236 if (display !=
nullptr) {
245 std::cout <<
"Visual servo failed with exception: " <<
e << std::endl;
246#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
247 if (display !=
nullptr) {
258 std::cout <<
"You do not have an afma6 robot connected to your computer..." << std::endl;
Generic class defining intrinsic camera parameters.
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
Implementation of column vector and the associated operations.
static const vpColor blue
static const vpColor green
Class that defines generic functionalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
error that can be emitted by ViSP classes.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Class that defines a 2D segment visual features. This class allow to consider two sets of visual feat...
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const VP_OVERRIDE
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
void acquire(vpImage< unsigned char > &grey, double *ts=nullptr)
bool open(const rs2::config &cfg=rs2::config())
Control of Irisa's gantry robot named Afma6.
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
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)
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.