Nav2 Navigation Stack - humble  humble
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(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base);
36 
41  explicit NodeThread(rclcpp::executors::SingleThreadedExecutor::SharedPtr executor);
42 
47  template<typename NodeT>
48  explicit NodeThread(NodeT node)
49  : NodeThread(node->get_node_base_interface())
50  {}
51 
55  ~NodeThread();
56 
57 protected:
58  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_;
59  std::unique_ptr<std::thread> thread_;
60  rclcpp::Executor::SharedPtr executor_;
61 };
62 
63 } // namespace nav2_util
64 
65 #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:41
NodeThread(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base)
A background thread to process node callbacks constructor.
Definition: node_thread.cpp:22
NodeThread(NodeT node)
A background thread to process node callbacks constructor.
Definition: node_thread.hpp:48