Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
qp_plot.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 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 * Example of sequential calls to QP solver
32 */
38
39#include <visp3/core/vpConfig.h>
40#include <visp3/core/vpTime.h>
41#include <visp3/gui/vpPlot.h>
42
43#ifndef DOXYGEN_SHOULD_SKIP_THIS
44VISP_NAMESPACE_ADDRESSING vpMatrix randM(int n, int m)
45{
46 VISP_NAMESPACE_ADDRESSING vpMatrix M(n, m);
47 for (int i = 0; i < n; ++i)
48 for (int j = 0; j < m; ++j)
49 M[i][j] = (2. * rand()) / RAND_MAX - 1;
50 return M;
51}
52
53VISP_NAMESPACE_ADDRESSING vpColVector randV(int n)
54{
55 VISP_NAMESPACE_ADDRESSING vpColVector M(n);
56 for (int i = 0; i < n; ++i)
57 M[i] = (2. * rand()) / RAND_MAX - 1;
58 return M;
59}
60
61#ifdef VISP_HAVE_DISPLAY
62class QPlot
63{
64public:
65 virtual ~QPlot() { delete P; }
66 QPlot(int graphNum, int total, std::vector<std::string> legend)
67 {
68 P = new VISP_NAMESPACE_ADDRESSING vpPlot(graphNum, 700, 700, 100, 200, "Resolution time");
69
70 for (int i = 0; i < graphNum; ++i) {
71 P->initGraph(i, 2);
72 P->setColor(i, 0, VISP_NAMESPACE_ADDRESSING vpColor::red);
73 P->setColor(i, 1, VISP_NAMESPACE_ADDRESSING vpColor::blue);
74 P->setGraphThickness(i, 2);
75 P->initRange(i, 0, total, 0, 0.1);
76 P->setUnitY(i, "ms");
77 P->setTitle(i, legend[2 * i]);
78 P->setLegend(i, 0, "without " + legend[2 * i + 1]);
79 P->setLegend(i, 1, legend[2 * i + 1]);
80 }
81 }
82
83 void plot(int g, int c, int i, double t) { P->plot(g, c, i, VISP_NAMESPACE_ADDRESSING vpTime::measureTimeMs() - t); }
84
85 void wait() { P->I.display->getClick(); }
86 VISP_NAMESPACE_ADDRESSING vpPlot *P;
87
88private:
89 // Copy constructor not allowed.
90 QPlot(const QPlot &qplot);
91};
92#else
93class VISP_EXPORT QPPlot
94{
95public:
96 QPPlot(int, int, std::vector<std::string>) { }
97 void plot(int, int, int, double) { }
98 void wait() { }
99};
100#endif
101#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
Implementation of column vector and the associated operations.
static const vpColor red
Definition vpColor.h:198
static const vpColor blue
Definition vpColor.h:204
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
VISP_EXPORT double measureTimeMs()
VISP_EXPORT int wait(double t0, double t)