marker_display.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
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 the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * 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 THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef RVIZ_MARKER_DISPLAY_H
31 #define RVIZ_MARKER_DISPLAY_H
32 
33 #include <map>
34 #include <set>
35 
36 #include <boost/thread/mutex.hpp>
37 #include <boost/shared_ptr.hpp>
38 
39 #ifndef Q_MOC_RUN
40 #include <tf/message_filter.h>
42 #endif
43 
44 #include <visualization_msgs/Marker.h>
45 #include <visualization_msgs/MarkerArray.h>
46 
47 #include "rviz/display.h"
50 
51 namespace rviz
52 {
53 class IntProperty;
54 class MarkerBase;
55 class MarkerNamespace;
56 class MarkerSelectionHandler;
57 class Object;
59 
62 typedef std::pair<std::string, int32_t> MarkerID;
63 
70 class MarkerDisplay : public Display
71 {
72  Q_OBJECT
73 public:
74  MarkerDisplay();
75  ~MarkerDisplay() override;
76 
77  void onInitialize() override;
78 
79  void update(float wall_dt, float ros_dt) override;
80 
81  void fixedFrameChanged() override;
82  void reset() override;
83 
84  void deleteMarker(MarkerID id);
85 
87  void deleteAllMarkers();
88 
89  void setMarkerStatus(MarkerID id, StatusLevel level, const std::string& text);
90  void deleteMarkerStatus(MarkerID id);
91 
92  void setTopic(const QString& topic, const QString& datatype) override;
93 
94 protected:
95  void deleteMarkerInternal(MarkerID id);
96 
97  void onEnable() override;
98  void onDisable() override;
99 
100  void load(const Config& config) override;
101 
104  virtual void subscribe();
105 
108  virtual void unsubscribe();
109 
111  void incomingMarkerArray(const visualization_msgs::MarkerArray::ConstPtr& array);
112 
114 
117 
118 private Q_SLOTS:
119  void updateQueueSize();
120  void updateTopic();
121 
122 private:
124  void deleteMarkersInNamespace(const std::string& ns);
125 
129  void clearMarkers();
130 
135  void processMessage(const visualization_msgs::Marker::ConstPtr& message);
140  void processAdd(const visualization_msgs::Marker::ConstPtr& message);
145  void processDelete(const visualization_msgs::Marker::ConstPtr& message);
146 
150  void incomingMarker(const visualization_msgs::Marker::ConstPtr& marker);
151 
153  tf::FilterFailureReason reason);
154 
155  typedef std::map<MarkerID, MarkerBasePtr> M_IDToMarker;
156  typedef std::set<MarkerBasePtr> S_MarkerBase;
157  M_IDToMarker markers_;
159  S_MarkerBase frame_locked_markers_;
160  typedef std::vector<visualization_msgs::Marker::ConstPtr> V_MarkerMessage;
161  V_MarkerMessage message_queue_;
162  boost::mutex queue_mutex_;
165 
168 
169  typedef QHash<QString, MarkerNamespace*> M_Namespace;
170  M_Namespace namespaces_;
171 
173 
174  typedef std::map<QString, bool> M_EnabledState;
176 
177  friend class MarkerNamespace;
178 };
179 
183 {
184  Q_OBJECT
185 public:
186  MarkerNamespace(const QString& name, Property* parent_property, MarkerDisplay* owner);
187  bool isEnabled() const
188  {
189  return getBool();
190  }
191 
192 public Q_SLOTS:
193  void onEnableChanged();
194 
195 private:
197 };
198 
199 } // namespace rviz
200 
201 #endif /* RVIZ_MARKER_DISPLAY_H */
void processMessage(const visualization_msgs::Marker::ConstPtr &message)
Processes a marker message.
void processAdd(const visualization_msgs::Marker::ConstPtr &message)
Processes an "Add" marker message.
void onDisable() override
Derived classes override this to do the actual work of disabling themselves.
void processDelete(const visualization_msgs::Marker::ConstPtr &message)
Processes a "Delete" marker message.
S_MarkerBase frame_locked_markers_
void setMarkerStatus(MarkerID id, StatusLevel level, const std::string &text)
RosTopicProperty * marker_topic_property_
std::vector< visualization_msgs::Marker::ConstPtr > V_MarkerMessage
M_Namespace namespaces_
MarkerDisplay * owner_
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
IntProperty * queue_size_property_
boost::mutex queue_mutex_
config
void reset() override
Called to tell the display to clear its state.
void incomingMarker(const visualization_msgs::Marker::ConstPtr &marker)
ROS callback notifying us of a new marker.
virtual void onEnableChanged()
Definition: display.cpp:303
Manager of a single marker namespace. Keeps a hash from marker IDs to MarkerBasePtr, and creates or destroys them when .
void deleteMarkerInternal(MarkerID id)
virtual void unsubscribe()
Unsubscribes from the "visualization_marker" "visualization_marker_array" topics. ...
boost::shared_ptr< MarkerSelectionHandler > MarkerSelectionHandlerPtr
Property specialized to provide max/min enforcement for integers.
Definition: int_property.h:37
M_EnabledState namespace_config_enabled_state_
void deleteMarker(MarkerID id)
Configuration data storage class.
Definition: config.h:124
Property * namespaces_category_
void incomingMarkerArray(const visualization_msgs::MarkerArray::ConstPtr &array)
Process a MarkerArray message.
void deleteMarkersInNamespace(const std::string &ns)
Delete all the markers within the given namespace.
std::pair< std::string, int32_t > MarkerID
void update(float wall_dt, float ros_dt) override
Called periodically by the visualization manager.
M_IDToMarker markers_
Map of marker id to the marker info structure.
const char * datatype()
QHash< QString, MarkerNamespace * > M_Namespace
V_MarkerMessage message_queue_
in our update() function
void deleteMarkerStatus(MarkerID id)
void onInitialize() override
Override this function to do subclass-specific initialization.
ros::Subscriber array_sub_
message_filters::Subscriber< visualization_msgs::Marker > sub_
void setTopic(const QString &topic, const QString &datatype) override
Set the ROS topic to listen to for this display.
friend class MarkerNamespace
tf::MessageFilter< visualization_msgs::Marker > * tf_filter_
void fixedFrameChanged() override
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
void failedMarker(const ros::MessageEvent< visualization_msgs::Marker > &marker_evt, tf::FilterFailureReason reason)
void onEnable() override
Derived classes override this to do the actual work of enabling themselves.
S_MarkerBase markers_with_expiration_
virtual void subscribe()
Subscribes to the "visualization_marker" and "visualization_marker_array" topics. ...
std::map< QString, bool > M_EnabledState
void load(const Config &config) override
Load the value of this property and/or its children from the given Config reference.
void deleteAllMarkers()
Delete all known markers to this plugin, regardless of id or namespace.
boost::shared_ptr< MarkerBase > MarkerBasePtr
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
virtual bool getBool() const
Displays "markers" sent in by other ROS nodes on the "visualization_marker" topic.
std::set< MarkerBasePtr > S_MarkerBase
void clearMarkers()
Removes all the markers.
std::map< MarkerID, MarkerBasePtr > M_IDToMarker


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:24