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 RVIZ_MAP_DISPLAY_H 00031 #define RVIZ_MAP_DISPLAY_H 00032 00033 #include "rviz/display.h" 00034 #include "rviz/properties/forwards.h" 00035 00036 #include <OGRE/OgreTexture.h> 00037 #include <OGRE/OgreMaterial.h> 00038 #include <OGRE/OgreVector3.h> 00039 00040 #include <nav_msgs/MapMetaData.h> 00041 #include <ros/time.h> 00042 00043 #include <boost/thread/thread.hpp> 00044 #include <boost/thread/mutex.hpp> 00045 00046 #include <nav_msgs/OccupancyGrid.h> 00047 00048 namespace Ogre 00049 { 00050 class SceneNode; 00051 class ManualObject; 00052 } 00053 00054 namespace rviz 00055 { 00056 00062 class MapDisplay : public Display 00063 { 00064 public: 00065 MapDisplay(); 00066 virtual ~MapDisplay(); 00067 00068 void onInitialize(); 00069 00070 void setTopic( const std::string& topic ); 00071 const std::string& getTopic() { return topic_; } 00072 00073 float getResolution() { return resolution_; } 00074 int getWidth() { return width_; } 00075 int getHeight() { return height_; } 00076 Ogre::Vector3 getPosition() { return position_; } 00077 Ogre::Quaternion getOrientation() { return orientation_; } 00078 00079 float getAlpha() { return alpha_; } 00080 void setAlpha( float alpha ); 00081 00082 bool getDrawUnder() { return draw_under_; } 00083 void setDrawUnder(bool write); 00084 00085 // Overrides from Display 00086 virtual void fixedFrameChanged(); 00087 virtual void createProperties(); 00088 virtual void update(float wall_dt, float ros_dt); 00089 virtual void reset(); 00090 00092 virtual void hideVisible(); 00093 00095 virtual void restoreVisible(); 00096 00097 protected: 00098 // overrides from Display 00099 virtual void onEnable(); 00100 virtual void onDisable(); 00101 00102 void subscribe(); 00103 void unsubscribe(); 00104 00105 void incomingMap(const nav_msgs::OccupancyGrid::ConstPtr& msg); 00106 00107 void clear(); 00108 void load(const nav_msgs::OccupancyGrid::ConstPtr& msg); 00109 void transformMap(); 00110 00111 void requestThreadFunc(); 00112 00113 Ogre::SceneNode* scene_node_; 00114 Ogre::ManualObject* manual_object_; 00115 Ogre::TexturePtr texture_; 00116 Ogre::MaterialPtr material_; 00117 bool loaded_; 00118 00119 std::string topic_; 00120 float resolution_; 00121 int width_; 00122 int height_; 00123 Ogre::Vector3 position_; 00124 Ogre::Quaternion orientation_; 00125 std::string frame_; 00126 nav_msgs::OccupancyGrid::ConstPtr map_; 00127 00128 float alpha_; 00129 bool draw_under_; 00130 00131 ros::Subscriber map_sub_; 00132 00133 ROSTopicStringPropertyWPtr topic_property_; 00134 FloatPropertyWPtr resolution_property_; 00135 IntPropertyWPtr width_property_; 00136 IntPropertyWPtr height_property_; 00137 Vector3PropertyWPtr position_property_; 00138 QuaternionPropertyWPtr orientation_property_; 00139 FloatPropertyWPtr alpha_property_; 00140 BoolPropertyWPtr draw_under_property_; 00141 00142 bool hidden_; 00143 }; 00144 00145 } // namespace rviz 00146 00147 #endif