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  virtual ~MarkerDisplay();
76 
77  virtual void onInitialize();
78 
79  virtual void update(float wall_dt, float ros_dt);
80 
81  virtual void fixedFrameChanged();
82  virtual void reset();
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  virtual void setTopic( const QString &topic, const QString &datatype );
93 
94 protected:
95  virtual void onEnable();
96  virtual void onDisable();
97 
98  virtual void load( const Config& config);
99 
102  virtual void subscribe();
103 
106  virtual void unsubscribe();
107 
109  void incomingMarkerArray( const visualization_msgs::MarkerArray::ConstPtr& array );
110 
112 
115 
116 private Q_SLOTS:
117  void updateQueueSize();
118  void updateTopic();
119 
120 private:
122  void deleteMarkersInNamespace( const std::string& ns );
123 
127  void clearMarkers();
128 
133  void processMessage( const visualization_msgs::Marker::ConstPtr& message );
138  void processAdd( const visualization_msgs::Marker::ConstPtr& message );
143  void processDelete( const visualization_msgs::Marker::ConstPtr& message );
144 
148  void incomingMarker(const visualization_msgs::Marker::ConstPtr& marker);
149 
151 
152  typedef std::map<MarkerID, MarkerBasePtr> M_IDToMarker;
153  typedef std::set<MarkerBasePtr> S_MarkerBase;
154  M_IDToMarker markers_;
156  S_MarkerBase frame_locked_markers_;
157  typedef std::vector<visualization_msgs::Marker::ConstPtr> V_MarkerMessage;
158  V_MarkerMessage message_queue_;
159  boost::mutex queue_mutex_;
161 
164 
165  typedef QHash<QString, MarkerNamespace*> M_Namespace;
166  M_Namespace namespaces_;
167 
169 
170  typedef std::map<QString, bool> M_EnabledState;
172 
173  friend class MarkerNamespace;
174 };
175 
179 {
180 Q_OBJECT
181 public:
182  MarkerNamespace( const QString& name, Property* parent_property, MarkerDisplay* owner );
183  bool isEnabled() const { return getBool(); }
184 
185 public Q_SLOTS:
186  void onEnableChanged();
187 
188 private:
190 };
191 
192 } // namespace rviz
193 
194 #endif /* RVIZ_MARKER_DISPLAY_H */
void processMessage(const visualization_msgs::Marker::ConstPtr &message)
Processes a marker message.
virtual void update(float wall_dt, float ros_dt)
Called periodically by the visualization manager.
void processAdd(const visualization_msgs::Marker::ConstPtr &message)
Processes an "Add" marker message.
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
virtual void reset()
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:305
Manager of a single marker namespace. Keeps a hash from marker IDs to MarkerBasePtr, and creates or destroys them when .
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:38
M_EnabledState namespace_config_enabled_state_
void deleteMarker(MarkerID id)
Configuration data storage class.
Definition: config.h:125
Property * namespaces_category_
void incomingMarkerArray(const visualization_msgs::MarkerArray::ConstPtr &array)
Process a MarkerArray message.
virtual bool getBool() const
void deleteMarkersInNamespace(const std::string &ns)
Delete all the markers within the given namespace.
std::pair< std::string, int32_t > MarkerID
M_IDToMarker markers_
Map of marker id to the marker info structure.
bool isEnabled() const
QHash< QString, MarkerNamespace * > M_Namespace
V_MarkerMessage message_queue_
virtual void load(const Config &config)
Load the settings for this display from the given Config node, which must be a map.
virtual void onDisable()
Derived classes override this to do the actual work of disabling themselves.
void deleteMarkerStatus(MarkerID id)
virtual void fixedFrameChanged()
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
ros::Subscriber array_sub_
message_filters::Subscriber< visualization_msgs::Marker > sub_
friend class MarkerNamespace
tf::MessageFilter< visualization_msgs::Marker > * tf_filter_
void failedMarker(const ros::MessageEvent< visualization_msgs::Marker > &marker_evt, tf::FilterFailureReason reason)
S_MarkerBase markers_with_expiration_
virtual void subscribe()
Subscribes to the "visualization_marker" and "visualization_marker_array" topics. ...
virtual void onEnable()
Derived classes override this to do the actual work of enabling themselves.
std::map< QString, bool > M_EnabledState
virtual void setTopic(const QString &topic, const QString &datatype)
Set the ROS topic to listen to for this display.
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
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
virtual void onInitialize()
Override this function to do subclass-specific initialization.


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:51