-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdemo_ptr.hpp
73 lines (52 loc) · 1.82 KB
/
demo_ptr.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef _ROSPARAM_HANDLER_TUTORIAL_DEMO_BASE_H_
#define _ROSPARAM_HANDLER_TUTORIAL_DEMO_BASE_H_
#include <dynamic_reconfigure/server.h>
#include <ros/ros.h>
#include "rosparam_handler_tutorial/FooParameters.h"
#include "rosparam_handler_tutorial/BarParameters.h"
namespace rosparam_handler_tutorial {
struct DemoBase
{
DemoBase() = default;
virtual ~DemoBase() = default;
/// \brief A helper function to instantiate the
/// params_ptr_ properly
template <typename T>
void init(ros::NodeHandle& private_node_handle);
/// \brief A herlper function to call
/// params_ptr_->fromParamServer
void fromParamServer();
/// \brief A herlper function to call
/// params_ptr_->toParamServer
void toParamServer();
/// \brief A function to periodically print the params_ptr_
void timerCallback(const ros::TimerEvent&) const;
/// \brief A base pointer to the xParameters object
rosparam_handler::ParametersPtr params_ptr_;
ros::NodeHandle private_node_handle_;
ros::Timer timer_;
};
template <typename T>
inline void DemoBase::init(ros::NodeHandle& private_node_handle)
{
params_ptr_ = boost::make_shared<T>(private_node_handle);
}
struct Foo : public DemoBase
{
using DemoBase::timerCallback;
Foo(ros::NodeHandle private_node_handle);
/// \brief The dynamic reconfigure callback
void configCallback(FooConfig &config, uint32_t /*level*/);
/// \brief The dynamic reconfigure server
dynamic_reconfigure::Server<FooConfig> dr_srv_;
};
struct Bar : public DemoBase
{
Bar(ros::NodeHandle private_node_handle);
/// \brief The dynamic reconfigure callback
void configCallback(BarConfig &config, uint32_t /*level*/);
/// \brief The dynamic reconfigure server
dynamic_reconfigure::Server<BarConfig> dr_srv_;
};
} // namespace rosparam_handler_tutorial
#endif /* _ROSPARAM_HANDLER_TUTORIAL_DEMO_BASE_H_ */