35#include <visp3/core/vpConfig.h>
37#include <visp3/blob/vpDot2.h>
38#include <visp3/core/vpCameraParameters.h>
39#include <visp3/core/vpHomogeneousMatrix.h>
40#include <visp3/core/vpImage.h>
41#include <visp3/core/vpVelocityTwistMatrix.h>
42#include <visp3/gui/vpPlot.h>
43#include <visp3/robot/vpPioneerPan.h>
44#include <visp3/robot/vpRobotBiclops.h>
45#include <visp3/robot/vpRobotPioneer.h>
46#include <visp3/gui/vpDisplayFactory.h>
47#include <visp3/sensor/vp1394CMUGrabber.h>
48#include <visp3/sensor/vp1394TwoGrabber.h>
49#include <visp3/sensor/vpV4l2Grabber.h>
50#include <visp3/visual_features/vpFeatureBuilder.h>
51#include <visp3/visual_features/vpFeatureSegment.h>
52#include <visp3/vs/vpServo.h>
77#if defined(VISP_HAVE_PIONEER) && defined(VISP_HAVE_BICLOPS)
78int main(
int argc,
char **argv)
80#ifdef ENABLE_VISP_NAMESPACE
84#if defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_CMU1394)
85#if defined(VISP_HAVE_DISPLAY)
86#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
87 std::shared_ptr<vpDisplay> display;
98 double coef = 1.2 / 13.0;
101 bool normalized =
true;
136 ArArgumentParser
parser(&argc, argv);
137 parser.loadDefaultArguments();
141 ArRobotConnector robotConnector(&parser, &pioneer);
142 if (!robotConnector.connectRobot()) {
143 ArLog::log(ArLog::Terse,
"Could not connect to the pioneer robot.");
144 if (
parser.checkHelpAndWarnUnparsed()) {
149 if (!Aria::parseArgs()) {
163 std::cout <<
"Pioneer robot connected" << std::endl;
174#if defined(VISP_HAVE_V4L2)
183 cam.initPersProjWithoutDistortion(558, 555, 312, 210);
184#elif defined(VISP_HAVE_DC1394)
191 cam.initPersProjWithoutDistortion(800, 795, 320, 216);
192#elif defined(VISP_HAVE_CMU1394)
200 cam.initPersProjWithoutDistortion(800, 795, 320, 216);
207#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
217 for (
int i = 0;
i < 2;
i++) {
232 task.setLambda(lambda);
237 std::cout <<
"cVe: \n" << cVe << std::endl;
246 std::cout <<
"eJe: \n" << eJe << std::endl;
255 for (
int i = 0;
i < 2;
i++) {
264 for (
int i = 0;
i < 2;
i++) {
267 surface[
i] = 1. / sqrt(dot[i].m00 / (
cam.get_px() *
cam.get_py()));
270 Z[
i] = coef * surface[
i];
275 s_segment_d(normalized);
277 s_segment.setZ1(Z[0]);
278 s_segment.setZ2(Z[1]);
281 s_segment.setZ1(P[0].get_Z());
282 s_segment.setZ2(P[1].get_Z());
284 task.addFeature(s_segment, s_segment_d,
289 vpPlot graph(2, 500, 500, 700, 10,
"Curves...");
293 graph.initGraph(0, 3);
294 graph.initGraph(1, 3);
295 graph.setTitle(0,
"Velocities");
296 graph.setTitle(1,
"Error s-s*");
297 graph.setLegend(0, 0,
"vx");
298 graph.setLegend(0, 1,
"wz");
299 graph.setLegend(0, 2,
"w_pan");
300 graph.setLegend(1, 0,
"xm/l");
301 graph.setLegend(1, 1,
"1/l");
302 graph.setLegend(1, 2,
"alpha");
308 unsigned int iter = 0;
322 for (
int i = 0;
i < 2;
i++)
326 for (
int i = 0;
i < 2;
i++)
329 for (
int i = 0;
i < 2;
i++) {
332 surface[
i] = 1. / sqrt(dot[i].m00 / (
cam.get_px() *
cam.get_py()));
335 Z[
i] = coef * surface[
i];
343 s_segment.setZ1(Z[0]);
344 s_segment.setZ2(Z[1]);
358 v =
task.computeControlLaw();
369 if (
task.getTaskRank() != 3)
370 std::cout <<
"Warning: task is of rank " <<
task.getTaskRank() << std::endl;
373 graph.plot(0, iter, v);
374 graph.plot(1, iter,
task.getError());
386 std::cout <<
"Send velocity to the pionner: " << v_pioneer[0] <<
" m/s " <<
vpMath::deg(v_pioneer[1])
387 <<
" deg/s" << std::endl;
388 std::cout <<
"Send velocity to the Biclops head: " <<
vpMath::deg(v_biclops[0]) <<
" deg/s" << std::endl;
411 std::cout <<
"Ending robot thread..." << std::endl;
412 pioneer.stopRunning();
415 pioneer.waitForRunExit();
420#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
421 if (display !=
nullptr) {
428 std::cout <<
"Catch an exception: " <<
e << std::endl;
429#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
430 if (display !=
nullptr) {
442 std::cout <<
"ViSP is not able to control the Pioneer robot" << 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
@ DH1
First Denavit-Hartenberg representation.
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 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 2D segment visual features. This class allow to consider two sets of visual feat...
static unsigned int selectAlpha()
static unsigned int selectXc()
static unsigned int selectL()
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition of the vpImage class member functions.
static double deg(double rad)
Implementation of a matrix and operations on matrices.
Generic functions for Pioneer mobile robots equipped with a pan head.
void set_eJe(double q_pan)
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) const VP_OVERRIDE
void setWorldCoordinates(double oX, double oY, double oZ)
Interface for the Biclops, pan, tilt head control.
Interface for Pioneer mobile robots based on Aria 3rd party library.
void useSonar(bool usage)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
@ STATE_POSITION_CONTROL
Initialize the position controller.
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
vpVelocityTwistMatrix get_cVe() const
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.