Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
tutorial-ibvs-4pts-plotter-gain-adaptive.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
28
vpAdaptiveGain
lambda(4, 0.4, 30);
29
task
.setLambda(lambda);
30
31
vpFeaturePoint
p
[4], pd[4];
32
for
(
unsigned
int
i = 0;
i
< 4;
i
++) {
33
point[
i
].
track
(cdMo);
34
vpFeatureBuilder::create
(pd[i], point[i]);
35
point[
i
].
track
(cMo);
36
vpFeatureBuilder::create
(p[i], point[i]);
37
task
.addFeature(p[i], pd[i]);
38
}
39
40
vpHomogeneousMatrix
wMc, wMo;
41
vpSimulatorCamera
robot;
42
robot.
setSamplingTime
(0.040);
43
robot.getPosition(wMc);
44
wMo = wMc *
cMo
;
45
46
#ifdef VISP_HAVE_DISPLAY
47
vpPlot
plotter
(2, 250 * 2, 500, 100, 200,
"Real time curves plotter"
);
48
plotter
.setTitle(0,
"Visual features error"
);
49
plotter
.setTitle(1,
"Camera velocities"
);
50
51
plotter
.initGraph(0, 8);
52
plotter
.initGraph(1, 6);
53
54
plotter
.setLegend(0, 0,
"x1"
);
55
plotter
.setLegend(0, 1,
"y1"
);
56
plotter
.setLegend(0, 2,
"x2"
);
57
plotter
.setLegend(0, 3,
"y2"
);
58
plotter
.setLegend(0, 4,
"x3"
);
59
plotter
.setLegend(0, 5,
"y3"
);
60
plotter
.setLegend(0, 6,
"x4"
);
61
plotter
.setLegend(0, 7,
"y4"
);
62
63
plotter
.setLegend(1, 0,
"v_x"
);
64
plotter
.setLegend(1, 1,
"v_y"
);
65
plotter
.setLegend(1, 2,
"v_z"
);
66
plotter
.setLegend(1, 3,
"w_x"
);
67
plotter
.setLegend(1, 4,
"w_y"
);
68
plotter
.setLegend(1, 5,
"w_z"
);
69
#endif
70
71
unsigned
int
iter
= 0;
72
while
(1) {
73
robot.getPosition(wMc);
74
cMo
= wMc.
inverse
() * wMo;
75
for
(
unsigned
int
i = 0;
i
< 4;
i
++) {
76
point[
i
].
track
(cMo);
77
vpFeatureBuilder::create
(p[i], point[i]);
78
}
79
vpColVector
v
=
task
.computeControlLaw();
80
robot.setVelocity(
vpRobot::CAMERA_FRAME
, v);
81
82
#ifdef VISP_HAVE_DISPLAY
83
plotter
.plot(0, iter,
task
.getError());
84
plotter
.plot(1, iter, v);
85
#endif
86
if
((
task
.getError()).sumSquare() < 0.0001)
87
break
;
88
89
vpTime::wait
(100);
90
91
iter
++;
92
}
93
std::cout <<
"Convergence in "
<<
iter
<<
" iterations"
<< std::endl;
94
95
#ifdef VISP_HAVE_DISPLAY
96
plotter
.saveData(0,
"error.dat"
);
97
plotter
.saveData(1,
"vc.dat"
);
98
99
vpDisplay::getClick
(
plotter
.I);
100
#endif
101
}
102
catch
(
const
vpException
&e) {
103
std::cout <<
"Catch an exception: "
<<
e
<< std::endl;
104
}
105
}
vpAdaptiveGain
Adaptive gain computation.
Definition
vpAdaptiveGain.h:122
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-gain-adaptive.cpp
Generated by
1.17.0