00001 /* 00002 * Copyright (c) 2012, 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_MAP_DISPLAY_H 00031 #define RVIZ_MAP_DISPLAY_H 00032 00033 #ifndef Q_MOC_RUN 00034 #include <boost/thread/thread.hpp> 00035 00036 #include <OgreTexture.h> 00037 #include <OgreMaterial.h> 00038 #include <OgreVector3.h> 00039 #include <OgreSharedPtr.h> 00040 #endif 00041 00042 #include <nav_msgs/MapMetaData.h> 00043 #include <ros/time.h> 00044 00045 #include <nav_msgs/OccupancyGrid.h> 00046 #include <map_msgs/OccupancyGridUpdate.h> 00047 00048 #include "rviz/display.h" 00049 00050 namespace Ogre 00051 { 00052 class ManualObject; 00053 } 00054 00055 namespace rviz 00056 { 00057 00058 class EnumProperty; 00059 class FloatProperty; 00060 class IntProperty; 00061 class Property; 00062 class QuaternionProperty; 00063 class RosTopicProperty; 00064 class VectorProperty; 00065 00070 class MapDisplay: public Display 00071 { 00072 Q_OBJECT 00073 public: 00074 MapDisplay(); 00075 virtual ~MapDisplay(); 00076 00077 // Overrides from Display 00078 virtual void onInitialize(); 00079 virtual void fixedFrameChanged(); 00080 virtual void reset(); 00081 00082 float getResolution() { return resolution_; } 00083 int getWidth() { return width_; } 00084 int getHeight() { return height_; } 00085 00086 virtual void setTopic( const QString &topic, const QString &datatype ); 00087 00088 Q_SIGNALS: 00090 void mapUpdated(); 00091 00092 protected Q_SLOTS: 00093 void updateAlpha(); 00094 void updateTopic(); 00095 void updateDrawUnder(); 00096 void updatePalette(); 00098 void showMap(); 00099 00100 protected: 00101 // overrides from Display 00102 virtual void onEnable(); 00103 virtual void onDisable(); 00104 00105 virtual void subscribe(); 00106 virtual void unsubscribe(); 00107 virtual void update( float wall_dt, float ros_dt ); 00108 00110 void incomingMap(const nav_msgs::OccupancyGrid::ConstPtr& msg); 00111 00113 void incomingUpdate(const map_msgs::OccupancyGridUpdate::ConstPtr& update); 00114 00115 void clear(); 00116 00117 void transformMap(); 00118 00119 Ogre::ManualObject* manual_object_; 00120 Ogre::TexturePtr texture_; 00121 std::vector<Ogre::TexturePtr> palette_textures_; 00122 std::vector<bool> color_scheme_transparency_; 00123 Ogre::MaterialPtr material_; 00124 bool loaded_; 00125 00126 std::string topic_; 00127 float resolution_; 00128 int width_; 00129 int height_; 00130 std::string frame_; 00131 nav_msgs::OccupancyGrid current_map_; 00132 00133 ros::Subscriber map_sub_; 00134 ros::Subscriber update_sub_; 00135 00136 RosTopicProperty* topic_property_; 00137 FloatProperty* resolution_property_; 00138 IntProperty* width_property_; 00139 IntProperty* height_property_; 00140 VectorProperty* position_property_; 00141 QuaternionProperty* orientation_property_; 00142 FloatProperty* alpha_property_; 00143 Property* draw_under_property_; 00144 EnumProperty* color_scheme_property_; 00145 00146 BoolProperty* unreliable_property_; 00147 }; 00148 00149 } // namespace rviz 00150 00151 #endif