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/vision/vpPose.h>
59#include <visp3/visual_features/vpFeatureBuilder.h>
60#include <visp3/visual_features/vpFeatureDepth.h>
61#include <visp3/visual_features/vpFeaturePoint.h>
62#include <visp3/visual_features/vpFeatureThetaU.h>
63#include <visp3/vs/vpServo.h>
64#include <visp3/vs/vpServoDisplay.h>
72#ifdef ENABLE_VISP_NAMESPACE
80 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
81 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
82 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
88 for (
size_t i = 0;
i < 10; ++
i) {
106 robot.getCameraParameters(cam, I);
108 std::cout <<
"-------------------------------------------------------" << std::endl;
109 std::cout <<
" Test program for vpServo " << std::endl;
110 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl;
111 std::cout <<
" Simulation " << std::endl;
112 std::cout <<
" task : servo a line " << std::endl;
113 std::cout <<
"-------------------------------------------------------" << std::endl;
118 vpTRACE(
"sets the desired position of the visual feature ");
156 for (
int i = 0;
i < nbline; ++
i) {
165 for (
int i = 0;
i < nbline; ++
i) {
188 for (
int i = 0;
i < nbline; ++
i) {
197 double xc = (point[0].
get_x() + point[2].get_x()) / 2;
198 double yc = (point[0].
get_y() + point[2].get_y()) / 2;
215 cd_M_c = cd_M_o * c_M_o.
inverse();
217 s_tu.buildFrom(cd_M_c);
227 task.addFeature(s_p, s_pd);
228 task.addFeature(s_logZ);
229 task.addFeature(s_tu);
233 task.setLambda(lambda);
249 for (
int i = 0;
i < nbline; ++
i) {
272 xc = (point[0].
get_x() + point[2].get_x()) / 2;
273 yc = (point[0].
get_y() + point[2].get_y()) / 2;
282 for (
int i = 0;
i < nbpoint; ++
i) {
290 cd_M_c = cd_M_o * c_M_o.
inverse();
310 std::cout <<
"Visual servo failed with exception: " <<
e << std::endl;
318 std::cout <<
"You do not have an afma6 robot connected to your computer..." << std::endl;
Adaptive gain computation.
Generic class defining intrinsic camera parameters.
vpCameraParametersProjType
@ perspectiveProjWithDistortion
Perspective projection with 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)
Class that defines a 3D point visual feature which is composed by one parameters that is that defin...
vpFeatureDepth & buildFrom(const double &x, const double &y, const double &Z, const double &LogZoverZstar)
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const VP_OVERRIDE
Class that defines a 3D visual feature from a axis/angle parametrization that represent the rotati...
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix & buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
vpHomogeneousMatrix inverse() const
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 tracks in an image a line moving edges.
void display(const vpImage< unsigned char > &I, const vpColor &color, unsigned int thickness=1)
void track(const vpImage< unsigned char > &I)
void initTracking(const vpImage< unsigned char > &I)
static bool intersection(const vpMeLine &line1, const vpMeLine &line2, vpImagePoint &iP)
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)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void set_x(double x)
Set the point x coordinate in the image plane.
double get_y() const
Get the point y coordinate in the image plane.
double get_x() const
Get the point x coordinate in the image plane.
double get_Z() const
Get the point cZ coordinate in the camera frame.
void display(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpColor &color=vpColor::green, unsigned int thickness=1) VP_OVERRIDE
void setWorldCoordinates(double oX, double oY, double oZ)
void set_y(double y)
Set the point y coordinate in the image plane.
Class used for pose computation from N points (pose from point only). Some of the algorithms implemen...
void addPoint(const vpPoint &P)
@ DEMENTHON_LAGRANGE_VIRTUAL_VS
bool computePose(vpPoseMethodType method, vpHomogeneousMatrix &cMo, FuncCheckValidityPose func=nullptr)
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.