46#include <visp3/core/vpConfig.h>
48#if defined(VISP_HAVE_REALSENSE2) && defined(VISP_HAVE_DISPLAY) && defined(VISP_HAVE_AFMA6)
50#include <visp3/core/vpImage.h>
51#include <visp3/core/vpHomogeneousMatrix.h>
52#include <visp3/core/vpLine.h>
53#include <visp3/core/vpMath.h>
54#include <visp3/gui/vpDisplayFactory.h>
55#include <visp3/robot/vpRobotAfma6.h>
56#include <visp3/sensor/vpRealSense2.h>
57#include <visp3/me/vpMeLine.h>
58#include <visp3/visual_features/vpFeatureBuilder.h>
59#include <visp3/visual_features/vpFeatureLine.h>
60#include <visp3/vs/vpServo.h>
61#include <visp3/vs/vpServoDisplay.h>
65#ifdef ENABLE_VISP_NAMESPACE
73 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
74 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
75 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
81 for (
size_t i = 0;
i < 10; ++
i) {
90 std::cout <<
"-------------------------------------------------------" << std::endl;
91 std::cout <<
" Test program for vpServo " << std::endl;
92 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl;
93 std::cout <<
" Simulation " << std::endl;
94 std::cout <<
" task : servo a point " << std::endl;
95 std::cout <<
"-------------------------------------------------------" << std::endl;
99 std::vector<vpMeLine> line(nb_lines);
110 for (
int i = 0;
i < nb_lines; ++
i) {
114 line[
i].initTracking(I);
124 robot.getCameraParameters(cam, I);
127 std::vector<vpFeatureLine> s_line(nb_lines);
128 for (
int i = 0;
i < nb_lines; ++
i) {
133 std::vector<vpLine> line_d(2);
134 line_d[0].setWorldCoordinates(1, 0, 0, -0.05, 0, 0, 1, 0);
135 line_d[1].setWorldCoordinates(1, 0, 0, 0.05, 0, 0, 1, 0);
139 line_d[0].project(c_M_o);
140 line_d[1].project(c_M_o);
146 line_d[0].setRho(-fabs(line_d[0].getRho()));
147 line_d[0].setTheta(0);
148 line_d[1].setRho(-fabs(line_d[1].getRho()));
149 line_d[1].setTheta(M_PI);
151 std::vector<vpFeatureLine> s_line_d(nb_lines);
162 for (
int i = 0;
i < nb_lines; ++
i) {
163 task.addFeature(s_line[i], s_line_d[i]);
180 for (
int i = 0;
i < nb_lines; ++
i) {
208 std::cout <<
"Visual servo failed with exception: " <<
e << std::endl;
216 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 green
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
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.
Definition of the vpImage class member functions.
static double rad(double deg)
void setPointsToTrack(const int &points_to_track)
void setRange(const unsigned int &range)
void setLikelihoodThresholdType(const vpLikelihoodThresholdType likelihood_threshold_type)
void setThreshold(const double &threshold)
void setSampleStep(const double &sample_step)
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.
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.