Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
vector_object_utils.cpp
1 // Copyright (c) 2023 Samsung R&D Institute Russia
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 #include "nav2_map_server/vector_object_utils.hpp"
16 
17 namespace nav2_map_server
18 {
19 
20 bool lookupShapeTransform(
21  const std_msgs::msg::Header & header,
22  const std::string & target_frame,
23  const nav2::TransformBuffer::SharedPtr & tf_buffer,
24  const double transform_tolerance,
25  geometry_msgs::msg::TransformStamped & transform)
26 {
27  try {
28  transform = tf_buffer->lookupTransform(
29  target_frame, header.frame_id, rclcpp::Time(header.stamp),
30  tf2::durationFromSec(transform_tolerance));
31  return true;
32  } catch (const tf2::TransformException &) {
33  return false;
34  }
35 }
36 
37 } // namespace nav2_map_server