Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
qp_plot.h
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See https://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * Example of sequential calls to QP solver
33 *
34*****************************************************************************/
41#include <visp3/core/vpConfig.h>
42#include <visp3/core/vpTime.h>
43#include <visp3/gui/vpPlot.h>
44
45#ifndef DOXYGEN_SHOULD_SKIP_THIS
46vpMatrix randM(int n, int m)
47{
48 vpMatrix M(n, m);
49 for (int i = 0; i < n; ++i)
50 for (int j = 0; j < m; ++j)
51 M[i][j] = (2. * rand()) / RAND_MAX - 1;
52 return M;
53}
54
55vpColVector randV(int n)
56{
57 vpColVector M(n);
58 for (int i = 0; i < n; ++i)
59 M[i] = (2. * rand()) / RAND_MAX - 1;
60 return M;
61}
62
63#ifdef VISP_HAVE_DISPLAY
64class QPlot
65{
66public:
67 virtual ~QPlot() { delete P; }
68 QPlot(int graphNum, int total, std::vector<std::string> legend)
69 {
70 P = new vpPlot(graphNum, 700, 700, 100, 200, "Resolution time");
71
72 for (int i = 0; i < graphNum; ++i) {
73 P->initGraph(i, 2);
74 P->setColor(i, 0, vpColor::red);
75 P->setColor(i, 1, vpColor::blue);
76 P->setGraphThickness(i, 2);
77 P->initRange(i, 0, total, 0, 0.1);
78 P->setUnitY(i, "ms");
79 P->setTitle(i, legend[2 * i]);
80 P->setLegend(i, 0, "without " + legend[2 * i + 1]);
81 P->setLegend(i, 1, legend[2 * i + 1]);
82 }
83 }
84
85 void plot(int g, int c, int i, double t) { P->plot(g, c, i, vpTime::measureTimeMs() - t); }
86
87 void wait() { P->I.display->getClick(); }
88 vpPlot *P;
89
90private:
91 // Copy constructor not allowed.
92 QPlot(const QPlot &qplot);
93};
94#else
95class VISP_EXPORT QPPlot
96{
97public:
98 QPPlot(int, int, std::vector<std::string>) { }
99 void plot(int, int, int, double) { }
100 void wait() { }
101};
102#endif
103#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
Implementation of column vector and the associated operations.
static const vpColor red
Definition vpColor.h:211
static const vpColor blue
Definition vpColor.h:217
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:152
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
Definition vpPlot.h:113
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeMs()