$search
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( const std::string& name, VisualizationManager* manager ); 00066 virtual ~MapDisplay(); 00067 00068 void setTopic( const std::string& topic ); 00069 const std::string& getTopic() { return topic_; } 00070 00071 float getResolution() { return resolution_; } 00072 int getWidth() { return width_; } 00073 int getHeight() { return height_; } 00074 Ogre::Vector3 getPosition() { return position_; } 00075 Ogre::Quaternion getOrientation() { return orientation_; } 00076 00077 float getAlpha() { return alpha_; } 00078 void setAlpha( float alpha ); 00079 00080 bool getDrawUnder() { return draw_under_; } 00081 void setDrawUnder(bool write); 00082 00083 // Overrides from Display 00084 virtual void targetFrameChanged() {} 00085 virtual void fixedFrameChanged(); 00086 virtual void createProperties(); 00087 virtual void update(float wall_dt, float ros_dt); 00088 virtual void reset(); 00089 00090 protected: 00091 // overrides from Display 00092 virtual void onEnable(); 00093 virtual void onDisable(); 00094 00095 void subscribe(); 00096 void unsubscribe(); 00097 00098 void incomingMap(const nav_msgs::OccupancyGrid::ConstPtr& msg); 00099 00100 void clear(); 00101 void load(const nav_msgs::OccupancyGrid::ConstPtr& msg); 00102 void transformMap(); 00103 00104 void requestThreadFunc(); 00105 00106 Ogre::SceneNode* scene_node_; 00107 Ogre::ManualObject* manual_object_; 00108 Ogre::TexturePtr texture_; 00109 Ogre::MaterialPtr material_; 00110 bool loaded_; 00111 00112 std::string topic_; 00113 float resolution_; 00114 int width_; 00115 int height_; 00116 Ogre::Vector3 position_; 00117 Ogre::Quaternion orientation_; 00118 std::string frame_; 00119 nav_msgs::OccupancyGrid::ConstPtr map_; 00120 00121 float alpha_; 00122 bool draw_under_; 00123 00124 ros::Subscriber map_sub_; 00125 00126 ROSTopicStringPropertyWPtr topic_property_; 00127 FloatPropertyWPtr resolution_property_; 00128 IntPropertyWPtr width_property_; 00129 IntPropertyWPtr height_property_; 00130 Vector3PropertyWPtr position_property_; 00131 QuaternionPropertyWPtr orientation_property_; 00132 FloatPropertyWPtr alpha_property_; 00133 BoolPropertyWPtr draw_under_property_; 00134 }; 00135 00136 } // namespace rviz 00137 00138 #endif