48#include <visp3/core/vpConfig.h>
50#if defined(VISP_HAVE_AFMA6) && defined(VISP_HAVE_REALSENSE2) && defined(VISP_HAVE_DISPLAY)
52#include <visp3/core/vpImage.h>
53#include <visp3/core/vpIoTools.h>
54#include <visp3/gui/vpDisplayFactory.h>
55#include <visp3/sensor/vpRealSense2.h>
56#include <visp3/blob/vpDot2.h>
57#include <visp3/robot/vpRobotAfma6.h>
58#include <visp3/visual_features/vpFeatureBuilder.h>
59#include <visp3/visual_features/vpFeaturePoint.h>
60#include <visp3/vs/vpServo.h>
61#include <visp3/vs/vpServoDisplay.h>
69#ifdef ENABLE_VISP_NAMESPACE
84 std::string logdirname =
"/tmp/" + username;
93 std::cerr << std::endl <<
"ERROR:" << std::endl;
94 std::cerr <<
" Cannot create " << logdirname << std::endl;
98 std::string logfilename = logdirname +
"/log.dat";
101 std::ofstream flog(logfilename.c_str());
107 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
108 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
109 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
115 for (
size_t i = 0;
i < 10; ++
i) {
124 std::cout <<
"-------------------------------------------------------" << std::endl;
125 std::cout <<
" Test program for vpServo " << std::endl;
126 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl;
127 std::cout <<
" Use of the Afma6 robot " << std::endl;
128 std::cout <<
" Interaction matrix computed with the desired features " << std::endl;
130 std::cout <<
" task : servo 4 points on a square with dimension " << L <<
" meters" << std::endl;
131 std::cout <<
"-------------------------------------------------------" << std::endl;
133 std::vector<vpDot2> dot(4);
135 std::cout <<
"Click on the 4 dots clockwise starting from upper/left dot..." << std::endl;
136 for (
size_t i = 0;
i < dot.size(); ++
i) {
137 dot[
i].initTracking(I);
152 robot.getCameraParameters(cam, I);
155 std::vector<vpFeaturePoint>
s(4);
156 for (
size_t i = 0;
i <
s.size(); ++
i) {
176 std::vector<vpFeaturePoint> s_d(4);
178 for (
size_t i = 0;
i < s_d.size(); ++
i) {
197 for (
size_t i = 0;
i <
s.size(); ++
i) {
198 task.addFeature(s[i], s_d[i]);
210 std::cout <<
"\nHit CTRL-C to stop the loop...\n" << std::flush;
221 for (
size_t i = 0;
i < dot.size(); ++
i) {
240 flog <<
v[0] <<
" " <<
v[1] <<
" " <<
v[2] <<
" " <<
v[3] <<
" " <<
v[4] <<
" " <<
v[5] <<
" ";
250 flog << qvel[0] <<
" " << qvel[1] <<
" " << qvel[2] <<
" " << qvel[3] <<
" " << qvel[4] <<
" " << qvel[5] <<
" ";
260 flog << q[0] <<
" " << q[1] <<
" " << q[2] <<
" " << q[3] <<
" " << q[4] <<
" " << q[5] <<
" ";
265 flog << (
task.getError()).
t() << std::endl;
286 std::cout <<
"Visual servo failed with exception: " <<
e << std::endl;
294 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)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix & buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
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.
static double rad(double deg)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void projection(const vpColVector &_cP, vpColVector &_p) const VP_OVERRIDE
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) const VP_OVERRIDE
void setWorldCoordinates(double oX, double oY, double oZ)
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.
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a rotation vector as Euler angle minimal representation.
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 consider the case of a translation vector.
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.