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 * $Id: collision_map_display.h 45518 2010-10-08 20:52:15Z gjones $ 00030 * 00031 */ 00032 00033 #ifndef RVIZ_COLLISION_MAP_DISPLAY_H_ 00034 #define RVIZ_COLLISION_MAP_DISPLAY_H_ 00035 00036 #include "rviz/display.h" 00037 #include "rviz/helpers/color.h" 00038 #include "rviz/properties/forwards.h" 00039 00040 #include <boost/thread/mutex.hpp> 00041 00042 #include <boost/shared_ptr.hpp> 00043 00044 #include <mapping_msgs/OrientedBoundingBox.h> 00045 #include <mapping_msgs/CollisionMap.h> 00046 00047 #include <message_filters/subscriber.h> 00048 #include <tf/message_filter.h> 00049 00050 namespace ogre_tools 00051 { 00052 class PointCloud; 00053 } 00054 00055 namespace Ogre 00056 { 00057 class SceneNode; 00058 class ManualObject; 00059 } 00060 00061 namespace mapping_rviz_plugin 00062 { 00063 00064 namespace collision_render_ops 00065 { 00066 enum CollisionRenderOp 00067 { 00068 CBoxes, CPoints, CCount, 00069 }; 00070 } 00071 typedef collision_render_ops::CollisionRenderOp CollisionRenderOp; 00072 00077 class CollisionMapDisplay : public rviz::Display 00078 { 00079 public: 00080 CollisionMapDisplay(const std::string& name, rviz::VisualizationManager* manager); 00081 00082 virtual ~CollisionMapDisplay(); 00083 00084 void setTopic(const std::string& topic); 00085 const std::string& getTopic() 00086 { 00087 return (topic_); 00088 } 00089 00090 void setColor(const rviz::Color& color); 00091 const rviz::Color& getColor() 00092 { 00093 return (color_); 00094 } 00095 00096 void setOverrideColor(bool override); 00097 bool getOverrideColor() 00098 { 00099 return (override_color_); 00100 } 00101 00102 void setRenderOperation(int op); 00103 int getRenderOperation() 00104 { 00105 return (render_operation_); 00106 } 00107 00108 void setPointSize(float size); 00109 float getPointSize() 00110 { 00111 return (point_size_); 00112 } 00113 00114 void setAlpha(float alpha); 00115 float getAlpha() 00116 { 00117 return (alpha_); 00118 } 00119 00120 // Overrides from Display 00121 virtual void targetFrameChanged(); 00122 virtual void fixedFrameChanged(); 00123 virtual void createProperties(); 00124 virtual void update(float wall_dt, float ros_dt); 00125 virtual void reset(); 00126 00127 protected: 00128 void subscribe(); 00129 void unsubscribe(); 00130 void clear(); 00131 void incomingMessage(const mapping_msgs::CollisionMap::ConstPtr& message); 00132 void processMessage(const mapping_msgs::CollisionMap::ConstPtr& message); 00133 00134 // overrides from Display 00135 virtual void onEnable(); 00136 virtual void onDisable(); 00137 00138 std::string topic_; 00139 rviz::Color color_; 00140 int render_operation_; 00141 bool override_color_; 00142 float point_size_; 00143 float alpha_; 00144 00145 Ogre::SceneNode* scene_node_; 00146 Ogre::ManualObject* manual_object_; 00147 ogre_tools::PointCloud* cloud_; 00148 00149 mapping_msgs::CollisionMap::ConstPtr current_message_; 00150 message_filters::Subscriber<mapping_msgs::CollisionMap> sub_; 00151 tf::MessageFilter<mapping_msgs::CollisionMap> tf_filter_; 00152 00153 rviz::ColorPropertyWPtr color_property_; 00154 rviz::ROSTopicStringPropertyWPtr topic_property_; 00155 rviz::BoolPropertyWPtr override_color_property_; 00156 rviz::EnumPropertyWPtr render_operation_property_; 00157 rviz::FloatPropertyWPtr point_size_property_; 00158 rviz::FloatPropertyWPtr alpha_property_; 00159 }; 00160 00161 } // namespace mapping_rviz_plugin 00162 00163 #endif /* RVIZ_COLLISION_MAP_DISPLAY_H_ */