AutoAPMS
Resilient Robot Mission Management
Loading...
Searching...
No Matches
ros_node_context.cpp
Go to the documentation of this file.
1// Copyright 2024 Robin Müller
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// https://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
16
18{
19RosNodeContext::RosNodeContext(rclcpp::Node::SharedPtr node_ptr, const NodeRegistrationParams& tree_node_params)
20 : nh(node_ptr)
21 , default_port_name(tree_node_params.port)
22 , wait_for_server_timeout(tree_node_params.wait_timeout)
23 , request_timeout(tree_node_params.request_timeout)
24{
25}
26
27rclcpp::Logger RosNodeContext::getLogger() const
28{
29 if (const auto node = nh.lock())
30 {
31 return node->get_logger();
32 }
33 return rclcpp::get_logger("RosTreeNode");
34}
35
37{
38 if (const auto node = nh.lock())
39 {
40 return node->now();
41 }
42 return rclcpp::Clock(RCL_ROS_TIME).now();
43}
44
45} // namespace auto_apms_behavior_tree
Behavior tree node registration parameters.
RosNodeContext(rclcpp::Node::SharedPtr node_ptr, const NodeRegistrationParams &tree_node_params)
std::weak_ptr< rclcpp::Node > nh
Handle for the ROS2 node.