Skip to content

Commit 48e9719

Browse files
authored
feat(autoware_utils_tf): split package (#49)
* feat(autoware_utils_geometry): split package Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * compatibility header Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * rename namespace Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * fix namespace Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * feat(autoware_utils_tf): split package Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * fix path Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * fix include path Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * move header Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * add todo comment for test Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> --------- Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
1 parent 22cbf83 commit 48e9719

File tree

9 files changed

+157
-46
lines changed

9 files changed

+157
-46
lines changed

autoware_utils/README.md

-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,3 @@
33
## Overview
44

55
The **autoware_utils** library is a comprehensive toolkit designed to facilitate the development of autonomous driving applications. This library provides essential utilities for geometry, mathematics, ROS (Robot Operating System) expansions, diagnostics, and more. It is extensively used in the Autoware project to handle common tasks such as geometric calculations, data normalization, message conversions, performance monitoring, and point cloud transformations.
6-
7-
### Design
8-
9-
#### ROS Module
10-
11-
The ROS module provides utilities for working with ROS messages and nodes:
12-
13-
- **`self_pose_listener.hpp`**: Listens to the self-pose of the vehicle.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 Tier IV, Inc.
1+
// Copyright 2025 The Autoware Contributors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,44 +15,13 @@
1515
#ifndef AUTOWARE_UTILS__ROS__SELF_POSE_LISTENER_HPP_
1616
#define AUTOWARE_UTILS__ROS__SELF_POSE_LISTENER_HPP_
1717

18-
#include "autoware_utils/geometry/geometry.hpp"
19-
#include "autoware_utils/ros/transform_listener.hpp"
18+
// NOLINTBEGIN(build/namespaces, whitespace/line_length)
19+
// clang-format off
2020

21-
#include <rclcpp/rclcpp.hpp>
21+
#include <autoware_utils_tf/self_pose_listener.hpp>
22+
namespace autoware_utils { using namespace autoware_utils_tf; }
2223

23-
#include <memory>
24-
25-
namespace autoware_utils
26-
{
27-
class SelfPoseListener
28-
{
29-
public:
30-
explicit SelfPoseListener(rclcpp::Node * node) : transform_listener_(node) {}
31-
32-
void wait_for_first_pose()
33-
{
34-
while (rclcpp::ok()) {
35-
if (get_current_pose()) {
36-
return;
37-
}
38-
RCLCPP_INFO(transform_listener_.get_logger(), "waiting for self pose...");
39-
rclcpp::Rate(0.2).sleep();
40-
}
41-
}
42-
43-
geometry_msgs::msg::PoseStamped::ConstSharedPtr get_current_pose()
44-
{
45-
const auto tf = transform_listener_.get_latest_transform("map", "base_link");
46-
if (!tf) {
47-
return {};
48-
}
49-
50-
return std::make_shared<const geometry_msgs::msg::PoseStamped>(transform2pose(*tf));
51-
}
52-
53-
private:
54-
TransformListener transform_listener_;
55-
};
56-
} // namespace autoware_utils
24+
// clang-format on
25+
// NOLINTEND
5726

5827
#endif // AUTOWARE_UTILS__ROS__SELF_POSE_LISTENER_HPP_

autoware_utils_tf/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ find_package(autoware_cmake REQUIRED)
55
autoware_package()
66

77
if(BUILD_TESTING)
8+
file(GLOB_RECURSE test_files test/*.cpp)
9+
ament_add_ros_isolated_gtest(test_${PROJECT_NAME} ${test_files})
10+
ament_target_dependencies(test_${PROJECT_NAME}
11+
${${PROJECT_NAME}_FOUND_BUILD_DEPENDS}
12+
${${PROJECT_NAME}_FOUND_TEST_DEPENDS}
13+
)
14+
target_include_directories(test_${PROJECT_NAME} PRIVATE include)
815
endif()
916

1017
ament_auto_package()

autoware_utils_tf/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ It is extensively used in the Autoware project to handle common tasks such as ma
99
## Design
1010

1111
- **`transform_listener.hpp`**: Manages transformation listeners.
12+
- **`self_pose_listener.hpp`**: Listens to the self-pose of the vehicle.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2020 Tier IV, Inc.
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 AUTOWARE_UTILS_TF__SELF_POSE_LISTENER_HPP_
16+
#define AUTOWARE_UTILS_TF__SELF_POSE_LISTENER_HPP_
17+
18+
#include <autoware_utils_geometry/geometry.hpp>
19+
#include <autoware_utils_tf/transform_listener.hpp>
20+
#include <rclcpp/rclcpp.hpp>
21+
22+
#include <geometry_msgs/msg/pose_stamped.hpp>
23+
24+
#include <memory>
25+
26+
namespace autoware_utils_tf
27+
{
28+
class SelfPoseListener
29+
{
30+
public:
31+
explicit SelfPoseListener(rclcpp::Node * node) : transform_listener_(node) {}
32+
33+
void wait_for_first_pose()
34+
{
35+
while (rclcpp::ok()) {
36+
if (get_current_pose()) {
37+
return;
38+
}
39+
RCLCPP_INFO(transform_listener_.get_logger(), "waiting for self pose...");
40+
rclcpp::Rate(0.2).sleep();
41+
}
42+
}
43+
44+
geometry_msgs::msg::PoseStamped::ConstSharedPtr get_current_pose()
45+
{
46+
const auto tf = transform_listener_.get_latest_transform("map", "base_link");
47+
if (!tf) {
48+
return {};
49+
}
50+
51+
return std::make_shared<const geometry_msgs::msg::PoseStamped>(
52+
autoware_utils_geometry::transform2pose(*tf));
53+
}
54+
55+
private:
56+
TransformListener transform_listener_;
57+
};
58+
} // namespace autoware_utils_tf
59+
60+
#endif // AUTOWARE_UTILS_TF__SELF_POSE_LISTENER_HPP_

autoware_utils_tf/package.xml

+2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
<buildtool_depend>ament_cmake_auto</buildtool_depend>
1515
<buildtool_depend>autoware_cmake</buildtool_depend>
1616

17+
<depend>autoware_utils_geometry</depend>
1718
<depend>geometry_msgs</depend>
1819
<depend>rclcpp</depend>
1920
<depend>tf2_ros</depend>
2021

22+
<test_depend>ament_cmake_ros</test_depend>
2123
<test_depend>ament_lint_auto</test_depend>
2224
<test_depend>autoware_lint_common</test_depend>
2325

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2025 The Autoware Contributors
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 "autoware_utils_tf/self_pose_listener.hpp"
16+
17+
#include <gtest/gtest.h>
18+
19+
TEST(TestSelfPoseListener, Main)
20+
{
21+
// TODO(Takagi, Isamu): Add test cases. Currently, we are only checking whether it can be built.
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2025 The Autoware Contributors
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 "autoware_utils_tf/transform_listener.hpp"
16+
17+
#include <gtest/gtest.h>
18+
19+
TEST(TestTransformListener, Main)
20+
{
21+
// TODO(Takagi, Isamu): Add test cases. Currently, we are only checking whether it can be built.
22+
}

autoware_utils_tf/test/main.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2025 The Autoware Contributors
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 <rclcpp/rclcpp.hpp>
16+
17+
#include <gtest/gtest.h>
18+
19+
class RclcppEnvironment : public testing::Environment
20+
{
21+
public:
22+
RclcppEnvironment(int argc, char ** argv) : argc(argc), argv(argv) {}
23+
void SetUp() override { rclcpp::init(argc, argv); }
24+
void TearDown() override { rclcpp::shutdown(); }
25+
26+
private:
27+
int argc;
28+
char ** argv;
29+
};
30+
31+
int main(int argc, char ** argv)
32+
{
33+
testing::InitGoogleTest(&argc, argv);
34+
testing::AddGlobalTestEnvironment(new RclcppEnvironment(argc, argv));
35+
return RUN_ALL_TESTS();
36+
}

0 commit comments

Comments
 (0)