35#include <visp3/core/vpConfig.h>
46#include <visp3/blob/vpDot2.h>
47#include <visp3/core/vpCameraParameters.h>
48#include <visp3/core/vpHomogeneousMatrix.h>
49#include <visp3/core/vpImage.h>
50#include <visp3/core/vpImageConvert.h>
51#include <visp3/core/vpVelocityTwistMatrix.h>
52#include <visp3/gui/vpDisplayFactory.h>
53#include <visp3/robot/vpRobotPioneer.h>
54#include <visp3/sensor/vp1394CMUGrabber.h>
55#include <visp3/sensor/vp1394TwoGrabber.h>
56#include <visp3/sensor/vpV4l2Grabber.h>
57#include <visp3/visual_features/vpFeatureBuilder.h>
58#include <visp3/visual_features/vpFeatureDepth.h>
59#include <visp3/visual_features/vpFeaturePoint.h>
60#include <visp3/vs/vpServo.h>
62#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)
63#include <opencv2/highgui/highgui.hpp>
64#elif defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)
65#include <opencv2/videoio/videoio.hpp>
68#if defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_OPENCV) && \
69 (((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
70 ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
71#if defined(VISP_HAVE_DISPLAY)
72#if defined(VISP_HAVE_PIONEER)
73#define TEST_COULD_BE_ACHIEVED
100#ifdef TEST_COULD_BE_ACHIEVED
101int main(
int argc,
char **argv)
103#ifdef ENABLE_VISP_NAMESPACE
107#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
108 std::shared_ptr<vpDisplay> display;
116 double coef = 1. / 6.77;
120 ArArgumentParser
parser(&argc, argv);
121 parser.loadDefaultArguments();
125 ArRobotConnector robotConnector(&parser, &robot);
126 if (!robotConnector.connectRobot()) {
127 ArLog::log(ArLog::Terse,
"Could not connect to the robot.");
128 if (
parser.checkHelpAndWarnUnparsed()) {
133 if (!Aria::parseArgs()) {
145 std::cout <<
"Robot connected" << std::endl;
152#if defined(VISP_HAVE_OPENCV) && \
153 (((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
154 ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
156 std::cout <<
"Use device: " << device << std::endl;
157 cv::VideoCapture g(device);
158 g.set(CV_CAP_PROP_FRAME_WIDTH, 640);
159 g.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
167 cam.initPersProjWithoutDistortion(558, 555, 312, 210);
168#elif defined(VISP_HAVE_V4L2)
177 cam.initPersProjWithoutDistortion(558, 555, 312, 210);
178#elif defined(VISP_HAVE_DC1394)
185 cam.initPersProjWithoutDistortion(800, 795, 320, 216);
186#elif defined(VISP_HAVE_CMU1394)
194 cam.initPersProjWithoutDistortion(800, 795, 320, 216);
198#if defined(VISP_HAVE_OPENCV) && \
199 (((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
200 ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
208#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
231 task.setLambda(lambda);
233 cVe = robot.get_cVe();
236 std::cout <<
"cVe: \n" << cVe << std::endl;
241 std::cout <<
"eJe: \n" << eJe << std::endl;
254 task.addFeature(s_x, s_xd);
260 double surface = 1. / sqrt(dot.
m00 / (
cam.get_px() *
cam.get_py()));
268 std::cout <<
"Z " << Z << std::endl;
275 task.addFeature(s_Z, s_Zd);
281#if defined(VISP_HAVE_OPENCV) && \
282 (((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
283 ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
299 surface = 1. / sqrt(dot.
m00 / (
cam.get_px() *
cam.get_py()));
311 v =
task.computeControlLaw();
313 std::cout <<
"Send velocity to the pioneer: " <<
v[0] <<
" m/s " <<
vpMath::deg(v[1]) <<
" deg/s" << std::endl;
328 std::cout <<
"Ending robot thread..." << std::endl;
332 robot.waitForRunExit();
336#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
337 if (display !=
nullptr) {
344 std::cout <<
"Catch an exception: " <<
e << std::endl;
345#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
346 if (display !=
nullptr) {
356 std::cout <<
"You don't have the right 3rd party libraries to run this example..." << std::endl;
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
void setVideoMode(unsigned long format, unsigned long mode)
void acquire(vpImage< unsigned char > &I)
void setFramerate(unsigned long fps)
void open(vpImage< unsigned char > &I)
Class for firewire ieee1394 video devices using libdc1394-2.x api.
@ vpVIDEO_MODE_640x480_MONO8
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Class that defines generic functionalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void flush(const vpImage< unsigned char > &I)
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
void track(const vpImage< unsigned char > &I, bool canMakeTheWindowGrow=true)
void setGraphics(bool activate)
void setGrayLevelPrecision(const double &grayLevelPrecision)
void setEllipsoidBadPointsPercentage(const double &percentage=0.0)
void setEllipsoidShapePrecision(const double &ellipsoidShapePrecision)
void setComputeMoments(bool activate)
void initTracking(const vpImage< unsigned char > &I, unsigned int size=0)
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...
vpFeaturePoint & buildFrom(const double &x, const double &y, const double &Z)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Definition of the vpImage class member functions.
static double deg(double rad)
Implementation of a matrix and operations on matrices.
Interface for Pioneer mobile robots based on Aria 3rd party library.
Class that is a wrapper over the Video4Linux2 (V4L2) driver.
void setFramerate(vpV4l2FramerateType framerate)
void setInput(unsigned input=vpV4l2Grabber::DEFAULT_INPUT)
void open(vpImage< unsigned char > &I)
void setScale(unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
void setDevice(const std::string &devname)
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.
VISP_EXPORT void sleepMs(double t)