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 <filesystem>
34#include <iostream>
35#include <list>
36#include <string>
37#include <vector>
38
41
42class Gnuplot;
43namespace CoverageControl {
44
47 MapType map;
48 PointVector positions;
49 std::vector<std::list<Point2>> positions_history;
50 std::vector<int> robot_status;
51 std::vector<std::list<Point2>> voronoi;
52};
53
55class Plotter {
56 std::string dir = "data/test/";
57 std::string plot_name = "map.png";
58 int marker_sz = 2;
59 int half_marker_sz = 1;
60 int image_sz = 1024;
61 int font_sz = 14;
62 double scale = 1;
63 bool unset_colorbox = true;
64
65 int range_max = 1024;
66 double resolution = 1;
67
68 std::string color_robot = "#002d7d";
69 std::string color_robot_alt = "#196f3d";
70 /* std::string color_idf = "#900C3F"; */
71 std::string color_idf = "#900C3F";
72 std::string color_voronoi = "#196f3d";
73 std::string color_unknown = "#aeb6bf";
74 std::string color_communication_links = "#1f77b4";
75
76 public:
77 Plotter(std::string const &d, int const &r_max, double const &res) {
78 SetDir(d);
79 range_max = r_max;
80 resolution = res;
81 }
82
83 inline void SetDir(std::string const &d) { dir = d; }
84
85 inline void SetScale(double const &sc) {
86 scale = sc;
87 marker_sz = static_cast<int>(2 * scale);
88 half_marker_sz = static_cast<int>(1 * scale);
89 image_sz = static_cast<int>(1024 * scale);
90 font_sz = static_cast<int>(14 * scale);
91 }
92
93 void SetPlotName(std::string const &name) { plot_name = name + ".png"; }
94
95 void SetPlotName(std::string const &name, int const &i) {
96 std::stringstream ss;
97 ss << std::setw(4) << std::setfill('0') << i;
98 plot_name = name + ss.str() + ".png";
99 }
100
101 /* void PlotMap(MapType const &); */
102 /* void PlotMap(MapType const &, PointVector const &); */
103 /* void PlotMap(MapType const &, PointVector const &); */
104 /* void PlotMap(MapType const &, PointVector const &, std::vector
105 * <std::list<Point2>> const &, std::vector <int> const &); */
106 /* void PlotMap(MapType const &, PointVector const &, PointVector const &,
107 * Voronoi const &); */
108 /* void PlotMap(MapType const &, PointVector const &, PointVector const &); */
109
110 bool GnuplotCommands(Gnuplot &gp);
111 void StreamMap(Gnuplot &gp, MapType const &map);
112 void PlotMap(Gnuplot &gp, bool begin = true);
113 void PlotLine(Gnuplot &gp, int marker_sz, std::string color,
114 bool begin = false);
115 void PlotPoints(Gnuplot &gp, int point_type, int marker_sz, std::string color,
116 bool begin = false);
117
118 void PlotMap(MapType const &map);
119
120 void PlotMap(MapType const &map, PointVector const &positions);
121
122 void PlotMap(MapType const &map, PointVector const &positions,
123 std::vector<std::list<Point2>> const &trajectories,
124 std::vector<int> const &robot_status);
125 void PlotMap(MapType const &map, PointVector const &positions,
126 std::vector<std::list<Point2>> const &trajectories,
127 std::vector<int> const &robot_status,
128 double const &communication_range);
129
130 void PlotMap(MapType const &map, PointVector const &positions,
131 std::vector<std::list<Point2>> const &voronoi,
132 std::vector<std::list<Point2>> const &trajectories);
133 void PlotMap(MapType const &map, PointVector const &positions,
134 Voronoi const &voronoi,
135 std::vector<std::list<Point2>> const &trajectories);
136 void PlotMap(MapType const &map, PointVector const &positions,
137 PointVector const &goals, Voronoi const &voronoi);
138
139 void PlotMap(MapType const &map, PointVector const &positions,
140 std::vector<std::list<Point2>> const &trajectories,
141 PointVector const &frontiers);
142};
143
144} // namespace CoverageControl
145
146#endif // CPPSRC_CORE_INCLUDE_COVERAGECONTROL_PLOTTER_H_
Class to plot the map.
Definition plotter.h:55
Class for computing Voronoi cells.
Definition voronoi.h:119
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:46
Contains typedefs for the library.
Class for computing Voronoi cells.