Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef RVIZ_MARKER_DISPLAY_H
00031 #define RVIZ_MARKER_DISPLAY_H
00032
00033 #include <map>
00034 #include <set>
00035
00036 #include <boost/thread/mutex.hpp>
00037 #include <boost/shared_ptr.hpp>
00038
00039 #ifndef Q_MOC_RUN
00040 #include <tf/message_filter.h>
00041 #include <message_filters/subscriber.h>
00042 #endif
00043
00044 #include <visualization_msgs/Marker.h>
00045 #include <visualization_msgs/MarkerArray.h>
00046
00047 #include "rviz/display.h"
00048 #include "rviz/properties/bool_property.h"
00049 #include "rviz/selection/forwards.h"
00050
00051 namespace rviz
00052 {
00053 class IntProperty;
00054 class MarkerBase;
00055 class MarkerNamespace;
00056 class MarkerSelectionHandler;
00057 class Object;
00058 class RosTopicProperty;
00059
00060 typedef boost::shared_ptr<MarkerSelectionHandler> MarkerSelectionHandlerPtr;
00061 typedef boost::shared_ptr<MarkerBase> MarkerBasePtr;
00062 typedef std::pair<std::string, int32_t> MarkerID;
00063
00070 class MarkerDisplay: public Display
00071 {
00072 Q_OBJECT
00073 public:
00074 MarkerDisplay();
00075 virtual ~MarkerDisplay();
00076
00077 virtual void onInitialize();
00078
00079 virtual void update(float wall_dt, float ros_dt);
00080
00081 virtual void fixedFrameChanged();
00082 virtual void reset();
00083
00084 void deleteMarker(MarkerID id);
00085
00087 void deleteAllMarkers();
00088
00089 void setMarkerStatus(MarkerID id, StatusLevel level, const std::string& text);
00090 void deleteMarkerStatus(MarkerID id);
00091
00092 virtual void setTopic( const QString &topic, const QString &datatype );
00093
00094 protected:
00095 virtual void onEnable();
00096 virtual void onDisable();
00097
00098 virtual void load( const Config& config);
00099
00102 virtual void subscribe();
00103
00106 virtual void unsubscribe();
00107
00109 void incomingMarkerArray( const visualization_msgs::MarkerArray::ConstPtr& array );
00110
00111 ros::Subscriber array_sub_;
00112
00113 RosTopicProperty* marker_topic_property_;
00114 IntProperty* queue_size_property_;
00115
00116 private Q_SLOTS:
00117 void updateQueueSize();
00118 void updateTopic();
00119
00120 private:
00122 void deleteMarkersInNamespace( const std::string& ns );
00123
00127 void clearMarkers();
00128
00133 void processMessage( const visualization_msgs::Marker::ConstPtr& message );
00138 void processAdd( const visualization_msgs::Marker::ConstPtr& message );
00143 void processDelete( const visualization_msgs::Marker::ConstPtr& message );
00144
00148 void incomingMarker(const visualization_msgs::Marker::ConstPtr& marker);
00149
00150 void failedMarker(const ros::MessageEvent<visualization_msgs::Marker>& marker_evt, tf::FilterFailureReason reason);
00151
00152 typedef std::map<MarkerID, MarkerBasePtr> M_IDToMarker;
00153 typedef std::set<MarkerBasePtr> S_MarkerBase;
00154 M_IDToMarker markers_;
00155 S_MarkerBase markers_with_expiration_;
00156 S_MarkerBase frame_locked_markers_;
00157 typedef std::vector<visualization_msgs::Marker::ConstPtr> V_MarkerMessage;
00158 V_MarkerMessage message_queue_;
00159
00160 boost::mutex queue_mutex_;
00161
00162 message_filters::Subscriber<visualization_msgs::Marker> sub_;
00163 tf::MessageFilter<visualization_msgs::Marker>* tf_filter_;
00164
00165 typedef QHash<QString, MarkerNamespace*> M_Namespace;
00166 M_Namespace namespaces_;
00167
00168 Property* namespaces_category_;
00169
00170 typedef std::map<QString, bool> M_EnabledState;
00171 M_EnabledState namespace_config_enabled_state_;
00172
00173 friend class MarkerNamespace;
00174 };
00175
00178 class MarkerNamespace: public BoolProperty
00179 {
00180 Q_OBJECT
00181 public:
00182 MarkerNamespace( const QString& name, Property* parent_property, MarkerDisplay* owner );
00183 bool isEnabled() const { return getBool(); }
00184
00185 public Q_SLOTS:
00186 void onEnableChanged();
00187
00188 private:
00189 MarkerDisplay* owner_;
00190 };
00191
00192 }
00193
00194 #endif