stparameter.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (C) 2018, OMRON SENTECH. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the names of OMRON SENTECH nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *****************************************************************************/
29 
31 #include <algorithm>
32 
33 namespace stcamera
34 {
36  {
37  }
38 
40  {
41  }
42 
44  std::vector<std::string> &camera_to_connect)
45  {
46  vec_camera_to_connect_.clear();
47  camera_to_connect.clear();
48 
49  if (nh.hasParam("camera_to_connect"))
50  {
51  nh.getParam("camera_to_connect", vec_camera_to_connect_);
52  }
53 
54  for (size_t i = 0; i < vec_camera_to_connect_.size(); i++)
55  {
56  std::string camera_id = vec_camera_to_connect_[i];
57  if (camera_id.compare("all") == 0)
58  {
59  continue;
60  }
61 
62  // fill in the return arguments
63  camera_to_connect.push_back(camera_id);
64  }
65  }
66 
68  std::string camera_namespace)
69  {
70  std::string param_key = "";
71  if (!camera_namespace.empty())
72  {
73  if (nh.searchParam("calibration_file", param_key))
74  {
75  std::string value = "";
76  nh.getParam(param_key, value);
77  return value;
78  }
79  }
80 
81  if (nh.searchParam("default_calibration_file", param_key))
82  {
83  std::string value = "";
84  nh.getParam(param_key, value);
85  return value;
86  }
87  return "";
88  }
89 
91  {
92  return (vec_camera_to_connect_.size() == 0);
93  }
94 
96  {
97  for (size_t i = 0; i < vec_camera_to_connect_.size(); i++)
98  {
99  std::string value = vec_camera_to_connect_[i];
100  if (value.compare("all") == 0) return true;
101  }
102  return false;
103  }
104 
105  std::string StParameter::getNamespace(std::string camera_id)
106  {
107  std::replace_if(camera_id.begin(), camera_id.end(), ::ispunct, '_');
108  return std::string("dev_" + camera_id);
109  }
110 
111 } // end of namespace stcamera
std::vector< std::string > vec_camera_to_connect_
Definition: stparameter.h:124
std::string getCalibrationFile(const ros::NodeHandle &nh, std::string camera_namespace)
Definition: stparameter.cpp:67
bool searchParam(const std::string &key, std::string &result) const
void loadCameraList(const ros::NodeHandle &nh, std::vector< std::string > &camera_to_connect)
Definition: stparameter.cpp:43
std::string getNamespace(std::string camera_id)
bool getParam(const std::string &key, std::string &s) const
Class to handle ROS parameter.
bool hasParam(const std::string &key) const


omronsentech_camera
Author(s): OSE ROS Support
autogenerated on Tue Jul 2 2019 19:44:14