dynamic_parameters_test_node.cpp
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2020, Southwest Research Institute® (SwRI®)
4 // 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
9 // notice, 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 name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from 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 SOUTHWEST RESEARCH INSTITUTE BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #include <ros/ros.h>
31 
33 
34 #include <boost/function.hpp>
35 #include <boost/bind/placeholders.hpp>
36 
38 {
39 public:
41  nh_("~")
42  {
43  // Setup a one-shot timer to initialize the node after a brief
44  // delay so that /rosout is always fully initialized.
45  ROS_INFO("Starting initialization timer...");
48  this,
49  true);
50  }
51 
52  bool isTestBool() const
53  {
54  return test_bool_;
55  }
56 
57  double getTestDouble() const
58  {
59  return test_double_;
60  }
61 
62  int getTestInt() const
63  {
64  return test_int_;
65  }
66 
67  float getTestFloat() const
68  {
69  return test_float_;
70  }
71 
72  const std::string& getTestString() const
73  {
74  return test_string_;
75  }
76 
77  const std::string& getTestEnum() const
78  {
79  return test_enum_;
80  }
81 
82 private:
84  {
86  params_.get("test_bool", test_bool_, false, "Test Bool");
87  params_.get("test_double", test_double_, 0.0, "Test Double");
88  params_.get("test_int", test_int_, 0, "Test Int");
89  params_.get("test_float", test_float_, 0.0f, "Test Float");
90  params_.get("test_string", test_string_, "", "Test String");
91  std::vector<std::pair<std::string, int> > enums;
92  enums.push_back({"First", 1});
93  enums.push_back({"Second", 2});
94  enums.push_back({"Third", 3});
95  enums.push_back({"Zeroth", 0});
96  params_.addEnums("test_int", enums);
97  params_.finalize();
98 
100  }
101 
103  {
104  ROS_INFO("handleReconfigure");
105  }
106 
109 
111 
112  bool test_bool_{false};
113  double test_double_{0.0};
114  int test_int_{0};
115  float test_float_{0.0};
116  std::string test_string_;
117  std::string test_enum_;
118 };
119 
120 int main(int argc, char **argv)
121 {
122  ros::init(argc, argv, "dynamic_parameters_test");
123 
125  ros::spin();
126 
127  return 0;
128 }
int main(int argc, char **argv)
void finalize(bool alphabetical_order=true)
f
const std::string & getTestEnum() const
void initialize(ros::NodeHandle &pnh)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
const std::string & getTestString() const
WallTimer createWallTimer(WallDuration period, void(T::*callback)(const WallTimerEvent &), T *obj, bool oneshot=false, bool autostart=true) const
void setCallback(boost::function< void(DynamicParameters &)> fun)
#define ROS_INFO(...)
ROSCPP_DECL void spin()
void get(const std::string &name, float &variable, const float default_value, const std::string description="None.", const float min=-100, const float max=100)
void addEnums(const std::string &param, const std::vector< std::pair< std::string, int > > &enums)
void handleReconfigure(swri::DynamicParameters &params)
void initialize(const ros::WallTimerEvent &)


swri_roscpp
Author(s):
autogenerated on Sat Jan 21 2023 03:13:16