56#include <visp3/core/vpConfig.h>
58#if defined(VISP_HAVE_REALSENSE2) && defined(VISP_HAVE_DISPLAY) && defined(VISP_HAVE_AFMA6)
60#include <visp3/core/vpImage.h>
61#include <visp3/core/vpHomogeneousMatrix.h>
62#include <visp3/core/vpLine.h>
63#include <visp3/core/vpMath.h>
64#include <visp3/gui/vpDisplayFactory.h>
65#include <visp3/robot/vpRobotAfma6.h>
66#include <visp3/sensor/vpRealSense2.h>
67#include <visp3/me/vpMeLine.h>
68#include <visp3/visual_features/vpFeatureBuilder.h>
69#include <visp3/visual_features/vpFeatureLine.h>
70#include <visp3/vs/vpServo.h>
71#include <visp3/vs/vpServoDisplay.h>
75#ifdef ENABLE_VISP_NAMESPACE
83 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
84 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
85 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
91 for (
size_t i = 0;
i < 10; ++
i) {
100 std::cout <<
"-------------------------------------------------------" << std::endl;
101 std::cout <<
" Test program for vpServo " << std::endl;
102 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl;
103 std::cout <<
" Simulation " << std::endl;
104 std::cout <<
" task : servo a line " << std::endl;
105 std::cout <<
"-------------------------------------------------------" << std::endl;
109 std::vector<vpMeLine> line(nb_lines);
119 for (
int i = 0;
i < nb_lines; ++
i) {
123 line[
i].initTracking(I);
132 robot.getCameraParameters(cam, I);
135 std::vector<vpFeatureLine> s_line(nb_lines);
136 for (
int i = 0;
i < nb_lines; ++
i)
140 std::vector<vpLine> line_d(nb_lines);
141 line_d[0].setWorldCoordinates(1, 0, 0, 0.05, 0, 0, 1, 0);
142 line_d[1].setWorldCoordinates(0, 1, 0, 0.05, 0, 0, 1, 0);
143 line_d[2].setWorldCoordinates(1, 0, 0, -0.05, 0, 0, 1, 0);
144 line_d[3].setWorldCoordinates(0, 1, 0, -0.05, 0, 0, 1, 0);
148 line_d[0].project(c_M_o);
149 line_d[1].project(c_M_o);
150 line_d[2].project(c_M_o);
151 line_d[3].project(c_M_o);
157 line_d[0].setRho(-fabs(line_d[0].getRho()));
158 line_d[0].setTheta(0);
159 line_d[1].setRho(-fabs(line_d[1].getRho()));
160 line_d[1].setTheta(M_PI / 2);
161 line_d[2].setRho(-fabs(line_d[2].getRho()));
162 line_d[2].setTheta(M_PI);
163 line_d[3].setRho(-fabs(line_d[3].getRho()));
164 line_d[3].setTheta(-M_PI / 2);
166 std::vector<vpFeatureLine> s_line_d(nb_lines);
181 for (
int i = 0;
i < nb_lines; ++
i) {
182 task.addFeature(s_line[i], s_line_d[i]);
199 for (
int i = 0;
i < nb_lines; ++
i) {
226 std::cout <<
"Visual servo failed with exception: " <<
e << std::endl;
234 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.