basic_palettes.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2020, Locus Robotics
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 
38 #include <color_util/convert.h>
40 #include <string>
41 #include <vector>
42 
43 namespace robot_nav_rviz_plugins
44 {
46 
51 class MapPalette : public NavGridPalette
52 {
53 public:
54  std::string getName() const override { return "map"; }
55  bool hasTransparency() const override { return false; }
56  std::vector<ColorRGBA24> getColors() const override
57  {
58  std::vector<ColorRGBA24> colors(NUM_COLORS);
59  // Standard gray map palette values
60  for (int i = 0; i <= 100; i++)
61  {
62  unsigned char v = 255 - (255 * i) / 100;
63  colors[i] = ColorRGBA24(v, v, v);
64  }
65  // illegal positive values in green
66  for (int i = 101; i <= 127; i++)
67  {
68  colors[i] = ColorRGBA24(0, 255, 0);
69  }
70  // illegal negative (char) values in shades of red/yellow
71  for (int i = 128; i <= 254; i++)
72  {
73  colors[i] = ColorRGBA24(255, (255 * (i - 128)) / (254 - 128), 0);
74  }
75 
76  // legal 255 value is tasteful blueish greenish grayish color
77  colors[255] = ColorRGBA24(0x70, 0x89, 0x86);
78 
79  return colors;
80  }
81 };
87 {
88 public:
89  std::string getName() const override { return "costmap"; }
90  bool hasTransparency() const override { return true; }
91  std::vector<ColorRGBA24> getColors() const override
92  {
93  std::vector<ColorRGBA24> colors(NUM_COLORS);
94 
95  // zero values have alpha=0
96  colors[0] = ColorRGBA24(0, 0, 0, 0);
97 
98  // Blue to red spectrum for most normal cost values
99  for (int i = 1; i <= 98; i++)
100  {
101  unsigned char v = (255 * i) / 100;
102  colors[i] = ColorRGBA24(v, 0, 255 - v);
103  }
104 
105  // inscribed obstacle values (99) in cyan
106  colors[99] = ColorRGBA24(0, 255, 255);
107 
108  // lethal obstacle values (100) in purple
109  colors[100] = ColorRGBA24(255, 0, 255);
110 
111  // illegal positive values in green
112  for (int i = 101; i <= 127; i++)
113  {
114  colors[i] = ColorRGBA24(0, 255, 0);
115  }
116 
117  // illegal negative (char) values in shades of red/yellow
118  for (int i = 128; i <= 254; i++)
119  {
120  colors[i] = ColorRGBA24(255, (255 * (i - 128)) / (254 - 128), 0);
121  }
122 
123  // legal 255 value is tasteful blueish greenish grayish color
124  colors[255] = ColorRGBA24(0x70, 0x89, 0x86);
125 
126  return colors;
127  }
128 };
129 
135 {
136 public:
137  std::string getName() const override { return "raw"; }
138  bool hasTransparency() const override { return false; }
139  std::vector<ColorRGBA24> getColors() const override
140  {
141  std::vector<ColorRGBA24> colors(NUM_COLORS);
142  for (unsigned int i = 0; i < NUM_COLORS; i++)
143  {
144  colors[i] = ColorRGBA24(i, i, i);
145  }
146  return colors;
147  }
148 };
149 
154 {
155 public:
156  std::string getName() const override { return "rainbow"; }
157  bool hasTransparency() const override { return true; }
158  std::vector<ColorRGBA24> getColors() const override
159  {
160  std::vector<ColorRGBA24> colors(NUM_COLORS);
161  colors[0] = ColorRGBA24(0, 0, 0, 0);
162  for (unsigned int i = 1; i < NUM_COLORS; i++)
163  {
164  double fraction = static_cast<double>(255 - i) / 254;
165  // multiplying by 0.75 scales it to purple to red
166  color_util::ColorHSVA color(fraction * 0.75, 1.0, 1.0, 1.0);
168  }
169  return colors;
170  }
171 };
172 
177 {
178 public:
179  std::string getName() const override { return "rainbow2"; }
180  bool hasTransparency() const override { return true; }
181  std::vector<ColorRGBA24> getColors() const override
182  {
183  std::vector<ColorRGBA24> colors(NUM_COLORS);
184  colors[0] = ColorRGBA24(0, 0, 0, 0);
185  for (unsigned int i = 1; i < NUM_COLORS; i++)
186  {
187  double fraction = static_cast<double>(i - 1) / 254;
188  // multiplying by 0.75 scales it to red to purple
189  color_util::ColorHSVA color(fraction * 0.75, 1.0, 1.0, 1.0);
191  }
192  return colors;
193  }
194 };
195 
200 {
201 public:
202  // Blend from black to blue
204  : SpectrumPalette(color_util::ColorRGBA24(0, 0, 0), color_util::ColorRGBA24(0, 0, 255), true) {}
205  std::string getName() const override { return "blues"; }
206 };
207 
212 {
213 public:
214  std::string getName() const override { return "distinct"; }
215  bool hasTransparency() const override { return true; }
216 
217  std::vector<ColorRGBA24> getColors() const override
218  {
220  }
221 };
222 
223 
224 } // namespace robot_nav_rviz_plugins
225 
Same as rviz::MapDisplay map palette. See https://github.com/ros-visualization/rviz/blob/4b6c0f447159...
bool hasTransparency() const override
See if the palette has any transparent colors.
std::string getName() const override
Unique descriptive name for this particular palette.
color_util::ColorHSVA changeColorspace(const color_util::ColorRGBA &rgba)
std::string getName() const override
Unique descriptive name for this particular palette.
bool hasTransparency() const override
See if the palette has any transparent colors.
Palette with a gradient of blues from dark to light.
std::vector< ColorRGBA24 > getColors() const override
The actual definition of the colors.
std::vector< ColorRGBA24 > getColors() const override
The actual definition of the colors.
Same as rviz::MapDisplay raw palette. See https://github.com/ros-visualization/rviz/blob/4b6c0f447159...
bool hasTransparency() const override
See if the palette has any transparent colors.
std::vector< ColorRGBA24 > getColors() const override
The actual definition of the colors.
bool hasTransparency() const override
See if the palette has any transparent colors.
std::string getName() const override
Unique descriptive name for this particular palette.
static const unsigned int NUM_COLORS
std::vector< ColorRGBA24 > getColors() const override
The actual definition of the colors.
Easy class to generate palettes that simply blend two colors together.
const std::vector< ColorRGBA24 > & getNamedColors()
bool hasTransparency() const override
See if the palette has any transparent colors.
std::string getName() const override
Unique descriptive name for this particular palette.
std::string getName() const override
Unique descriptive name for this particular palette.
Same as rviz::MapDisplay costmap palette. See https://github.com/ros-visualization/rviz/blob/4b6c0f44...
bool hasTransparency() const override
See if the palette has any transparent colors.
Several reusable pieces for displaying polygons.
Rainbow hued palette from red to purple with transparent 0.
std::string getName() const override
Unique descriptive name for this particular palette.
std::vector< ColorRGBA24 > getColors() const override
The actual definition of the colors.
Rainbow hued palette from purple to red with transparent 0.
List of distinct colors for displaying individual categories.
std::string getName() const override
Unique descriptive name for this particular palette.
color_util::ColorRGBA24 toInt(const color_util::ColorRGBA &float_color)
std::vector< ColorRGBA24 > getColors() const override
The actual definition of the colors.
A simple datastructure representing a palette of up to 256 24-bit colors.
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)


robot_nav_rviz_plugins
Author(s):
autogenerated on Sun Jan 10 2021 04:08:58