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>
72#ifdef ENABLE_VISP_NAMESPACE
87 std::string logdirname =
"/tmp/" + username;
96 std::cerr << std::endl <<
"ERROR:" << std::endl;
97 std::cerr <<
" Cannot create " << logdirname << std::endl;
101 std::string logfilename = logdirname +
"/log.dat";
104 std::ofstream flog(logfilename.c_str());
110 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
111 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
112 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
118 for (
size_t i = 0;
i < 10; ++
i) {
127 std::cout <<
"-------------------------------------------------------" << std::endl;
128 std::cout <<
" Test program for vpServo " << std::endl;
129 std::cout <<
" Eye-in-hand task control, velocity computed in the joint space" << std::endl;
130 std::cout <<
" Use of the Afma6 robot " << std::endl;
131 std::cout <<
" task : servo 4 points on a square with dimension " << L <<
" meters" << std::endl;
132 std::cout <<
"-------------------------------------------------------" << std::endl;
134 std::vector<vpDot2> dot(4);
136 std::cout <<
"Click on the 4 dots clockwise starting from upper/left dot..." << std::endl;
137 for (
size_t i = 0;
i < dot.size(); ++
i) {
138 dot[
i].initTracking(I);
153 robot.getCameraParameters(cam, I);
156 std::vector<vpFeaturePoint>
s(4);
157 for (
size_t i = 0;
i <
s.size(); ++
i) {
178 for (
size_t i = 0;
i <
s.size(); ++
i) {
179 task.addFeature(s[i], s_d[i]);
187 robot.get_cVe(c_V_e);
192 robot.get_eJe(e_J_e);
201 std::cout <<
"\nHit CTRL-C to stop the loop...\n" << std::flush;
212 for (
size_t i = 0;
i < dot.size(); ++
i) {
220 robot.get_eJe(e_J_e);
238 flog << qdot[0] <<
" " << qdot[1] <<
" " << qdot[2] <<
" " << qdot[3] <<
" " << qdot[4] <<
" " << qdot[5] <<
" ";
246 flog << qdot_mes[0] <<
" " << qdot_mes[1] <<
" " << qdot_mes[2] <<
" " << qdot_mes[3] <<
" " << qdot_mes[4] <<
" " << qdot_mes[5] <<
" ";
256 flog << q[0] <<
" " << q[1] <<
" " << q[2] <<
" " << q[3] <<
" " << q[4] <<
" " << q[5] <<
" ";
261 flog << (
task.getError()).
t() << std::endl;
282 std::cout <<
"Visual servo failed with exception: " <<
e << std::endl;
290 std::cout <<
"You do not have an afma6 robot connected to your computer..." << std::endl;
Generic class defining intrinsic camera parameters.
vpCameraParametersProjType
@ perspectiveProjWithDistortion
Perspective projection with 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)
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.
Implementation of a matrix and operations on matrices.
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.