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 }
DynamicParametersTestNode::DynamicParametersTestNode
DynamicParametersTestNode()
Definition: dynamic_parameters_test_node.cpp:40
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
DynamicParametersTestNode::getTestDouble
double getTestDouble() const
Definition: dynamic_parameters_test_node.cpp:57
ros.h
DynamicParametersTestNode::getTestFloat
float getTestFloat() const
Definition: dynamic_parameters_test_node.cpp:67
DynamicParametersTestNode
Definition: dynamic_parameters_test_node.cpp:37
DynamicParametersTestNode::getTestEnum
const std::string & getTestEnum() const
Definition: dynamic_parameters_test_node.cpp:77
swri::DynamicParameters::addEnums
void addEnums(const std::string &param, const std::vector< std::pair< std::string, int > > &enums)
Definition: dynamic_parameters.h:474
ros::WallTimer
swri::DynamicParameters::get
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)
Definition: dynamic_parameters.h:601
DynamicParametersTestNode::getTestInt
int getTestInt() const
Definition: dynamic_parameters_test_node.cpp:62
DynamicParametersTestNode::getTestString
const std::string & getTestString() const
Definition: dynamic_parameters_test_node.cpp:72
f
f
DynamicParametersTestNode::test_bool_
bool test_bool_
Definition: dynamic_parameters_test_node.cpp:112
swri::DynamicParameters::finalize
void finalize(bool alphabetical_order=true)
Definition: dynamic_parameters.h:323
swri::DynamicParameters
Definition: dynamic_parameters.h:125
DynamicParametersTestNode::handleReconfigure
void handleReconfigure(swri::DynamicParameters &params)
Definition: dynamic_parameters_test_node.cpp:102
DynamicParametersTestNode::test_double_
double test_double_
Definition: dynamic_parameters_test_node.cpp:113
DynamicParametersTestNode::test_enum_
std::string test_enum_
Definition: dynamic_parameters_test_node.cpp:117
DynamicParametersTestNode::test_float_
float test_float_
Definition: dynamic_parameters_test_node.cpp:115
DynamicParametersTestNode::isTestBool
bool isTestBool() const
Definition: dynamic_parameters_test_node.cpp:52
DynamicParametersTestNode::nh_
ros::NodeHandle nh_
Definition: dynamic_parameters_test_node.cpp:107
dynamic_parameters.h
swri::DynamicParameters::initialize
void initialize(ros::NodeHandle &pnh)
Definition: dynamic_parameters.h:304
ros::WallTimerEvent
swri::DynamicParameters::setCallback
void setCallback(boost::function< void(DynamicParameters &)> fun)
Definition: dynamic_parameters.h:486
main
int main(int argc, char **argv)
Definition: dynamic_parameters_test_node.cpp:120
ros::spin
ROSCPP_DECL void spin()
DynamicParametersTestNode::init_timer_
ros::WallTimer init_timer_
Definition: dynamic_parameters_test_node.cpp:108
DynamicParametersTestNode::test_int_
int test_int_
Definition: dynamic_parameters_test_node.cpp:114
DynamicParametersTestNode::test_string_
std::string test_string_
Definition: dynamic_parameters_test_node.cpp:116
DynamicParametersTestNode::params_
swri::DynamicParameters params_
Definition: dynamic_parameters_test_node.cpp:110
ros::WallDuration
ROS_INFO
#define ROS_INFO(...)
DynamicParametersTestNode::initialize
void initialize(const ros::WallTimerEvent &)
Definition: dynamic_parameters_test_node.cpp:83
ros::NodeHandle::createWallTimer
WallTimer createWallTimer(WallDuration period, const WallTimerCallback &callback, bool oneshot=false, bool autostart=true) const
ros::NodeHandle


swri_roscpp
Author(s): P. J. Reed
autogenerated on Fri Aug 2 2024 08:39:15