Nav2 Navigation Stack - jazzy  jazzy
ROS 2 Navigation Stack
node_thread.hpp
1 // Copyright (c) 2019 Intel Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NAV2_UTIL__NODE_THREAD_HPP_
16 #define NAV2_UTIL__NODE_THREAD_HPP_
17 
18 #include <memory>
19 
20 #include "rclcpp/rclcpp.hpp"
21 
22 namespace nav2_util
23 {
29 {
30 public:
35  explicit NodeThread(
36  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base);
37 
42  explicit NodeThread(
43  rclcpp::executors::SingleThreadedExecutor::SharedPtr executor);
44 
49  template<typename NodeT>
50  explicit NodeThread(NodeT node)
51  : NodeThread(node->get_node_base_interface())
52  {}
53 
57  ~NodeThread();
58 
59 protected:
60  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_;
61  std::unique_ptr<std::thread> thread_;
62  rclcpp::Executor::SharedPtr executor_;
63 };
64 
65 } // namespace nav2_util
66 
67 #endif // NAV2_UTIL__NODE_THREAD_HPP_
A background thread to process node/executor callbacks.
Definition: node_thread.hpp:29
~NodeThread()
A destructor.
Definition: node_thread.cpp:44
NodeThread(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base)
A background thread to process node callbacks constructor.
Definition: node_thread.cpp:21
NodeThread(NodeT node)
A background thread to process node callbacks constructor.
Definition: node_thread.hpp:50