NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
config_client.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef FF_UTIL_CONFIG_CLIENT_H_
20 #define FF_UTIL_CONFIG_CLIENT_H_
21 
22 #include <ros/ros.h>
23 
24 #include <ff_common/ff_names.h>
25 
26 #include <dynamic_reconfigure/Reconfigure.h>
27 
28 #include <string>
29 #include <list>
30 
31 namespace ff_util {
32 class ConfigClient {
33  public:
34  // Constructor and destructor
35  explicit ConfigClient(ros::NodeHandle *platform_nh, const std::string &node);
36  virtual ~ConfigClient();
37  // Call a reconfigure with all set variables
38  bool Reconfigure();
39  // Getters and Setters
40  template<typename T> bool Set(const std::string &name, const T &value);
41  template<typename T> bool Get(const std::string &name, T &value);
42  template<typename T> T Get(const std::string &name) {
43  T tmp;
44  if (!Get(name, tmp)) {
45  ROS_ERROR_STREAM("Cannot query parameter " << name);
46  }
47  return tmp;
48  }
49  private:
50  // Private members
51  ros::NodeHandle nh_;
52  ros::ServiceClient service_;
53  dynamic_reconfigure::ReconfigureRequest request_;
54 };
55 
56 template<> bool ConfigClient::Get<int>(const std::string &name, int &value);
57 template<> bool ConfigClient::Get<double>(const std::string &name, double &value);
58 template<> bool ConfigClient::Get<bool>(const std::string &name, bool &value);
59 template<> bool ConfigClient::Get<std::string>(const std::string &name, std::string &value);
60 
61 template<> bool ConfigClient::Set<int>(const std::string &name, const int &value);
62 template<> bool ConfigClient::Set<double>(const std::string &name, const double &value);
63 template<> bool ConfigClient::Set<bool>(const std::string &name, const bool &value);
64 template<> bool ConfigClient::Set<std::string>(const std::string &name, const std::string &value);
65 
66 } // namespace ff_util
67 
68 #endif // FF_UTIL_CONFIG_CLIENT_H_
ff_util::ConfigClient::~ConfigClient
virtual ~ConfigClient()
Definition: config_client.cc:38
ff_util::ConfigClient::Reconfigure
bool Reconfigure()
Definition: config_client.cc:137
ff_util::ConfigClient
Definition: config_client.h:32
ff_util::ConfigClient::Get
T Get(const std::string &name)
Definition: config_client.h:42
ff_util::ConfigClient::Set
bool Set(const std::string &name, const T &value)
Definition: config_client.cc:49
name
std::string name
Definition: eps_simulator.cc:48
ff_names.h
ff_util::ConfigClient::ConfigClient
ConfigClient(ros::NodeHandle *platform_nh, const std::string &node)
Definition: config_client.cc:33
ff_util::ConfigClient::Get
bool Get(const std::string &name, T &value)
Definition: config_client.cc:43
ff_util
Definition: config_client.h:31