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 <tf2_ros/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(const MarkerID& id);
85 
87  void deleteAllMarkers();
88 
89  void setMarkerStatus(const MarkerID& id, StatusLevel level, const std::string& text);
90  void deleteMarkerStatus(const MarkerID& id);
91 
92  void setTopic(const QString& topic, const QString& datatype) override;
93 
94 protected:
95  void deleteMarkerInternal(const 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 
154 
155  typedef std::map<MarkerID, MarkerBasePtr> M_IDToMarker;
156  typedef std::set<MarkerBasePtr> S_MarkerBase;
160  typedef std::vector<visualization_msgs::Marker::ConstPtr> V_MarkerMessage;
162  boost::mutex queue_mutex_;
165 
168 
169  typedef QHash<QString, MarkerNamespace*> M_Namespace;
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 */
rviz::BoolProperty::getBool
virtual bool getBool() const
Definition: bool_property.cpp:48
rviz::MarkerDisplay::onDisable
void onDisable() override
Derived classes override this to do the actual work of disabling themselves.
Definition: marker_display.cpp:129
rviz::RosTopicProperty
Definition: ros_topic_property.h:39
rviz::MarkerDisplay
Displays "markers" sent in by other ROS nodes on the "visualization_marker" topic.
Definition: marker_display.h:70
rviz::MarkerDisplay::MarkerDisplay
MarkerDisplay()
Definition: marker_display.cpp:52
tf2_ros::MessageFilter< visualization_msgs::Marker >
boost::shared_ptr
rviz::MarkerDisplay::M_Namespace
QHash< QString, MarkerNamespace * > M_Namespace
Definition: marker_display.h:169
forwards.h
rviz::MarkerDisplay::sub_
message_filters::Subscriber< visualization_msgs::Marker > sub_
Definition: marker_display.h:166
rviz::MarkerDisplay::update
void update(float wall_dt, float ros_dt) override
Called periodically by the visualization manager.
Definition: marker_display.cpp:383
rviz::MarkerDisplay::processAdd
void processAdd(const visualization_msgs::Marker::ConstPtr &message)
Processes an "Add" marker message.
Definition: marker_display.cpp:309
rviz::MarkerDisplay::reset
void reset() override
Called to tell the display to clear its state.
Definition: marker_display.cpp:441
rviz::MarkerDisplay::incomingMarker
void incomingMarker(const visualization_msgs::Marker::ConstPtr &marker)
ROS callback notifying us of a new marker.
Definition: marker_display.cpp:262
rviz::MarkerDisplay::onEnable
void onEnable() override
Derived classes override this to do the actual work of enabling themselves.
Definition: marker_display.cpp:124
tf2_ros::filter_failure_reasons::FilterFailureReason
FilterFailureReason
rviz::StatusProperty::Level
Level
Definition: status_property.h:42
rviz::BoolProperty
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
rviz::MarkerDisplay::message_queue_
V_MarkerMessage message_queue_
in our update() function
Definition: marker_display.h:161
rviz::MarkerDisplay::array_sub_
ros::Subscriber array_sub_
Definition: marker_display.h:113
rviz::MarkerDisplay::namespaces_category_
Property * namespaces_category_
Definition: marker_display.h:172
rviz::MarkerNamespace::onEnableChanged
void onEnableChanged()
Definition: marker_display.cpp:465
bool_property.h
rviz::MarkerNamespace::MarkerNamespace
MarkerNamespace(const QString &name, Property *parent_property, MarkerDisplay *owner)
Definition: marker_display.cpp:455
rviz::MarkerDisplay::V_MarkerMessage
std::vector< visualization_msgs::Marker::ConstPtr > V_MarkerMessage
Definition: marker_display.h:160
rviz::MarkerDisplay::setTopic
void setTopic(const QString &topic, const QString &datatype) override
Set the ROS topic to listen to for this display.
Definition: marker_display.cpp:447
rviz::MarkerDisplay::queue_mutex_
boost::mutex queue_mutex_
Definition: marker_display.h:164
message_filters::Subscriber< visualization_msgs::Marker >
rviz::MarkerNamespace::owner_
MarkerDisplay * owner_
Definition: marker_display.h:196
rviz::Display
Definition: display.h:63
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz::MarkerDisplay::processMessage
void processMessage(const visualization_msgs::Marker::ConstPtr &message)
Processes a marker message.
Definition: marker_display.cpp:284
rviz::MarkerDisplay::deleteMarker
void deleteMarker(const MarkerID &id)
Definition: marker_display.cpp:180
rviz::MarkerDisplay::M_EnabledState
std::map< QString, bool > M_EnabledState
Definition: marker_display.h:174
rviz::MarkerDisplay::deleteMarkerInternal
void deleteMarkerInternal(const MarkerID &id)
Definition: marker_display.cpp:186
rviz::MarkerDisplay::load
void load(const Config &config) override
Load the value of this property and/or its children from the given Config reference.
Definition: marker_display.cpp:100
message_filter.h
rviz
Definition: add_display_dialog.cpp:54
subscriber.h
rviz::MarkerBasePtr
boost::shared_ptr< MarkerBase > MarkerBasePtr
Definition: interactive_marker_display.h:55
rviz::MarkerDisplay::~MarkerDisplay
~MarkerDisplay() override
Definition: marker_display.cpp:88
rviz::MarkerDisplay::namespace_config_enabled_state_
M_EnabledState namespace_config_enabled_state_
Definition: marker_display.h:175
rviz::MarkerDisplay::tf_filter_
tf2_ros::MessageFilter< visualization_msgs::Marker > * tf_filter_
Definition: marker_display.h:167
rviz::MarkerDisplay::deleteMarkerStatus
void deleteMarkerStatus(const MarkerID &id)
Definition: marker_display.cpp:245
rviz::MarkerSelectionHandlerPtr
boost::shared_ptr< MarkerSelectionHandler > MarkerSelectionHandlerPtr
Definition: marker_display.h:58
rviz::MarkerDisplay::namespaces_
M_Namespace namespaces_
Definition: marker_display.h:170
rviz::MarkerDisplay::unsubscribe
virtual void unsubscribe()
Unsubscribes from the "visualization_marker" "visualization_marker_array" topics.
Definition: marker_display.cpp:174
rviz::MarkerNamespace
Manager of a single marker namespace. Keeps a hash from marker IDs to MarkerBasePtr,...
Definition: marker_display.h:182
rviz::MarkerDisplay::deleteAllMarkers
void deleteAllMarkers()
Delete all known markers to this plugin, regardless of id or namespace.
Definition: marker_display.cpp:222
rviz::MarkerNamespace::isEnabled
bool isEnabled() const
Definition: marker_display.h:187
display.h
rviz::MarkerDisplay::updateQueueSize
void updateQueueSize()
Definition: marker_display.cpp:135
rviz::MarkerDisplay::markers_
M_IDToMarker markers_
Map of marker id to the marker info structure.
Definition: marker_display.h:157
rviz::MarkerID
std::pair< std::string, int32_t > MarkerID
Definition: interactive_marker_display.h:58
rviz::MarkerDisplay::clearMarkers
void clearMarkers()
Removes all the markers.
Definition: marker_display.cpp:113
rviz::MarkerDisplay::subscribe
virtual void subscribe()
Subscribes to the "visualization_marker" and "visualization_marker_array" topics.
Definition: marker_display.cpp:147
rviz::MarkerDisplay::frame_locked_markers_
S_MarkerBase frame_locked_markers_
Definition: marker_display.h:159
rviz::MarkerDisplay::marker_topic_property_
RosTopicProperty * marker_topic_property_
Definition: marker_display.h:115
rviz::MarkerDisplay::onInitialize
void onInitialize() override
Override this function to do subclass-specific initialization.
Definition: marker_display.cpp:72
datatype
const char * datatype()
rviz::MarkerDisplay::M_IDToMarker
std::map< MarkerID, MarkerBasePtr > M_IDToMarker
Definition: marker_display.h:155
rviz::MarkerDisplay::processDelete
void processDelete(const visualization_msgs::Marker::ConstPtr &message)
Processes a "Delete" marker message.
Definition: marker_display.cpp:376
rviz::MarkerDisplay::markers_with_expiration_
S_MarkerBase markers_with_expiration_
Definition: marker_display.h:158
rviz::MarkerDisplay::failedMarker
void failedMarker(const ros::MessageEvent< visualization_msgs::Marker > &marker_evt, tf2_ros::FilterFailureReason reason)
Definition: marker_display.cpp:268
rviz::MarkerDisplay::queue_size_property_
IntProperty * queue_size_property_
Definition: marker_display.h:116
rviz::MarkerDisplay::incomingMarkerArray
void incomingMarkerArray(const visualization_msgs::MarkerArray::ConstPtr &array)
Process a MarkerArray message.
Definition: marker_display.cpp:253
rviz::MarkerDisplay::deleteMarkersInNamespace
void deleteMarkersInNamespace(const std::string &ns)
Delete all the markers within the given namespace.
Definition: marker_display.cpp:197
config
config
rviz::MarkerDisplay::fixedFrameChanged
void fixedFrameChanged() override
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
Definition: marker_display.cpp:434
rviz::Config
Configuration data storage class.
Definition: config.h:124
ros::MessageEvent
ros::Subscriber
rviz::IntProperty
Property specialized to provide max/min enforcement for integers.
Definition: int_property.h:37
rviz::MarkerDisplay::updateTopic
void updateTopic()
Definition: marker_display.cpp:141
rviz::MarkerDisplay::S_MarkerBase
std::set< MarkerBasePtr > S_MarkerBase
Definition: marker_display.h:156
rviz::MarkerDisplay::setMarkerStatus
void setMarkerStatus(const MarkerID &id, StatusLevel level, const std::string &text)
Definition: marker_display.cpp:237


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:09