Coverage Control Library
Loading...
Searching...
No Matches
plotter.h
Go to the documentation of this file.
1/*
2 * This file is part of the CoverageControl library
3 *
4 * Author: Saurav Agarwal
5 * Contact: sauravag@seas.upenn.edu, agr.saurav1@gmail.com
6 * Repository: https://github.com/KumarRobotics/CoverageControl
7 *
8 * Copyright (c) 2024, Saurav Agarwal
9 *
10 * The CoverageControl library is free software: you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or (at your
13 * option) any later version.
14 *
15 * The CoverageControl library is distributed in the hope that it will be
16 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18 * Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * CoverageControl library. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30#ifndef CPPSRC_CORE_INCLUDE_COVERAGECONTROL_PLOTTER_H_
31#define CPPSRC_CORE_INCLUDE_COVERAGECONTROL_PLOTTER_H_
32
33#include <iomanip>
34#include <list>
35#include <string>
36#include <vector>
37
40
41namespace gnuplotio {
42class Gnuplot;
43}
44using namespace gnuplotio;
45
46namespace CoverageControl {
47
52 std::vector<std::list<Point2>> positions_history;
53 std::vector<int> robot_status;
54 std::vector<std::list<Point2>> voronoi;
56};
57
59class Plotter {
60 std::string dir = "data/test/";
61 std::string plot_name = "map.png";
62 int marker_sz = 2;
63 int half_marker_sz = 1;
64 int image_sz = 1024;
65 int font_sz = 14;
66 double scale = 1;
67 bool unset_colorbox = true;
68
69 int range_max = 1024;
70 double resolution = 1;
71
72 std::string color_robot = "#002d7d";
73 std::string color_robot_alt = "#196f3d";
74 /* std::string color_idf = "#900C3F"; */
75 std::string color_idf = "#900C3F";
76 std::string color_voronoi = "#196f3d";
77 std::string color_unknown = "#aeb6bf";
78 std::string color_communication_links = "#1f77b4";
79
80 bool GnuplotCommands(Gnuplot &gp);
81 void StreamMap(Gnuplot &gp, MapType const &map);
82 void PlotMap(Gnuplot &gp, bool begin = true);
83 void PlotLine(Gnuplot &gp, int marker_sz, std::string color,
84 bool begin = false);
85 void PlotPoints(Gnuplot &gp, int point_type, int marker_sz, std::string color,
86 bool begin = false);
87
88 public:
89 Plotter(std::string const &d, int const &r_max, double const &res) {
90 SetDir(d);
91 range_max = r_max;
92 resolution = res;
93 }
94
95 inline void SetDir(std::string const &d) { dir = d; }
96
97 inline void SetScale(double const &sc) {
98 scale = sc;
99 marker_sz = static_cast<int>(2 * scale);
100 half_marker_sz = static_cast<int>(1 * scale);
101 image_sz = static_cast<int>(1024 * scale);
102 font_sz = static_cast<int>(14 * scale);
103 }
104
105 void SetPlotName(std::string const &name) { plot_name = name + ".png"; }
106
107 void SetPlotName(std::string const &name, int const &i) {
108 std::stringstream ss;
109 ss << std::setw(4) << std::setfill('0') << i;
110 plot_name = name + ss.str() + ".png";
111 }
112
113 /* void PlotMap(MapType const &); */
114 /* void PlotMap(MapType const &, PointVector const &); */
115 /* void PlotMap(MapType const &, PointVector const &); */
116 /* void PlotMap(MapType const &, PointVector const &, std::vector
117 * <std::list<Point2>> const &, std::vector <int> const &); */
118 /* void PlotMap(MapType const &, PointVector const &, PointVector const &,
119 * Voronoi const &); */
120 /* void PlotMap(MapType const &, PointVector const &, PointVector const &); */
121
122 void PlotMap(MapType const &map);
123
124 void PlotMap(MapType const &map, PointVector const &positions);
125
126 void PlotMap(MapType const &map, PointVector const &positions,
127 std::vector<std::list<Point2>> const &trajectories,
128 std::vector<int> const &robot_status);
129 void PlotMap(MapType const &map, PointVector const &positions,
130 std::vector<std::list<Point2>> const &trajectories,
131 std::vector<int> const &robot_status,
132 double const &communication_range);
133
134 void PlotMap(MapType const &map, PointVector const &positions,
135 std::vector<std::list<Point2>> const &voronoi,
136 std::vector<std::list<Point2>> const &trajectories);
137 void PlotMap(MapType const &map, PointVector const &positions,
138 Voronoi const &voronoi,
139 std::vector<std::list<Point2>> const &trajectories);
140 void PlotMap(MapType const &map, PointVector const &positions,
141 PointVector const &goals, Voronoi const &voronoi);
142
143 void PlotMap(MapType const &map, PointVector const &positions,
144 std::vector<std::list<Point2>> const &trajectories,
145 PointVector const &frontiers);
146};
147
148} // namespace CoverageControl
149
150#endif // CPPSRC_CORE_INCLUDE_COVERAGECONTROL_PLOTTER_H_
Class to plot the map.
Definition plotter.h:59
void SetPlotName(std::string const &name)
Definition plotter.h:105
void SetPlotName(std::string const &name, int const &i)
Definition plotter.h:107
Plotter(std::string const &d, int const &r_max, double const &res)
Definition plotter.h:89
void SetDir(std::string const &d)
Definition plotter.h:95
void SetScale(double const &sc)
Definition plotter.h:97
Class for computing Voronoi cells.
Definition voronoi.h:116
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MapType
Definition typedefs.h:48
std::vector< Point2 > PointVector
Definition typedefs.h:51
Namespace for the CoverageControl library.
Data structure to store plotter data.
Definition plotter.h:49
std::vector< std::list< Point2 > > voronoi
Definition plotter.h:54
std::vector< std::list< Point2 > > positions_history
Definition plotter.h:52
std::vector< int > robot_status
Definition plotter.h:53
Contains typedefs for the library.
Class for computing Voronoi cells.