marker_display.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef RVIZ_MARKER_DISPLAY_H
00031 #define RVIZ_MARKER_DISPLAY_H
00032 
00033 #include "rviz/display.h"
00034 #include "rviz/selection/forwards.h"
00035 #include "rviz/properties/forwards.h"
00036 
00037 #include <map>
00038 #include <set>
00039 
00040 #include <visualization_msgs/Marker.h>
00041 #include <visualization_msgs/MarkerArray.h>
00042 #include <boost/thread/mutex.hpp>
00043 #include <boost/shared_ptr.hpp>
00044 
00045 #include <message_filters/subscriber.h>
00046 #include <tf/message_filter.h>
00047 
00048 namespace Ogre
00049 {
00050 class SceneManager;
00051 class SceneNode;
00052 }
00053 
00054 namespace ogre_tools
00055 {
00056 class Object;
00057 }
00058 
00059 namespace rviz
00060 {
00061 
00062 class MarkerSelectionHandler;
00063 typedef boost::shared_ptr<MarkerSelectionHandler> MarkerSelectionHandlerPtr;
00064 
00065 class MarkerBase;
00066 typedef boost::shared_ptr<MarkerBase> MarkerBasePtr;
00067 
00068 typedef std::pair<std::string, int32_t> MarkerID;
00069 
00076 class MarkerDisplay : public Display
00077 {
00078 public:
00079   MarkerDisplay();
00080   virtual ~MarkerDisplay();
00081 
00082   virtual void onInitialize();
00083 
00084   virtual void update(float wall_dt, float ros_dt);
00085 
00086   virtual void targetFrameChanged();
00087   virtual void fixedFrameChanged();
00088   virtual void reset();
00089 
00090   void setMarkerTopic(const std::string& topic);
00091   const std::string& getMarkerTopic() { return marker_topic_; }
00092 
00093   virtual void createProperties();
00094 
00095   void setNamespaceEnabled(const std::string& ns, bool enabled);
00096   bool isNamespaceEnabled(const std::string& ns);
00097 
00098   void deleteMarker(MarkerID id);
00099 
00100   void setMarkerStatus(MarkerID id, StatusLevel level, const std::string& text);
00101   void deleteMarkerStatus(MarkerID id);
00102 
00103 protected:
00104   virtual void onEnable();
00105   virtual void onDisable();
00106 
00110   virtual void subscribe();
00114   virtual void unsubscribe();
00115 
00119   void clearMarkers();
00120 
00125   void processMessage( const visualization_msgs::Marker::ConstPtr& message );
00130   void processAdd( const visualization_msgs::Marker::ConstPtr& message );
00135   void processDelete( const visualization_msgs::Marker::ConstPtr& message );
00136 
00137   MarkerBasePtr getMarker(MarkerID id);
00138 
00142   void incomingMarker(const visualization_msgs::Marker::ConstPtr& marker);
00143 
00144   void incomingMarkerArray(const visualization_msgs::MarkerArray::ConstPtr& array);
00145 
00146   void failedMarker(const visualization_msgs::Marker::ConstPtr& marker, tf::FilterFailureReason reason);
00147 
00148   typedef std::map<MarkerID, MarkerBasePtr> M_IDToMarker;
00149   typedef std::set<MarkerBasePtr> S_MarkerBase;
00150   M_IDToMarker markers_;                                
00151   S_MarkerBase markers_with_expiration_;
00152   S_MarkerBase frame_locked_markers_;
00153   typedef std::vector<visualization_msgs::Marker::ConstPtr> V_MarkerMessage;
00154   V_MarkerMessage message_queue_;                       
00155 
00156   boost::mutex queue_mutex_;
00157 
00158   Ogre::SceneNode* scene_node_;                         
00159 
00160   message_filters::Subscriber<visualization_msgs::Marker> sub_;
00161   tf::MessageFilter<visualization_msgs::Marker>* tf_filter_;
00162   ros::Subscriber array_sub_;
00163 
00164   std::string marker_topic_;
00165 
00166   struct Namespace
00167   {
00168     std::string name;
00169     bool enabled;
00170     BoolPropertyWPtr prop;
00171   };
00172   typedef std::map<std::string, Namespace> M_Namespace;
00173   M_Namespace namespaces_;
00174 
00175   ROSTopicStringPropertyWPtr marker_topic_property_;
00176   CategoryPropertyWPtr namespaces_category_;
00177 };
00178 
00179 } // namespace rviz
00180 
00181 #endif /* RVIZ_MARKER_DISPLAY_H */


rviz_qt
Author(s): Dave Hershberger
autogenerated on Fri Dec 6 2013 20:56:52