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 #include <OGRE/OgreTexture.h> 00034 #include <OGRE/OgreMaterial.h> 00035 #include <OGRE/OgreVector3.h> 00036 00037 #include <nav_msgs/MapMetaData.h> 00038 #include <ros/time.h> 00039 00040 #include <nav_msgs/OccupancyGrid.h> 00041 00042 #include "rviz/display.h" 00043 00044 namespace Ogre 00045 { 00046 class SceneNode; 00047 class ManualObject; 00048 } 00049 00050 namespace rviz 00051 { 00052 00053 class FloatProperty; 00054 class IntProperty; 00055 class Property; 00056 class QuaternionProperty; 00057 class RosTopicProperty; 00058 class VectorProperty; 00059 00064 class MapDisplay: public Display 00065 { 00066 Q_OBJECT 00067 public: 00068 MapDisplay(); 00069 virtual ~MapDisplay(); 00070 00071 // Overrides from Display 00072 virtual void onInitialize(); 00073 virtual void fixedFrameChanged(); 00074 virtual void reset(); 00075 00076 float getResolution() { return resolution_; } 00077 int getWidth() { return width_; } 00078 int getHeight() { return height_; } 00079 Ogre::Vector3 getPosition() { return position_; } 00080 Ogre::Quaternion getOrientation() { return orientation_; } 00081 00082 protected: 00083 // overrides from Display 00084 virtual void onEnable(); 00085 virtual void onDisable(); 00086 00087 private Q_SLOTS: 00088 void updateAlpha(); 00089 void updateTopic(); 00090 void updateDrawUnder(); 00091 00092 private: 00093 void subscribe(); 00094 void unsubscribe(); 00095 00096 void incomingMap(const nav_msgs::OccupancyGrid::ConstPtr& msg); 00097 00098 void clear(); 00099 void transformMap(); 00100 00101 Ogre::SceneNode* scene_node_; 00102 Ogre::ManualObject* manual_object_; 00103 Ogre::TexturePtr texture_; 00104 Ogre::MaterialPtr material_; 00105 bool loaded_; 00106 00107 std::string topic_; 00108 float resolution_; 00109 int width_; 00110 int height_; 00111 Ogre::Vector3 position_; 00112 Ogre::Quaternion orientation_; 00113 std::string frame_; 00114 nav_msgs::OccupancyGrid::ConstPtr map_; 00115 00116 ros::Subscriber map_sub_; 00117 00118 RosTopicProperty* topic_property_; 00119 FloatProperty* resolution_property_; 00120 IntProperty* width_property_; 00121 IntProperty* height_property_; 00122 VectorProperty* position_property_; 00123 QuaternionProperty* orientation_property_; 00124 FloatProperty* alpha_property_; 00125 Property* draw_under_property_; 00126 }; 00127 00128 } // namespace rviz 00129 00130 #endif