marker_plugin.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #ifndef MAPVIZ_PLUGINS_MARKER_PLUGIN_H_
31 #define MAPVIZ_PLUGINS_MARKER_PLUGIN_H_
32 
33 // C++ standard libraries
34 #include <string>
35 #include <unordered_map>
36 
37 #include <mapviz/mapviz_plugin.h>
38 
39 // QT libraries
40 #include <QGLWidget>
41 #include <QListWidgetItem>
42 
43 // ROS libraries
44 #include <tf/transform_datatypes.h>
46 #include <visualization_msgs/MarkerArray.h>
47 
48 #include <mapviz/map_canvas.h>
49 
50 // QT autogenerated files
51 #include "ui_marker_config.h"
52 
53 namespace mapviz_plugins
54 {
55  using MarkerId = std::pair<std::string, int>;
56 
57  struct MarkerIdHash {
58  std::size_t operator () (const MarkerId &p) const {
59  std::size_t seed = 0;
60  boost::hash_combine(seed, p.first);
61  boost::hash_combine(seed, p.second);
62  return seed;
63  }
64  };
65 
66  struct MarkerNsHash {
67  std::size_t operator () (const std::string &p) const {
68  std::size_t seed = 0;
69  boost::hash_combine(seed, p);
70  return seed;
71  }
72  };
73 
75  {
76  Q_OBJECT
77 
78  public:
79  MarkerPlugin();
80  virtual ~MarkerPlugin();
81 
82  bool Initialize(QGLWidget* canvas);
83  void Shutdown() {}
84 
85  void Draw(double x, double y, double scale);
86  void Paint(QPainter* painter, double x, double y, double scale);
87 
88  void Transform();
89 
90  void LoadConfig(const YAML::Node& node, const std::string& path);
91  void SaveConfig(YAML::Emitter& emitter, const std::string& path);
92 
93  QWidget* GetConfigWidget(QWidget* parent);
94 
96  {
97  return true;
98  }
99 
100  protected:
101  void PrintError(const std::string& message);
102  void PrintInfo(const std::string& message);
103  void PrintWarning(const std::string& message);
104  void timerEvent(QTimerEvent *);
105 
106  protected Q_SLOTS:
107  void SelectTopic();
108  void TopicEdited();
109  void ClearHistory();
110 
111  private:
112  struct Color
113  {
114  float r, g, b, a;
115  };
116 
118  {
121 
123 
128 
130  };
131 
132  struct MarkerData
133  {
136 
139 
140  std::vector<StampedPoint> points;
141  std::string text;
142 
143  float scale_x;
144  float scale_y;
145  float scale_z;
146 
147  std::string source_frame;
149 
151  };
152 
153  Ui::marker_config ui_;
154  QWidget* config_widget_;
155 
156  std::string topic_;
157 
161 
162  std::unordered_map<MarkerId, MarkerData, MarkerIdHash> markers_;
163  std::unordered_map<std::string, bool, MarkerNsHash> marker_visible_;
164 
166  void handleMarker(const visualization_msgs::Marker &marker);
167  void handleMarkerArray(const visualization_msgs::MarkerArray &markers);
168  void transformArrow(MarkerData& markerData,
169  const swri_transform_util::Transform& transform);
170  };
171 }
172 
173 #endif // MAPVIZ_PLUGINS_MARKER_PLUGIN_H_
mapviz_plugins::MarkerPlugin::timerEvent
void timerEvent(QTimerEvent *)
Definition: marker_plugin.cpp:710
mapviz_plugins::MarkerPlugin::StampedPoint::color
Color color
Definition: marker_plugin.h:129
mapviz_plugins::MarkerPlugin::connected_
bool connected_
Definition: marker_plugin.h:159
mapviz_plugins::MarkerPlugin::handleMarker
void handleMarker(const visualization_msgs::Marker &marker)
Definition: marker_plugin.cpp:140
mapviz_plugins::MarkerPlugin::StampedPoint::transformed_arrow_left
tf::Point transformed_arrow_left
Definition: marker_plugin.h:126
mapviz_plugins::MarkerPlugin::MarkerData::display_type
int display_type
Definition: marker_plugin.h:137
mapviz_plugins::MarkerPlugin::Draw
void Draw(double x, double y, double scale)
Definition: marker_plugin.cpp:420
mapviz_plugins::MarkerPlugin::config_widget_
QWidget * config_widget_
Definition: marker_plugin.h:154
boost::shared_ptr< ShapeShifter const >
mapviz_plugins::MarkerPlugin::MarkerData::scale_x
float scale_x
Definition: marker_plugin.h:143
mapviz_plugins::MarkerPlugin::Color::r
float r
Definition: marker_plugin.h:114
mapviz_plugins::MarkerPlugin::MarkerPlugin
MarkerPlugin()
Definition: marker_plugin.cpp:47
mapviz_plugins::MarkerPlugin::SaveConfig
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
Definition: marker_plugin.cpp:705
mapviz_plugins::MarkerPlugin::MarkerData::source_frame
std::string source_frame
Definition: marker_plugin.h:147
mapviz_plugins::MarkerPlugin::Transform
void Transform()
Definition: marker_plugin.cpp:661
mapviz_plugins::MarkerPlugin::~MarkerPlugin
virtual ~MarkerPlugin()
Definition: marker_plugin.cpp:70
mapviz_plugins::MarkerPlugin::marker_visible_
std::unordered_map< std::string, bool, MarkerNsHash > marker_visible_
Definition: marker_plugin.h:163
mapviz_plugins::MarkerPlugin::MarkerData::stamp
ros::Time stamp
Definition: marker_plugin.h:134
mapviz_plugins::MarkerPlugin::PrintError
void PrintError(const std::string &message)
Definition: marker_plugin.cpp:391
mapviz_plugins::MarkerPlugin::handleMarkerArray
void handleMarkerArray(const visualization_msgs::MarkerArray &markers)
Definition: marker_plugin.cpp:383
mapviz_plugins::MarkerIdHash::operator()
std::size_t operator()(const MarkerId &p) const
Definition: marker_plugin.h:58
mapviz_plugins::MarkerPlugin::TopicEdited
void TopicEdited()
Definition: marker_plugin.cpp:97
mapviz_plugins::MarkerPlugin::ui_
Ui::marker_config ui_
Definition: marker_plugin.h:153
mapviz_plugins::MarkerPlugin::transformArrow
void transformArrow(MarkerData &markerData, const swri_transform_util::Transform &transform)
Definition: marker_plugin.cpp:342
mapviz_plugins::MarkerPlugin::SupportsPainting
bool SupportsPainting()
Definition: marker_plugin.h:95
tf::Point
tf::Vector3 Point
mapviz_plugins::MarkerIdHash
Definition: marker_plugin.h:57
mapviz_plugins::MarkerPlugin::StampedPoint::orientation
tf::Quaternion orientation
Definition: marker_plugin.h:120
mapviz_plugins::MarkerPlugin::markers_
std::unordered_map< MarkerId, MarkerData, MarkerIdHash > markers_
Definition: marker_plugin.h:162
mapviz_plugins::MarkerPlugin::StampedPoint::transformed_arrow_right
tf::Point transformed_arrow_right
Definition: marker_plugin.h:127
mapviz_plugins::MarkerPlugin::StampedPoint::transformed_point
tf::Point transformed_point
Definition: marker_plugin.h:122
mapviz_plugins::MarkerPlugin::SelectTopic
void SelectTopic()
Definition: marker_plugin.cpp:82
mapviz_plugins::MarkerPlugin::Color
Definition: marker_plugin.h:112
swri_transform_util::Transform
mapviz_plugins::MarkerPlugin::MarkerData::expire_time
ros::Time expire_time
Definition: marker_plugin.h:135
mapviz_plugins::MarkerPlugin::MarkerData::color
Color color
Definition: marker_plugin.h:138
mapviz_plugins::MarkerPlugin::Initialize
bool Initialize(QGLWidget *canvas)
Definition: marker_plugin.cpp:413
mapviz_plugins::MarkerId
std::pair< std::string, int > MarkerId
Definition: marker_plugin.h:55
mapviz_plugins::MarkerPlugin::MarkerData::transformed
bool transformed
Definition: marker_plugin.h:150
mapviz_plugins::MarkerPlugin::MarkerData::scale_z
float scale_z
Definition: marker_plugin.h:145
mapviz_plugins::MarkerPlugin::has_message_
bool has_message_
Definition: marker_plugin.h:160
mapviz_plugins::MarkerPlugin::PrintWarning
void PrintWarning(const std::string &message)
Definition: marker_plugin.cpp:401
mapviz_plugins::MarkerNsHash::operator()
std::size_t operator()(const std::string &p) const
Definition: marker_plugin.h:67
mapviz_plugins::MarkerPlugin::Paint
void Paint(QPainter *painter, double x, double y, double scale)
Definition: marker_plugin.cpp:596
shape_shifter.h
mapviz_plugins::MarkerPlugin::MarkerData
Definition: marker_plugin.h:132
mapviz_plugins::MarkerPlugin::handleMessage
void handleMessage(const topic_tools::ShapeShifter::ConstPtr &msg)
Definition: marker_plugin.cpp:123
mapviz_plugins::MarkerPlugin::StampedPoint::transformed_arrow_point
tf::Point transformed_arrow_point
Definition: marker_plugin.h:125
mapviz_plugins::MarkerPlugin
Definition: marker_plugin.h:74
transform_datatypes.h
mapviz_plugins::MarkerPlugin::MarkerData::points
std::vector< StampedPoint > points
Definition: marker_plugin.h:140
ros::Time
mapviz_plugins::MarkerPlugin::PrintInfo
void PrintInfo(const std::string &message)
Definition: marker_plugin.cpp:396
mapviz_plugins::MarkerPlugin::marker_sub_
ros::Subscriber marker_sub_
Definition: marker_plugin.h:158
mapviz_plugins::MarkerPlugin::Color::b
float b
Definition: marker_plugin.h:114
mapviz_plugins::MarkerPlugin::topic_
std::string topic_
Definition: marker_plugin.h:156
mapviz_plugins::MarkerPlugin::Color::a
float a
Definition: marker_plugin.h:114
mapviz_plugins::MarkerPlugin::ClearHistory
void ClearHistory()
Definition: marker_plugin.cpp:74
mapviz_plugins::MarkerPlugin::LoadConfig
void LoadConfig(const YAML::Node &node, const std::string &path)
Definition: marker_plugin.cpp:693
mapviz::MapvizPlugin
mapviz_plugins::MarkerPlugin::Shutdown
void Shutdown()
Definition: marker_plugin.h:83
mapviz_plugins::MarkerPlugin::GetConfigWidget
QWidget * GetConfigWidget(QWidget *parent)
Definition: marker_plugin.cpp:406
mapviz_plugins::MarkerNsHash
Definition: marker_plugin.h:66
mapviz_plugins::MarkerPlugin::StampedPoint
Definition: marker_plugin.h:117
mapviz_plugins::MarkerPlugin::MarkerData::text
std::string text
Definition: marker_plugin.h:141
mapviz_plugins::MarkerPlugin::StampedPoint::arrow_point
tf::Point arrow_point
Definition: marker_plugin.h:124
mapviz_plugins
Definition: attitude_indicator_plugin.h:61
mapviz_plugins::MarkerPlugin::Color::g
float g
Definition: marker_plugin.h:114
tf::Quaternion
map_canvas.h
ros::Subscriber
mapviz_plugins::MarkerPlugin::StampedPoint::point
tf::Point point
Definition: marker_plugin.h:119
mapviz_plugins::MarkerPlugin::MarkerData::local_transform
swri_transform_util::Transform local_transform
Definition: marker_plugin.h:148
mapviz_plugins::MarkerPlugin::MarkerData::scale_y
float scale_y
Definition: marker_plugin.h:144
mapviz_plugin.h


mapviz_plugins
Author(s): Marc Alban
autogenerated on Sun Sep 8 2024 02:27:14