dynamic_graph_manager
ros_init.hh
Go to the documentation of this file.
1 
10 #ifndef ROS_INIT_HH
11 #define ROS_INIT_HH
12 
13 #include <ros/ros.h>
14 
15 namespace dynamic_graph
16 {
21 struct GlobalRos
22 {
23  GlobalRos()
24  {
25  node_handle_ = nullptr;
26  async_spinner_ = nullptr;
27  }
28 
32  {
33  if (async_spinner_)
34  {
35  async_spinner_->stop();
36  }
37  if (node_handle_)
38  {
39  node_handle_->shutdown();
40  }
41  }
45  boost::shared_ptr<ros::NodeHandle> node_handle_;
51  boost::shared_ptr<ros::AsyncSpinner> async_spinner_;
52 };
53 
60 ros::NodeHandle& ros_init(std::string node_name);
61 
67 ros::AsyncSpinner& ros_spinner(std::string node_name);
68 
73 void ros_shutdown(std::string node_name);
74 
78 void ros_shutdown();
79 
83 bool ros_exist(std::string node_name);
84 
85 } // end of namespace dynamic_graph.
86 
87 #endif
ros::AsyncSpinner & ros_spinner(std::string node_name)
ros_spinner return the async_spinner_.
Definition: ros_init.cpp:68
The GlobalRos struct is a structure that allows to gloabally handle the ROS objects.
Definition: ros_init.hh:21
~GlobalRos()
~GlobalRos is a specific destructor that stop the ROS activities
Definition: ros_init.hh:31
void ros_shutdown(std::string node_name)
ros_shutdown shuts down ros and stop the ros spinner with the associate name
Definition: ros_init.cpp:79
bool ros_exist(std::string node_name)
Check if a node handle has been created or not.
Definition: ros_init.cpp:96
boost::shared_ptr< ros::AsyncSpinner > async_spinner_
ros_async_spinner_ is a ros object that handles in a global way all the ros callbacks and interruptio...
Definition: ros_init.hh:51
this is this package namespace in order to avoid naming conflict
Definition: device.hh:22
boost::shared_ptr< ros::NodeHandle > node_handle_
nodeHandle_ is the global node handle used by all ROS objects
Definition: ros_init.hh:45
ros::NodeHandle & ros_init(std::string node_name)
rosInit is a global method that uses the structure GlobalRos.
Definition: ros_init.cpp:31