$search
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 SHAPE_DISPLAY_H 00031 #define SHAPE_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 <cob_3d_mapping_msgs/Shape.h> 00041 #include <cob_3d_mapping_msgs/ShapeArray.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 00049 namespace Ogre 00050 { 00051 class SceneManager; 00052 class SceneNode; 00053 } 00054 00055 namespace ogre_tools 00056 { 00057 class Object; 00058 } 00059 00060 namespace rviz 00061 { 00062 00063 class MarkerSelectionHandler; 00064 typedef boost::shared_ptr<MarkerSelectionHandler> MarkerSelectionHandlerPtr; 00065 00066 class ShapeBase; 00067 typedef boost::shared_ptr<ShapeBase> ShapeBasePtr; 00068 00069 typedef std::pair<std::string, int32_t> MarkerID; 00070 00077 class ShapeDisplay : public Display 00078 { 00079 public: 00080 ShapeDisplay( const std::string& name, VisualizationManager* manager ); 00081 virtual ~ShapeDisplay(); 00082 00083 virtual void update(float wall_dt, float ros_dt); 00084 00085 virtual void targetFrameChanged(); 00086 virtual void fixedFrameChanged(); 00087 virtual void reset(); 00088 00089 void setMarkerTopic(const std::string& topic); 00090 const std::string& getMarkerTopic() { return marker_topic_; } 00091 00092 virtual void createProperties(); 00093 00094 void setNamespaceEnabled(const std::string& ns, bool enabled); 00095 bool isNamespaceEnabled(const std::string& ns); 00096 00097 void deleteMarker(MarkerID id); 00098 00099 void setMarkerStatus(MarkerID id, StatusLevel level, const std::string& text); 00100 void deleteMarkerStatus(MarkerID id); 00101 00102 protected: 00103 virtual void onEnable(); 00104 virtual void onDisable(); 00105 00109 virtual void subscribe(); 00113 virtual void unsubscribe(); 00114 00118 void clearMarkers(); 00119 00124 void processMessage( const cob_3d_mapping_msgs::Shape::ConstPtr& message ); 00129 void processAdd( const cob_3d_mapping_msgs::Shape::ConstPtr& message ); 00134 void processDelete( const cob_3d_mapping_msgs::Shape::ConstPtr& message ); 00135 00136 //MarkerBasePtr getMarker(MarkerID id); 00137 00141 void incomingMarker(const cob_3d_mapping_msgs::Shape::ConstPtr& marker); 00142 00143 void incomingMarkerArray(const cob_3d_mapping_msgs::ShapeArray::ConstPtr& array); 00144 00145 void failedMarker(const cob_3d_mapping_msgs::Shape::ConstPtr& marker, tf::FilterFailureReason reason); 00146 00147 typedef std::vector<ShapeBasePtr> M_IDToMarker; 00148 typedef std::set<ShapeBasePtr> S_MarkerBase; 00149 M_IDToMarker markers_; 00150 //S_MarkerBase markers_with_expiration_; 00151 //S_MarkerBase frame_locked_markers_; 00152 typedef std::vector<cob_3d_mapping_msgs::Shape::ConstPtr> V_MarkerMessage; 00153 V_MarkerMessage message_queue_; 00154 00155 boost::mutex queue_mutex_; 00156 00157 Ogre::SceneNode* scene_node_; 00158 00159 message_filters::Subscriber<cob_3d_mapping_msgs::Shape> sub_; 00160 tf::MessageFilter<cob_3d_mapping_msgs::Shape> tf_filter_; 00161 ros::Subscriber array_sub_; 00162 00163 std::string marker_topic_; 00164 00165 struct Namespace 00166 { 00167 std::string name; 00168 bool enabled; 00169 BoolPropertyWPtr prop; 00170 }; 00171 typedef std::map<std::string, Namespace> M_Namespace; 00172 M_Namespace namespaces_; 00173 00174 ROSTopicStringPropertyWPtr marker_topic_property_; 00175 CategoryPropertyWPtr namespaces_category_; 00176 }; 00177 00178 } // namespace rviz 00179 00180 #endif /* SHAPE_DISPLAY_H */