47#include <visp3/core/vpConfig.h>
49#if defined(VISP_HAVE_AFMA6) && defined(VISP_HAVE_REALSENSE2) && defined(VISP_HAVE_DISPLAY)
51#include <visp3/core/vpImage.h>
52#include <visp3/core/vpIoTools.h>
53#include <visp3/gui/vpDisplayFactory.h>
54#include <visp3/sensor/vpRealSense2.h>
55#include <visp3/blob/vpDot2.h>
56#include <visp3/robot/vpRobotAfma6.h>
57#include <visp3/visual_features/vpFeatureBuilder.h>
58#include <visp3/visual_features/vpFeaturePoint.h>
59#include <visp3/vs/vpServo.h>
60#include <visp3/vs/vpServoDisplay.h>
65#ifdef ENABLE_VISP_NAMESPACE
80 std::string logdirname =
"/tmp/" + username;
89 std::cerr << std::endl <<
"ERROR:" << std::endl;
90 std::cerr <<
" Cannot create " << logdirname << std::endl;
94 std::string logfilename = logdirname +
"/log.dat";
97 std::ofstream flog(logfilename.c_str());
103 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
104 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
105 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
111 for (
size_t i = 0;
i < 10; ++
i) {
120 std::cout <<
"-------------------------------------------------------" << std::endl;
121 std::cout <<
" Test program for vpServo " << std::endl;
122 std::cout <<
" Eye-in-hand task control, velocity computed in the joint space" << std::endl;
123 std::cout <<
" Use of the Afma6 robot " << std::endl;
124 std::cout <<
" task : servo a point " << std::endl;
125 std::cout <<
"-------------------------------------------------------" << std::endl;
130 std::cout <<
"Click on a dot..." << std::endl;
143 robot.getCameraParameters(cam, I);
161 task.addFeature(s, s_d);
172 std::cout <<
"\nHit CTRL-C to stop the loop...\n" << std::flush;
200 flog << v_c[0] <<
" " << v_c[1] <<
" " << v_c[2] <<
" " << v_c[3] <<
" " << v_c[4] <<
" " << v_c[5] <<
" ";
208 flog << qdot_mes[0] <<
" " << qdot_mes[1] <<
" " << qdot_mes[2] <<
" " << qdot_mes[3] <<
" " << qdot_mes[4] <<
" " << qdot_mes[5] <<
" ";
218 flog << q[0] <<
" " << q[1] <<
" " << q[2] <<
" " << q[3] <<
" " << q[4] <<
" " << q[5] <<
" ";
223 flog << (
task.getError()).
t() << std::endl;
244 std::cout <<
"Visual servo failed with exception: " <<
e << std::endl;
252 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 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.
void initTracking(const vpImage< unsigned char > &I)
void setGraphics(bool activate)
vpImagePoint getCog() const
void track(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...
vpFeaturePoint & buildFrom(const double &x, const double &y, const double &Z)
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.