Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nav2_util/src/robot_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool getCurrentPose(
RCLCPP_ERROR(
logger,
"Transform timeout with tolerance: %.4f", transform_timeout);
} catch (...) {
} catch (tf2::TransformException & ex) {
RCLCPP_ERROR(
logger, "Failed to transform from %s to %s",
global_frame.c_str(), robot_frame.c_str());
Expand Down
4 changes: 4 additions & 0 deletions nav2_util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ target_link_libraries(test_lifecycle_cli_node ${library_name})
ament_add_gtest(test_geometry_utils test_geometry_utils.cpp)
ament_target_dependencies(test_geometry_utils geometry_msgs)
target_link_libraries(test_geometry_utils ${library_name})

ament_add_gtest(test_robot_utils test_robot_utils.cpp)
ament_target_dependencies(test_robot_utils geometry_msgs)
target_link_libraries(test_robot_utils ${library_name})
32 changes: 32 additions & 0 deletions nav2_util/test/test_robot_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2020 Samsung Research
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "nav2_util/robot_utils.hpp"
#include "tf2_ros/transform_listener.h"
#include "tf2_ros/transform_broadcaster.h"
#include "geometry_msgs/msg/pose_stamped.hpp"
#include "gtest/gtest.h"
#include "nav2_util/node_thread.hpp"
#include "tf2_ros/create_timer_ros.h"

TEST(RobotUtils, LookupExceptionError)
{
rclcpp::init(0, nullptr);
auto node = std::make_shared<rclcpp::Node>("name", rclcpp::NodeOptions());
geometry_msgs::msg::PoseStamped global_pose;
tf2_ros::Buffer tf(node->get_clock());
ASSERT_FALSE(nav2_util::getCurrentPose(global_pose, tf, "map", "base_link", 0.1));
}