ros_image_texture.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009, 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_ROS_IMAGE_TEXTURE_H
00031 #define RVIZ_ROS_IMAGE_TEXTURE_H
00032 
00033 #include <sensor_msgs/Image.h>
00034 
00035 #include <OGRE/OgreTexture.h>
00036 #include <OGRE/OgreImage.h>
00037 
00038 #include <boost/shared_ptr.hpp>
00039 #include <boost/thread/mutex.hpp>
00040 
00041 #include <ros/ros.h>
00042 #include <image_transport/image_transport.h>
00043 #include <image_transport/subscriber_filter.h>
00044 
00045 #include <tf/message_filter.h>
00046 
00047 #include <stdexcept>
00048 
00049 namespace tf
00050 {
00051 class TransformListener;
00052 }
00053 
00054 namespace rviz
00055 {
00056 
00057 typedef std::vector<std::string> V_string;
00058 
00059 class UnsupportedImageEncoding : public std::runtime_error
00060 {
00061 public:
00062   UnsupportedImageEncoding(const std::string& encoding)
00063   : std::runtime_error("Unsupported image encoding [" + encoding + "]")
00064   {}
00065 };
00066 
00067 class ROSImageTexture
00068 {
00069 public:
00070   ROSImageTexture(const ros::NodeHandle& nh);
00071   ~ROSImageTexture();
00072 
00073   void setTopic(const std::string& topic);
00074   void setFrame(const std::string& frame, tf::TransformListener* tf_client);
00075   bool update();
00076   void clear();
00077 
00078   const Ogre::TexturePtr& getTexture() { return texture_; }
00079   const sensor_msgs::Image::ConstPtr& getImage();
00080 
00081   uint32_t getWidth() { return width_; }
00082   uint32_t getHeight() { return height_; }
00083   uint32_t getImageCount() { return image_count_; }
00084 
00085   image_transport::ImageTransport& getImageTransport() { return it_; }
00086 
00087   void setTransportType(const std::string& transport_type);
00088   const std::string& getTransportType() { return transport_type_; }
00089   void getAvailableTransportTypes(V_string& types);
00090 
00092   void setQueueSize( int size );
00093   int getQueueSize();
00094 
00095 private:
00096   void callback(const sensor_msgs::Image::ConstPtr& image);
00097 
00098   void scanForTransportSubscriberPlugins();
00099 
00100   ros::NodeHandle nh_;
00101   image_transport::ImageTransport it_;
00102   boost::shared_ptr<image_transport::SubscriberFilter> sub_;
00103   boost::shared_ptr<tf::MessageFilter<sensor_msgs::Image> > tf_filter_;
00104 
00105   std::string transport_type_;
00106 
00107   sensor_msgs::Image::ConstPtr current_image_;
00108   boost::mutex mutex_;
00109   bool new_image_;
00110 
00111   Ogre::TexturePtr texture_;
00112   Ogre::Image empty_image_;
00113 
00114   uint32_t width_;
00115   uint32_t height_;
00116 
00117   std::string topic_;
00118   std::string frame_;
00119   tf::TransformListener* tf_client_;
00120 
00121   uint32_t image_count_;
00122   int queue_size_;
00123 
00124   std::set<std::string> transport_plugin_types_;
00125 };
00126 
00127 }
00128 
00129 #endif


rviz
Author(s): Dave Hershberger, Josh Faust
autogenerated on Mon Jan 6 2014 11:54:32