bounding_box_array_display.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Ryohei Ueda and JSK Lab
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 JSK Lab 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 OWNER 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 
37 #include <jsk_topic_tools/color_utils.h>
38 
39 namespace jsk_rviz_plugins
40 {
41 
43  {
45  "coloring", "Auto",
46  "coloring method",
47  this, SLOT(updateColoring()));
48  coloring_property_->addOption("Flat color", 1);
49  coloring_property_->addOption("Label", 2);
50  coloring_property_->addOption("Value", 3);
51 
53  "alpha method", "flat", "alpha method",
54  this, SLOT(updateAlphaMethod()));
56  alpha_method_property_->addOption("value", 1);
57 
59  "color", QColor(25, 255, 0),
60  "color to draw the bounding boxes",
61  this, SLOT(updateColor()));
63  "alpha", 0.8,
64  "alpha value to draw the bounding boxes",
65  this, SLOT(updateAlpha()));
67  "alpha min", 0.0,
68  "alpha value corresponding to value = 0",
69  this, SLOT(updateAlphaMin()));
71  "alpha max", 1.0,
72  "alpha value corresponding to value = 1",
73  this, SLOT(updateAlphaMax()));
75  "only edge", false,
76  "show only the edges of the boxes",
77  this, SLOT(updateOnlyEdge()));
79  "line width", 0.005,
80  "line width of the edges",
81  this, SLOT(updateLineWidth()));
83  "show coords", false,
84  "show coordinate of bounding box",
85  this, SLOT(updateShowCoords()));
87  "value threshold", 0.0,
88  "filter all boxes with value < threshold",
89  this, SLOT(updateValueThreshold()));
90  }
91 
93  {
94  delete color_property_;
95  delete alpha_property_;
96  delete alpha_min_property_;
97  delete alpha_max_property_;
98  delete only_edge_property_;
99  delete coloring_property_;
100  delete alpha_method_property_;
101  delete show_coords_property_;
103  }
104 
106  {
108  scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();
109 
110  updateColor();
111  updateAlpha();
112  updateAlphaMin();
113  updateAlphaMax();
114  updateOnlyEdge();
115  updateColoring();
117  updateLineWidth();
120  }
121 
123  {
125  if (latest_msg_) {
127  }
128  }
129 
131  {
133  if (latest_msg_) {
135  }
136  }
137 
139  {
141  if (latest_msg_) {
143  }
144  }
145 
147  {
149  {
150  ROS_WARN("alpha_min must be <= alpha_max");
152  return;
153  }
155  if (latest_msg_) {
157  }
158  }
159 
161  {
163  {
164  ROS_WARN("alpha_min must be <= alpha_max");
166  return;
167  }
169  if (latest_msg_) {
171  }
172  }
173 
175  {
177  if (only_edge_) {
179  }
180  else {
182  }
183  // Imediately apply attribute
184  if (latest_msg_) {
185  if (only_edge_) {
187  }
188  else {
190  }
191  }
192  }
193 
195  {
196  if (coloring_property_->getOptionInt() == 0) {
197  coloring_method_ = "auto";
199  }
200  else if (coloring_property_->getOptionInt() == 1) {
201  coloring_method_ = "flat";
203  }
204  else if (coloring_property_->getOptionInt() == 2) {
205  coloring_method_ = "label";
207  }
208  else if (coloring_property_->getOptionInt() == 3) {
209  coloring_method_ = "value";
211  }
212 
213  if (latest_msg_) {
215  }
216  }
217 
219  {
220  if (alpha_method_property_->getOptionInt() == 0) {
221  alpha_method_ = "flat";
225  }
227  alpha_method_ = "value";
231  }
232 
233  if (latest_msg_) {
235  }
236  }
237 
239  {
241  // Immediately apply show_coords attribute
242  if (!show_coords_) {
243  hideCoords();
244  }
245  else if (show_coords_ && latest_msg_) {
247  }
248  }
249 
251  {
252  MFDClass::reset();
253  shapes_.clear();
254  edges_.clear();
255  coords_nodes_.clear();
256  coords_objects_.clear();
257  latest_msg_.reset();
258  }
259 
261  const jsk_recognition_msgs::BoundingBoxArray::ConstPtr& msg)
262  {
263  // Store latest message
264  latest_msg_ = msg;
265 
266  if (!only_edge_) {
267  showBoxes(msg);
268  }
269  else {
270  showEdges(msg);
271  }
272 
273  if (show_coords_) {
274  showCoords(msg);
275  }
276  else {
277  hideCoords();
278  }
279  }
280 
282  {
284  {
285  ROS_WARN("value threshold must be in [0,1]");
287  return;
288  }
290  if (latest_msg_) {
292  }
293  }
294 
295 } // namespace jsk_rviz_plugins
296 
rviz::BoolProperty::getBool
virtual bool getBool() const
jsk_rviz_plugins::BoundingBoxArrayDisplay::BoundingBoxArrayDisplay
BoundingBoxArrayDisplay()
Definition: bounding_box_array_display.cpp:74
rviz::EnumProperty::getOptionInt
virtual int getOptionInt()
jsk_rviz_plugins::BoundingBoxArrayDisplay::latest_msg_
jsk_recognition_msgs::BoundingBoxArray::ConstPtr latest_msg_
Definition: bounding_box_array_display.h:144
rviz::ColorProperty::getColor
virtual QColor getColor() const
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::alpha_method_
std::string alpha_method_
Definition: bounding_box_display_common.h:143
rviz::MessageFilterDisplay< MessageType >::reset
void reset() override
msg
msg
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::showCoords
void showCoords(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
Definition: bounding_box_display_common.h:443
jsk_rviz_plugins::BoundingBoxArrayDisplay::value_threshold_property_
rviz::FloatProperty * value_threshold_property_
Definition: bounding_box_array_display.h:142
rviz::Property::show
void show()
jsk_rviz_plugins::BoundingBoxArrayDisplay::show_coords_
bool show_coords_
Definition: bounding_box_array_display.h:131
bounding_box_array_display.h
jsk_rviz_plugins::BoundingBoxArrayDisplay::line_width_property_
rviz::FloatProperty * line_width_property_
Definition: bounding_box_array_display.h:140
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateAlphaMin
void updateAlphaMin()
Definition: bounding_box_array_display.cpp:178
rviz::BoolProperty
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::coords_objects_
std::vector< std::vector< ArrowPtr > > coords_objects_
Definition: bounding_box_display_common.h:147
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateColor
void updateColor()
Definition: bounding_box_array_display.cpp:162
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateLineWidth
void updateLineWidth()
Definition: bounding_box_array_display.cpp:154
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateAlphaMax
void updateAlphaMax()
Definition: bounding_box_array_display.cpp:192
jsk_rviz_plugins::BoundingBoxArrayDisplay::processMessage
void processMessage(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
Definition: bounding_box_array_display.cpp:292
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::coords_nodes_
std::vector< Ogre::SceneNode * > coords_nodes_
Definition: bounding_box_display_common.h:148
rviz::ColorProperty
rviz::Display
rviz::EnumProperty
rviz::FloatProperty
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateColoring
void updateColoring()
Definition: bounding_box_array_display.cpp:226
class_list_macros.h
rviz::Property::hide
void hide()
jsk_rviz_plugins::BoundingBoxArrayDisplay::only_edge_
bool only_edge_
Definition: bounding_box_array_display.h:130
jsk_rviz_plugins::BoundingBoxArrayDisplay::alpha_property_
rviz::FloatProperty * alpha_property_
Definition: bounding_box_array_display.h:136
jsk_rviz_plugins::BoundingBoxArrayDisplay::~BoundingBoxArrayDisplay
virtual ~BoundingBoxArrayDisplay()
Definition: bounding_box_array_display.cpp:124
jsk_rviz_plugins::BoundingBoxArrayDisplay::coloring_property_
rviz::EnumProperty * coloring_property_
Definition: bounding_box_array_display.h:133
rviz::FloatProperty::getFloat
virtual float getFloat() const
rviz::EnumProperty::addOption
virtual void addOption(const QString &option, int value=0)
bounding_box_display_common.h
jsk_rviz_plugins::BoundingBoxArrayDisplay::alpha_max_property_
rviz::FloatProperty * alpha_max_property_
Definition: bounding_box_array_display.h:138
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::showEdges
void showEdges(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
Definition: bounding_box_display_common.h:341
rviz::Display::scene_node_
Ogre::SceneNode * scene_node_
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::alpha_max_
double alpha_max_
Definition: bounding_box_display_common.h:142
jsk_rviz_plugins::BoundingBoxArrayDisplay::show_coords_property_
rviz::BoolProperty * show_coords_property_
Definition: bounding_box_array_display.h:141
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateAlphaMethod
void updateAlphaMethod()
Definition: bounding_box_array_display.cpp:250
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::edges_
std::vector< BillboardLinePtr > edges_
Definition: bounding_box_display_common.h:149
rviz::Display::scene_manager_
Ogre::SceneManager * scene_manager_
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::alpha_
double alpha_
Definition: bounding_box_display_common.h:140
ROS_WARN
#define ROS_WARN(...)
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::hideCoords
void hideCoords()
Definition: bounding_box_display_common.h:525
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::showBoxes
void showBoxes(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
Definition: bounding_box_display_common.h:274
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateOnlyEdge
void updateOnlyEdge()
Definition: bounding_box_array_display.cpp:206
jsk_rviz_plugins::BoundingBoxArrayDisplay::only_edge_property_
rviz::BoolProperty * only_edge_property_
Definition: bounding_box_array_display.h:139
rviz::MessageFilterDisplay< MessageType >::onInitialize
void onInitialize() override
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::line_width_
double line_width_
Definition: bounding_box_display_common.h:144
PLUGINLIB_EXPORT_CLASS
PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::PictogramArrayDisplay, rviz::Display)
jsk_rviz_plugins::BoundingBoxArrayDisplay::color_property_
rviz::ColorProperty * color_property_
Definition: bounding_box_array_display.h:134
jsk_rviz_plugins::BoundingBoxArrayDisplay::alpha_min_property_
rviz::FloatProperty * alpha_min_property_
Definition: bounding_box_array_display.h:137
rviz::FloatProperty::setFloat
bool setFloat(float new_value)
jsk_rviz_plugins::BoundingBoxArrayDisplay::reset
virtual void reset()
Definition: bounding_box_array_display.cpp:282
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateValueThreshold
void updateValueThreshold()
Definition: bounding_box_array_display.cpp:313
jsk_rviz_plugins::BoundingBoxArrayDisplay::onInitialize
void onInitialize()
Definition: bounding_box_array_display.cpp:137
jsk_rviz_plugins::BoundingBoxArrayDisplay::alpha_method_property_
rviz::EnumProperty * alpha_method_property_
Definition: bounding_box_array_display.h:135
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::color_
QColor color_
Definition: bounding_box_display_common.h:138
jsk_rviz_plugins::BoundingBoxArrayDisplay
Definition: bounding_box_array_display.h:88
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::alpha_min_
double alpha_min_
Definition: bounding_box_display_common.h:141
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateAlpha
void updateAlpha()
Definition: bounding_box_array_display.cpp:170
jsk_rviz_plugins
Definition: __init__.py:1
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::shapes_
std::vector< ShapePtr > shapes_
Definition: bounding_box_display_common.h:150
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::value_threshold_
double value_threshold_
Definition: bounding_box_display_common.h:145
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::coloring_method_
std::string coloring_method_
Definition: bounding_box_display_common.h:139
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateShowCoords
void updateShowCoords()
Definition: bounding_box_array_display.cpp:270


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Fri Dec 13 2024 03:49:56