camera_info_manager.h
Go to the documentation of this file.
00001 /* -*- mode: C++ -*- */
00002 /* $Id$ */
00003 
00004 /*********************************************************************
00005 * Software License Agreement (BSD License)
00006 *
00007 *  Copyright (c) 2010-2012 Jack O'Quin
00008 *  All rights reserved.
00009 *
00010 *  Redistribution and use in source and binary forms, with or without
00011 *  modification, are permitted provided that the following conditions
00012 *  are met:
00013 *
00014 *   * Redistributions of source code must retain the above copyright
00015 *     notice, this list of conditions and the following disclaimer.
00016 *   * Redistributions in binary form must reproduce the above
00017 *     copyright notice, this list of conditions and the following
00018 *     disclaimer in the documentation and/or other materials provided
00019 *     with the distribution.
00020 *   * Neither the name of the author nor other contributors may be
00021 *     used to endorse or promote products derived from this software
00022 *     without specific prior written permission.
00023 *
00024 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035 *  POSSIBILITY OF SUCH DAMAGE.
00036 *********************************************************************/
00037 
00038 #ifndef _CAMERA_INFO_MANAGER_H_
00039 #define _CAMERA_INFO_MANAGER_H_
00040 
00041 #include <ros/ros.h>
00042 #include <boost/thread/mutex.hpp>
00043 #include <sensor_msgs/CameraInfo.h>
00044 #include <sensor_msgs/SetCameraInfo.h>
00045 
00053 namespace camera_info_manager
00054 {
00055 
00174 class CameraInfoManager
00175 {
00176  public:
00177 
00178   CameraInfoManager(ros::NodeHandle nh,
00179                     const std::string &cname="camera",
00180                     const std::string &url="");
00181 
00182   sensor_msgs::CameraInfo getCameraInfo(void);
00183   bool isCalibrated(void);
00184   bool loadCameraInfo(const std::string &url);
00185   std::string resolveURL(const std::string &url,
00186                          const std::string &cname);
00187   bool setCameraName(const std::string &cname);
00188   bool validateURL(const std::string &url);
00189 
00190  private:
00191 
00192   // recognized URL types
00193   typedef enum
00194     {
00195       // supported URLs
00196       URL_empty = 0,             // empty string
00197       URL_file,                  // file:
00198       URL_package,               // package: 
00199       // URLs not supported
00200       URL_invalid,               // anything >= is invalid
00201       URL_flash,                 // flash: 
00202     } url_type_t;
00203 
00204   // private methods
00205   std::string getPackageFileName(const std::string &url);
00206   bool loadCalibration(const std::string &url,
00207                        const std::string &cname);
00208   bool loadCalibrationFile(const std::string &filename,
00209                            const std::string &cname);
00210   url_type_t parseURL(const std::string &url);
00211   bool saveCalibration(const sensor_msgs::CameraInfo &new_info,
00212                        const std::string &url,
00213                        const std::string &cname);
00214   bool saveCalibrationFile(const sensor_msgs::CameraInfo &new_info,
00215                            const std::string &filename,
00216                            const std::string &cname);
00217   bool setCameraInfo(sensor_msgs::SetCameraInfo::Request &req,
00218                      sensor_msgs::SetCameraInfo::Response &rsp);
00219 
00228   boost::mutex mutex_;
00229 
00230   // private data
00231   ros::NodeHandle nh_;                  
00232   ros::ServiceServer info_service_;     
00233   std::string camera_name_;             
00234   std::string url_;                     
00235   sensor_msgs::CameraInfo cam_info_;    
00236   bool loaded_cam_info_;                
00237 
00238 }; // class CameraInfoManager
00239 
00240 }; // namespace camera_info_manager
00241 
00242 #endif // _CAMERA_INFO_MANAGER_H_


camera_info_manager
Author(s): Jack O'Quin
autogenerated on Fri Jan 3 2014 11:24:06