Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testRobotBebop2.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Interface for the Irisa's Afma6 robot.
32
*/
33
39
40
#include <iostream>
41
42
#include <visp3/core/vpTime.h>
43
#include <visp3/gui/vpDisplayX.h>
44
#include <visp3/robot/vpRobotBebop2.h>
45
46
int
main(
int
argc,
char
**argv)
47
{
48
#ifdef ENABLE_VISP_NAMESPACE
49
using namespace
VISP_NAMESPACE_NAME
;
50
#endif
51
#ifdef VISP_HAVE_ARSDK
52
try
{
53
int
stream_res = 0;
54
std::string ip_address =
"192.168.42.1"
;
55
bool
verbose =
false
;
56
57
for
(
int
i = 1;
i
< argc;
i
++) {
58
if
(std::string(argv[i]) ==
"--ip"
&& i + 1 < argc) {
59
ip_address = std::string(argv[i + 1]);
60
i
++;
61
}
62
else
if
(std::string(argv[i]) ==
"--hd-resolution"
) {
63
stream_res = 1;
64
}
65
else
if
(std::string(argv[i]) ==
"--verbose"
|| std::string(argv[i]) ==
"-v"
) {
66
verbose =
true
;
67
}
68
else
if
(std::string(argv[i]) ==
"--help"
|| std::string(argv[i]) ==
"-h"
) {
69
std::cout <<
"\nUsage:\n"
70
<<
" "
<< argv[0] <<
" [--ip <drone ip>] [--hd-resolution] [--verbose] [-v]"
71
<<
" [--help] [-h]\n"
72
<< std::endl
73
<<
"Description:\n"
74
<<
" --ip <drone ip>\n"
75
<<
" IP address of the drone to which you want to connect (default : 192.168.42.1).\n\n"
76
<<
" --hd-resolution\n"
77
<<
" Enables HD 720p video instead of default 480p.\n\n"
78
<<
" --verbose, -v\n"
79
<<
" Enables verbose (drone information messages are then displayed).\n\n"
80
<<
" --help, -h\n"
81
<<
" Print help message.\n\n"
82
<< std::endl;
83
return
EXIT_SUCCESS;
84
}
85
else
{
86
std::cout <<
"Error : unknown parameter "
<< argv[
i
] << std::endl
87
<<
"See "
<< argv[0] <<
" --help"
<< std::endl;
88
return
EXIT_FAILURE;
89
}
90
}
91
92
vpRobotBebop2
drone(
93
verbose,
true
, ip_address);
// Create the drone with desired verbose level, settings reset, and corresponding IP
94
95
if
(drone.isRunning()) {
96
97
drone.setVideoResolution(stream_res);
// Set video resolution to 480p (default) or 720p
98
99
drone.startStreaming();
// Start video decoding and streaming
100
101
vpImage<vpRGBa>
I(1u, 1u,
vpRGBa
(0));
102
drone.getRGBaImage(I);
// Get color image from the drone video stream
103
104
#ifdef VISP_HAVE_X11
105
vpDisplayX
d
(I);
106
#elif defined(VISP_HAVE_GDI)
107
vpDisplayGDI
d
(I);
108
#elif defined(HAVE_OPENCV_HIGHGUI)
109
vpDisplayOpenCV
d
(I);
110
#else
111
std::cout <<
"No image viewer is available..."
<< std::endl;
112
#endif
113
vpDisplay::display
(I);
114
vpDisplay::flush
(I);
115
116
drone.doFlatTrim();
117
drone.takeOff(
true
);
118
119
vpColVector
vel(4, 0.0);
120
vel[3] =
vpMath::rad
(10);
121
122
double
delta_t = 0.040;
123
double
t
=
vpTime::measureTimeMs
();
124
125
do
{
// We make the drone rotate around Z axis for 10 seconds at 10 deg/s
126
drone.setVelocity(vel, 1);
127
128
drone.getRGBaImage(I);
129
vpDisplay::display
(I);
130
vpDisplay::flush
(I);
131
132
vpTime::wait
(delta_t * 1000);
133
}
while
(
vpTime::measureTimeMs
() - t < 10 * 1000);
134
135
drone.land();
136
137
}
138
else
{
139
std::cout <<
"Error : failed to setup drone control"
<< std::endl;
140
}
141
142
std::cout <<
"-- End of test --"
<< std::endl;
143
}
144
catch
(
const
vpException
&e) {
145
std::cout <<
"Caught an exception: "
<<
e
<< std::endl;
146
}
147
#else
148
(void)argc;
149
(void)argv;
150
std::cout <<
"Install Parrot ARSDK, configure and build ViSP to use this example..."
<< std::endl;
151
#endif
152
}
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpDisplayGDI
Display for windows using GDI (available on any windows 32 platform).
Definition
vpDisplayGDI.h:130
vpDisplayOpenCV
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Definition
vpDisplayOpenCV.h:139
vpDisplayX
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition
vpDisplayX.h:135
vpDisplay::display
static void display(const vpImage< unsigned char > &I)
Definition
vpDisplay_uchar.cpp:869
vpDisplay::flush
static void flush(const vpImage< unsigned char > &I)
Definition
vpDisplay_uchar.cpp:845
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpMath::rad
static double rad(double deg)
Definition
vpMath.h:129
vpRGBa
Definition
vpRGBa.h:74
vpRobotBebop2
Definition
vpRobotBebop2.h:76
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
ibvs-four-points.e
e
Definition
ibvs-four-points.py:272
pbvs-four-points.t
t
Definition
pbvs-four-points.py:220
vpTime::measureTimeMs
VISP_EXPORT double measureTimeMs()
vpTime::wait
VISP_EXPORT int wait(double t0, double t)
yolo-centering-task-afma6.d
d
Definition
yolo-centering-task-afma6.py:273
yolo-centering-task-afma6.i
i
Definition
yolo-centering-task-afma6.py:329
modules
robot
test
bebop2
testRobotBebop2.cpp
Generated by
1.17.0