interactive_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_INTERACTIVE_MARKER_DISPLAY_H
31 #define RVIZ_INTERACTIVE_MARKER_DISPLAY_H
32 
33 #include <map>
34 #include <set>
35 
36 #include <visualization_msgs/InteractiveMarker.h>
37 #include <visualization_msgs/InteractiveMarkerUpdate.h>
38 #include <visualization_msgs/InteractiveMarkerInit.h>
39 
40 #ifndef Q_MOC_RUN
43 #endif
44 
45 #include <rviz/display.h>
47 
49 
50 namespace rviz
51 {
52 class BoolProperty;
53 class Object;
54 class RosTopicProperty;
55 class MarkerBase;
56 
58 typedef std::pair<std::string, int32_t> MarkerID;
59 
65 {
66  Q_OBJECT
67 public:
69 
70  void onInitialize() override;
71 
72  void update(float wall_dt, float ros_dt) override;
73 
74  void fixedFrameChanged() override;
75 
76  void reset() override;
77 
78  void setTopic(const QString& topic, const QString& datatype) override;
79 
80 protected:
81  void onEnable() override;
82  void onDisable() override;
83 
84 protected Q_SLOTS:
85  void updateTopic();
87  void updateShowAxes();
88  void updateShowVisualAids();
90  void publishFeedback(visualization_msgs::InteractiveMarkerFeedback& feedback);
91  void onStatusUpdate(StatusProperty::Level level, const std::string& name, const std::string& text);
92 
93 private:
94  // Subscribe to all message topics
95  void subscribe();
96 
97  // Unsubscribe from all message topics
98  void unsubscribe();
99 
100  void initCb(const visualization_msgs::InteractiveMarkerInitConstPtr& msg);
101  void updateCb(const visualization_msgs::InteractiveMarkerUpdateConstPtr& msg);
102 
103  void resetCb(const std::string& server_id);
104 
106  const std::string& server_id,
107  const std::string& msg);
108 
109  void updateMarkers(const std::string& server_id,
110  const std::vector<visualization_msgs::InteractiveMarker>& markers);
111 
112  void updatePoses(const std::string& server_id,
113  const std::vector<visualization_msgs::InteractiveMarkerPose>& marker_poses);
114 
115  void eraseMarkers(const std::string& server_id, const std::vector<std::string>& names);
116 
117  // Update the display's versions of the markers.
118  void processMarkerChanges(const std::vector<visualization_msgs::InteractiveMarker>* markers = nullptr,
119  const std::vector<visualization_msgs::InteractiveMarkerPose>* poses = nullptr,
120  const std::vector<std::string>* erases = nullptr);
121 
123  typedef std::map<std::string, IMPtr> M_StringToIMPtr;
124  typedef std::map<std::string, M_StringToIMPtr> M_StringToStringToIMPtr;
126 
127  M_StringToIMPtr& getImMap(const std::string& server_id);
128 
129  std::string client_id_;
130 
131  // Properties
137 
139 
141 
142  std::string topic_ns_;
143 };
144 
145 } // namespace rviz
146 
147 #endif /* RVIZ_MARKER_DISPLAY_H */
interactive_markers::InteractiveMarkerClient::StatusT
StatusT
rviz::InteractiveMarkerDisplay::onStatusUpdate
void onStatusUpdate(StatusProperty::Level level, const std::string &name, const std::string &text)
Definition: interactive_marker_display.cpp:177
rviz::RosTopicProperty
Definition: ros_topic_property.h:39
rviz::InteractiveMarkerDisplay
Displays Interactive Markers.
Definition: interactive_marker_display.h:64
rviz::InteractiveMarkerDisplay::unsubscribe
void unsubscribe()
Definition: interactive_marker_display.cpp:184
ros::Publisher
rviz::InteractiveMarkerDisplay::onEnable
void onEnable() override
Derived classes override this to do the actual work of enabling themselves.
Definition: interactive_marker_display.cpp:131
rviz::InteractiveMarkerDisplay::show_descriptions_property_
BoolProperty * show_descriptions_property_
Definition: interactive_marker_display.h:133
boost::shared_ptr
rviz::InteractiveMarkerDisplay::updateShowAxes
void updateShowAxes()
Definition: interactive_marker_display.cpp:386
forwards.h
rviz::MarkerBase
Definition: marker_base.h:53
rviz::InteractiveMarkerDisplay::setTopic
void setTopic(const QString &topic, const QString &datatype) override
Set the ROS topic to listen to for this display.
Definition: interactive_marker_display.cpp:126
rviz::InteractiveMarkerDisplay::eraseMarkers
void eraseMarkers(const std::string &server_id, const std::vector< std::string > &names)
Definition: interactive_marker_display.cpp:280
rviz::StatusProperty::Level
Level
Definition: status_property.h:42
rviz::BoolProperty
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
rviz::InteractiveMarkerDisplay::im_client_
boost::shared_ptr< interactive_markers::InteractiveMarkerClient > im_client_
Definition: interactive_marker_display.h:138
rviz::InteractiveMarkerDisplay::updateCb
void updateCb(const visualization_msgs::InteractiveMarkerUpdateConstPtr &msg)
Definition: interactive_marker_display.cpp:337
rviz::InteractiveMarkerDisplay::topic_ns_
std::string topic_ns_
Definition: interactive_marker_display.h:142
rviz::InteractiveMarkerDisplay::updateMarkers
void updateMarkers(const std::string &server_id, const std::vector< visualization_msgs::InteractiveMarker > &markers)
Definition: interactive_marker_display.cpp:222
rviz::InteractiveMarkerDisplay::statusCb
void statusCb(interactive_markers::InteractiveMarkerClient::StatusT, const std::string &server_id, const std::string &msg)
Definition: interactive_marker_display.cpp:350
rviz::InteractiveMarkerDisplay::fixedFrameChanged
void fixedFrameChanged() override
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
Definition: interactive_marker_display.cpp:357
interactive_marker.h
rviz::InteractiveMarkerDisplay::subscribe
void subscribe()
Definition: interactive_marker_display.cpp:159
rviz::InteractiveMarkerDisplay::getImMap
M_StringToIMPtr & getImMap(const std::string &server_id)
Definition: interactive_marker_display.cpp:210
rviz::Display
Definition: display.h:63
rviz::InteractiveMarkerDisplay::initCb
void initCb(const visualization_msgs::InteractiveMarkerInitConstPtr &msg)
Definition: interactive_marker_display.cpp:331
rviz::InteractiveMarkerDisplay::show_axes_property_
BoolProperty * show_axes_property_
Definition: interactive_marker_display.h:134
rviz::InteractiveMarkerDisplay::updatePoses
void updatePoses(const std::string &server_id, const std::vector< visualization_msgs::InteractiveMarkerPose > &marker_poses)
Definition: interactive_marker_display.cpp:292
rviz::InteractiveMarkerDisplay::show_visual_aids_property_
BoolProperty * show_visual_aids_property_
Definition: interactive_marker_display.h:135
rviz::InteractiveMarkerDisplay::onDisable
void onDisable() override
Derived classes override this to do the actual work of disabling themselves.
Definition: interactive_marker_display.cpp:136
rviz::InteractiveMarkerDisplay::processMarkerChanges
void processMarkerChanges(const std::vector< visualization_msgs::InteractiveMarker > *markers=nullptr, const std::vector< visualization_msgs::InteractiveMarkerPose > *poses=nullptr, const std::vector< std::string > *erases=nullptr)
rviz
Definition: add_display_dialog.cpp:54
rviz::InteractiveMarkerDisplay::enable_transparency_property_
BoolProperty * enable_transparency_property_
Definition: interactive_marker_display.h:136
subscriber.h
rviz::MarkerBasePtr
boost::shared_ptr< MarkerBase > MarkerBasePtr
Definition: interactive_marker_display.h:55
interactive_marker_client.h
rviz::InteractiveMarkerDisplay::client_id_
std::string client_id_
Definition: interactive_marker_display.h:129
rviz::InteractiveMarkerDisplay::publishFeedback
void publishFeedback(visualization_msgs::InteractiveMarkerFeedback &feedback)
Definition: interactive_marker_display.cpp:171
rviz::InteractiveMarkerDisplay::updateShowDescriptions
void updateShowDescriptions()
Definition: interactive_marker_display.cpp:371
rviz::InteractiveMarkerDisplay::updateTopic
void updateTopic()
Definition: interactive_marker_display.cpp:141
rviz::InteractiveMarkerDisplay::update
void update(float wall_dt, float ros_dt) override
Called periodically by the visualization manager.
Definition: interactive_marker_display.cpp:194
rviz::InteractiveMarkerDisplay::M_StringToIMPtr
std::map< std::string, IMPtr > M_StringToIMPtr
Definition: interactive_marker_display.h:123
display.h
rviz::InteractiveMarkerDisplay::M_StringToStringToIMPtr
std::map< std::string, M_StringToIMPtr > M_StringToStringToIMPtr
Definition: interactive_marker_display.h:124
rviz::InteractiveMarkerDisplay::interactive_markers_
M_StringToStringToIMPtr interactive_markers_
Definition: interactive_marker_display.h:125
rviz::InteractiveMarkerDisplay::updateEnableTransparency
void updateEnableTransparency()
Definition: interactive_marker_display.cpp:416
rviz::MarkerID
std::pair< std::string, int32_t > MarkerID
Definition: interactive_marker_display.h:58
rviz::InteractiveMarkerDisplay::IMPtr
boost::shared_ptr< InteractiveMarker > IMPtr
Definition: interactive_marker_display.h:122
datatype
const char * datatype()
rviz::InteractiveMarkerDisplay::marker_update_topic_property_
RosTopicProperty * marker_update_topic_property_
Definition: interactive_marker_display.h:132
rviz::InteractiveMarkerDisplay::updateShowVisualAids
void updateShowVisualAids()
Definition: interactive_marker_display.cpp:401
rviz::InteractiveMarkerDisplay::InteractiveMarkerDisplay
InteractiveMarkerDisplay()
Definition: interactive_marker_display.cpp:82
rviz::InteractiveMarkerDisplay::reset
void reset() override
Called to tell the display to clear its state.
Definition: interactive_marker_display.cpp:364
rviz::InteractiveMarkerDisplay::resetCb
void resetCb(const std::string &server_id)
Definition: interactive_marker_display.cpp:344
rviz::InteractiveMarkerDisplay::feedback_pub_
ros::Publisher feedback_pub_
Definition: interactive_marker_display.h:140
rviz::InteractiveMarkerDisplay::onInitialize
void onInitialize() override
Override this function to do subclass-specific initialization.
Definition: interactive_marker_display.cpp:109


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Sat Jun 1 2024 02:31:53