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 BACKDROP_DISPLAY_H 00031 #define BACKDROP_DISPLAY_H 00032 00033 #include <message_filters/subscriber.h> 00034 #include <tf/message_filter.h> 00035 #include <rviz/display.h> 00036 #include <rviz/image/ros_image_texture.h> 00037 #include <rviz/properties/float_property.h> 00038 #include <rviz/properties/ros_topic_property.h> 00039 00040 namespace Ogre 00041 { 00042 class SceneNode; 00043 class ManualObject; 00044 } 00045 00046 // All the source in this plugin is in its own namespace. This is not 00047 // required but is good practice. 00048 namespace rviz_backdrop 00049 { 00050 00053 class BackdropDisplay: public rviz::Display 00054 { 00055 public: 00056 // Constructor. pluginlib::ClassLoader creates instances by calling 00057 // the default constructor, so make sure you have one. 00058 BackdropDisplay(); 00059 virtual ~BackdropDisplay(); 00060 00061 // Overrides of public virtual functions from the Display class. 00062 virtual void onInitialize(); 00063 virtual void createProperties(); 00064 virtual void update( float dt, float ros_dt ); 00065 00066 // Setter and getter functions for user-editable properties. 00067 void setTopic(const std::string& topic); 00068 const std::string& getTopic() { return topic_; } 00069 00070 void setScale( float scale ); 00071 float getScale() { return scale_; } 00072 00073 // Overrides of protected virtual functions from Display. As much 00074 // as possible, when Displays are not enabled, they should not be 00075 // subscribed to incoming data and should not show anything in the 00076 // 3D view. These functions are where these connections are made 00077 // and broken. 00078 protected: 00079 virtual void onEnable(); 00080 virtual void onDisable(); 00081 00082 private: 00083 // Internal helpers which do the work of subscribing and 00084 // unsubscribing from the ROS topic. 00085 void subscribe(); 00086 void unsubscribe(); 00087 00088 Ogre::MaterialPtr image_material_; 00089 Ogre::ManualObject* manual_object_; 00090 rviz::ROSImageTexture texture_; 00091 00092 // A node in the Ogre scene tree to be the parent of all our visuals. 00093 Ogre::SceneNode* scene_node_; 00094 00095 // User-editable property variables. 00096 std::string topic_; 00098 float scale_; 00099 00100 // Property objects for user-editable properties. 00101 //rviz::ROSTopicStringPropertyWPtr topic_property_; 00102 //rviz::FloatPropertyWPtr scale_property_; 00103 00104 rviz::FloatProperty* scale_property_; 00105 rviz::RosTopicProperty* topic_property_; 00106 }; 00107 00108 } // end namespace rviz_backdrop 00109 00110 #endif // BACKDROP_DISPLAY_H