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