camera_info_manager.h
Go to the documentation of this file.
1 /* -*- mode: C++ -*- */
2 /* $Id$ */
3 
4 /*********************************************************************
5 * Software License Agreement (BSD License)
6 *
7 * Copyright (c) 2010-2012 Jack O'Quin
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials provided
19 * with the distribution.
20 * * Neither the name of the author nor other contributors may be
21 * used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *********************************************************************/
37 
38 #ifndef _CAMERA_INFO_MANAGER_H_
39 #define _CAMERA_INFO_MANAGER_H_
40 
41 #include <ros/ros.h>
42 #include <boost/thread/mutex.hpp>
43 #include <sensor_msgs/CameraInfo.h>
44 #include <sensor_msgs/SetCameraInfo.h>
45 
46 #include <ros/macros.h>
47 
48 // Import/export for windows dll's and visibility for gcc shared libraries.
49 
50 #ifdef ROS_BUILD_SHARED_LIBS // ros is being built around shared libraries
51  #ifdef camera_info_manager_EXPORTS // we are building a shared lib/dll
52  #define CAMERA_INFO_MANAGER_DECL ROS_HELPER_EXPORT
53  #else // we are using shared lib/dll
54  #define CAMERA_INFO_MANAGER_DECL ROS_HELPER_IMPORT
55  #endif
56 #else // ros is being built around static libraries
57  #define CAMERA_INFO_MANAGER_DECL
58 #endif
59 
68 {
69 
189 {
190  public:
191 
193  const std::string &cname="camera",
194  const std::string &url="");
195 
196  sensor_msgs::CameraInfo getCameraInfo(void);
197  bool isCalibrated(void);
198  bool loadCameraInfo(const std::string &url);
199  std::string resolveURL(const std::string &url,
200  const std::string &cname);
201  bool setCameraName(const std::string &cname);
202  bool setCameraInfo(const sensor_msgs::CameraInfo &camera_info);
203  bool validateURL(const std::string &url);
204 
205  private:
206 
207  // recognized URL types
208  typedef enum
209  {
210  // supported URLs
211  URL_empty = 0, // empty string
212  URL_file, // file:
213  URL_package, // package:
214  // URLs not supported
215  URL_invalid, // anything >= is invalid
216  URL_flash, // flash:
217  } url_type_t;
218 
219  // private methods
220  std::string getPackageFileName(const std::string &url);
221  bool loadCalibration(const std::string &url,
222  const std::string &cname);
223  bool loadCalibrationFile(const std::string &filename,
224  const std::string &cname);
225  url_type_t parseURL(const std::string &url);
226  bool saveCalibration(const sensor_msgs::CameraInfo &new_info,
227  const std::string &url,
228  const std::string &cname);
229  bool saveCalibrationFile(const sensor_msgs::CameraInfo &new_info,
230  const std::string &filename,
231  const std::string &cname);
232  bool setCameraInfoService(sensor_msgs::SetCameraInfo::Request &req,
233  sensor_msgs::SetCameraInfo::Response &rsp);
234 
243  boost::mutex mutex_;
244 
245  // private data
248  std::string camera_name_;
249  std::string url_;
250  sensor_msgs::CameraInfo cam_info_;
252 
253 }; // class CameraInfoManager
254 
255 }; // namespace camera_info_manager
256 
257 #endif // _CAMERA_INFO_MANAGER_H_
bool loaded_cam_info_
cam_info_ load attempted
std::string url_
URL for calibration data.
ros::ServiceServer info_service_
set_camera_info service
sensor_msgs::CameraInfo cam_info_
current CameraInfo
boost::mutex mutex_
mutual exclusion lock for private data
ros::NodeHandle nh_
node handle for service
#define CAMERA_INFO_MANAGER_DECL


camera_info_manager
Author(s): Jack O'Quin
autogenerated on Sat Apr 4 2020 03:15:05