Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
tutorial-ibvs-4pts.cpp
1
2
#include <visp3/core/vpConfig.h>
3
#include <visp3/robot/vpSimulatorCamera.h>
4
#include <visp3/visual_features/vpFeatureBuilder.h>
5
#include <visp3/vs/vpServo.h>
6
7
int
main()
8
{
9
#ifdef ENABLE_VISP_NAMESPACE
10
using namespace
VISP_NAMESPACE_NAME
;
11
#endif
12
13
try
{
14
vpHomogeneousMatrix
cdMo(0, 0, 0.75, 0, 0, 0);
15
vpHomogeneousMatrix
cMo
(0.15, -0.1, 1.,
vpMath::rad
(10),
vpMath::rad
(-10),
vpMath::rad
(50));
16
17
vpPoint
point[4];
18
point[0].
setWorldCoordinates
(-0.1, -0.1, 0);
19
point[1].
setWorldCoordinates
(0.1, -0.1, 0);
20
point[2].
setWorldCoordinates
(0.1, 0.1, 0);
21
point[3].
setWorldCoordinates
(-0.1, 0.1, 0);
22
23
vpServo
task
;
24
task
.setServo(
vpServo::EYEINHAND_CAMERA
);
25
task
.setInteractionMatrixType(
vpServo::CURRENT
);
26
task
.setLambda(0.5);
27
28
vpFeaturePoint
p
[4], pd[4];
29
for
(
unsigned
int
i = 0;
i
< 4;
i
++) {
30
point[
i
].
track
(cdMo);
31
vpFeatureBuilder::create
(pd[i], point[i]);
32
point[
i
].
track
(cMo);
33
vpFeatureBuilder::create
(p[i], point[i]);
34
task
.addFeature(p[i], pd[i]);
35
}
36
37
vpHomogeneousMatrix
wMc, wMo;
38
vpSimulatorCamera
robot;
39
robot.
setSamplingTime
(0.040);
40
robot.getPosition(wMc);
41
wMo = wMc *
cMo
;
42
43
std::cout <<
"Start visual-servoing loop..."
<< std::endl;
44
for
(
unsigned
int
iter = 0;
iter
< 150;
iter
++) {
45
robot.getPosition(wMc);
46
cMo
= wMc.
inverse
() * wMo;
47
for
(
unsigned
int
i = 0;
i
< 4;
i
++) {
48
point[
i
].
track
(cMo);
49
vpFeatureBuilder::create
(p[i], point[i]);
50
}
51
vpColVector
v
=
task
.computeControlLaw();
52
robot.setVelocity(
vpRobot::CAMERA_FRAME
, v);
53
}
54
55
std::cout <<
"Stop visual-servoing loop"
<< std::endl;
56
}
57
catch
(
const
vpException
&e) {
58
std::cout <<
"Catch an exception: "
<<
e
<< std::endl;
59
}
60
}
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
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
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
yolo-centering-task-afma6.i
i
Definition
yolo-centering-task-afma6.py:329
tutorial
visual-servo
ibvs
tutorial-ibvs-4pts.cpp
Generated by
1.17.0