Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
tutorial-ibvs-4pts-plotter.cpp
1
2
#include <visp3/core/vpConfig.h>
3
#include <visp3/gui/vpPlot.h>
4
#include <visp3/robot/vpSimulatorCamera.h>
5
#include <visp3/visual_features/vpFeatureBuilder.h>
6
#include <visp3/vs/vpServo.h>
7
8
int
main()
9
{
10
#ifdef ENABLE_VISP_NAMESPACE
11
using namespace
VISP_NAMESPACE_NAME
;
12
#endif
13
14
try
{
15
vpHomogeneousMatrix
cdMo(0, 0, 0.75, 0, 0, 0);
16
vpHomogeneousMatrix
cMo
(0.15, -0.1, 1.,
vpMath::rad
(10),
vpMath::rad
(-10),
vpMath::rad
(50));
17
18
vpPoint
point[4];
19
point[0].
setWorldCoordinates
(-0.1, -0.1, 0);
20
point[1].
setWorldCoordinates
(0.1, -0.1, 0);
21
point[2].
setWorldCoordinates
(0.1, 0.1, 0);
22
point[3].
setWorldCoordinates
(-0.1, 0.1, 0);
23
24
vpServo
task
;
25
task
.setServo(
vpServo::EYEINHAND_CAMERA
);
26
task
.setInteractionMatrixType(
vpServo::CURRENT
);
27
task
.setLambda(0.5);
28
29
vpFeaturePoint
p
[4], pd[4];
30
for
(
unsigned
int
i = 0;
i
< 4;
i
++) {
31
point[
i
].
track
(cdMo);
32
vpFeatureBuilder::create
(pd[i], point[i]);
33
point[
i
].
track
(cMo);
34
vpFeatureBuilder::create
(p[i], point[i]);
35
task
.addFeature(p[i], pd[i]);
36
}
37
38
vpHomogeneousMatrix
wMc, wMo;
39
vpSimulatorCamera
robot;
40
robot.
setSamplingTime
(0.040);
41
robot.getPosition(wMc);
42
wMo = wMc *
cMo
;
43
44
#ifdef VISP_HAVE_DISPLAY
45
vpPlot
plotter
(2, 250 * 2, 500, 100, 200,
"Real time curves plotter"
);
46
plotter
.setTitle(0,
"Visual features error"
);
47
plotter
.setTitle(1,
"Camera velocities"
);
48
49
plotter
.initGraph(0, 8);
50
plotter
.initGraph(1, 6);
51
52
plotter
.setLegend(0, 0,
"x1"
);
53
plotter
.setLegend(0, 1,
"y1"
);
54
plotter
.setLegend(0, 2,
"x2"
);
55
plotter
.setLegend(0, 3,
"y2"
);
56
plotter
.setLegend(0, 4,
"x3"
);
57
plotter
.setLegend(0, 5,
"y3"
);
58
plotter
.setLegend(0, 6,
"x4"
);
59
plotter
.setLegend(0, 7,
"y4"
);
60
61
plotter
.setLegend(1, 0,
"v_x"
);
62
plotter
.setLegend(1, 1,
"v_y"
);
63
plotter
.setLegend(1, 2,
"v_z"
);
64
plotter
.setLegend(1, 3,
"w_x"
);
65
plotter
.setLegend(1, 4,
"w_y"
);
66
plotter
.setLegend(1, 5,
"w_z"
);
67
#endif
68
69
unsigned
int
iter
= 0;
70
while
(1) {
71
robot.getPosition(wMc);
72
cMo
= wMc.
inverse
() * wMo;
73
for
(
unsigned
int
i = 0;
i
< 4;
i
++) {
74
point[
i
].
track
(cMo);
75
vpFeatureBuilder::create
(p[i], point[i]);
76
}
77
vpColVector
v
=
task
.computeControlLaw();
78
robot.setVelocity(
vpRobot::CAMERA_FRAME
, v);
79
80
#ifdef VISP_HAVE_DISPLAY
81
plotter
.plot(0, iter,
task
.getError());
82
plotter
.plot(1, iter, v);
83
#endif
84
if
((
task
.getError()).sumSquare() < 0.0001)
85
break
;
86
87
vpTime::wait
(100);
88
89
iter
++;
90
}
91
std::cout <<
"Convergence in "
<<
iter
<<
" iterations"
<< std::endl;
92
93
#ifdef VISP_HAVE_DISPLAY
94
plotter
.saveData(0,
"error.dat"
);
95
plotter
.saveData(1,
"vc.dat"
);
96
97
vpDisplay::getClick
(
plotter
.I);
98
#endif
99
}
100
catch
(
const
vpException
&e) {
101
std::cout <<
"Catch an exception: "
<<
e
<< std::endl;
102
}
103
}
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpDisplay::getClick
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Definition
vpDisplay_uchar.cpp:894
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpFeatureBuilder::create
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Definition
vpFeatureBuilderPoint.cpp:90
vpFeaturePoint
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
Definition
vpFeaturePoint.h:190
vpForwardProjection::track
void track(const vpHomogeneousMatrix &cMo)
Definition
vpForwardProjection.cpp:101
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition
vpHomogeneousMatrix.h:221
vpHomogeneousMatrix::inverse
vpHomogeneousMatrix inverse() const
Definition
vpHomogeneousMatrix.cpp:1016
vpMath::rad
static double rad(double deg)
Definition
vpMath.h:129
vpPlot
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
Definition
vpPlot.h:117
vpPoint
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition
vpPoint.h:79
vpPoint::setWorldCoordinates
void setWorldCoordinates(double oX, double oY, double oZ)
Definition
vpPoint.cpp:116
vpRobotSimulator::setSamplingTime
virtual void setSamplingTime(const double &delta_t)
Definition
vpRobotSimulator.h:81
vpRobot::CAMERA_FRAME
@ CAMERA_FRAME
Definition
vpRobot.h:81
vpServo
Definition
vpServo.h:159
vpServo::EYEINHAND_CAMERA
@ EYEINHAND_CAMERA
Definition
vpServo.h:176
vpServo::CURRENT
@ CURRENT
Definition
vpServo.h:217
vpSimulatorCamera
Class that defines the simplest robot: a free flying camera.
Definition
vpSimulatorCamera.h:113
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
ibvs-four-points.p
p
Definition
ibvs-four-points.py:280
ibvs-four-points.iter
int iter
Definition
ibvs-four-points.py:236
ibvs-four-points.v
v
Definition
ibvs-four-points.py:271
ibvs-four-points.task
task
Definition
ibvs-four-points.py:210
ibvs-four-points.e
e
Definition
ibvs-four-points.py:272
realsense-mbt.cMo
cMo
Definition
realsense-mbt.py:212
vpTime::wait
VISP_EXPORT int wait(double t0, double t)
yolo-centering-task-afma6.i
i
Definition
yolo-centering-task-afma6.py:329
yolo-centering-task-afma6.plotter
plotter
Definition
yolo-centering-task-afma6.py:189
tutorial
visual-servo
ibvs
tutorial-ibvs-4pts-plotter.cpp
Generated by
1.17.0