Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autoware_utils_pcl): split package #29

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions autoware_utils/include/autoware_utils/autoware_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,20 @@
#include "autoware_utils/ros/debug_traits.hpp"
#include "autoware_utils/ros/diagnostics_interface.hpp"
#include "autoware_utils/ros/logger_level_configure.hpp"
#include "autoware_utils/ros/managed_transform_buffer.hpp"
#include "autoware_utils/ros/marker_helper.hpp"
#include "autoware_utils/ros/msg_covariance.hpp"
#include "autoware_utils/ros/msg_operation.hpp"
#include "autoware_utils/ros/parameter.hpp"
#include "autoware_utils/ros/pcl_conversion.hpp"
#include "autoware_utils/ros/polling_subscriber.hpp"
#include "autoware_utils/ros/processing_time_publisher.hpp"
#include "autoware_utils/ros/published_time_publisher.hpp"
#include "autoware_utils/ros/self_pose_listener.hpp"
#include "autoware_utils/ros/transform_listener.hpp"
#include "autoware_utils/ros/update_param.hpp"
#include "autoware_utils/ros/uuid_helper.hpp"
#include "autoware_utils/ros/wait_for_param.hpp"
#include "autoware_utils/system/backtrace.hpp"
#include "autoware_utils/system/lru_cache.hpp"
#include "autoware_utils/system/stop_watch.hpp"
#include "autoware_utils/system/time_keeper.hpp"
#include "autoware_utils/transform/transforms.hpp"

#endif // AUTOWARE_UTILS__AUTOWARE_UTILS_HPP_
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tier IV, Inc.
// Copyright 2025 The Autoware Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,73 +15,13 @@
#ifndef AUTOWARE_UTILS__ROS__TRANSFORM_LISTENER_HPP_
#define AUTOWARE_UTILS__ROS__TRANSFORM_LISTENER_HPP_

#include <rclcpp/rclcpp.hpp>

#include <geometry_msgs/msg/transform_stamped.hpp>

#include <tf2_ros/buffer.h>
#include <tf2_ros/create_timer_ros.h>
#include <tf2_ros/transform_listener.h>

#include <memory>
#include <string>
#include <autoware_utils_tf2/transform_listener.hpp>

namespace autoware_utils
{
class TransformListener
{
public:
explicit TransformListener(rclcpp::Node * node)
: clock_(node->get_clock()), logger_(node->get_logger())
{
tf_buffer_ = std::make_shared<tf2_ros::Buffer>(clock_);
auto timer_interface = std::make_shared<tf2_ros::CreateTimerROS>(
node->get_node_base_interface(), node->get_node_timers_interface());
tf_buffer_->setCreateTimerInterface(timer_interface);
tf_listener_ = std::make_shared<tf2_ros::TransformListener>(*tf_buffer_);
}

geometry_msgs::msg::TransformStamped::ConstSharedPtr get_latest_transform(
const std::string & from, const std::string & to)
{
geometry_msgs::msg::TransformStamped tf;
try {
tf = tf_buffer_->lookupTransform(from, to, tf2::TimePointZero);
} catch (tf2::TransformException & ex) {
RCLCPP_WARN_THROTTLE(
logger_, *clock_, 5000, "failed to get transform from %s to %s: %s", from.c_str(),
to.c_str(), ex.what());
return {};
}

return std::make_shared<const geometry_msgs::msg::TransformStamped>(tf);
}

geometry_msgs::msg::TransformStamped::ConstSharedPtr get_transform(
const std::string & from, const std::string & to, const rclcpp::Time & time,
const rclcpp::Duration & duration)
{
geometry_msgs::msg::TransformStamped tf;
try {
tf = tf_buffer_->lookupTransform(from, to, time, duration);
} catch (tf2::TransformException & ex) {
RCLCPP_WARN_THROTTLE(
logger_, *clock_, 5000, "failed to get transform from %s to %s: %s", from.c_str(),
to.c_str(), ex.what());
return {};
}

return std::make_shared<const geometry_msgs::msg::TransformStamped>(tf);
}

rclcpp::Logger get_logger() { return logger_; }
using namespace autoware_utils_tf2; // NOLINT(build/namespaces)

private:
rclcpp::Clock::SharedPtr clock_;
rclcpp::Logger logger_;
std::shared_ptr<tf2_ros::Buffer> tf_buffer_;
std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
};
} // namespace autoware_utils

#endif // AUTOWARE_UTILS__ROS__TRANSFORM_LISTENER_HPP_
4 changes: 2 additions & 2 deletions autoware_utils/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<maintainer email="ryohsuke.mitsudome@tier4.jp">Ryohsuke Mitsudome</maintainer>
<maintainer email="esteve.fernandez@tier4.jp">Esteve Fernandez</maintainer>
<maintainer email="yutaka.kondo@tier4.jp">Yutaka Kondo</maintainer>
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
Expand All @@ -18,14 +19,13 @@
<depend>autoware_internal_planning_msgs</depend>
<depend>autoware_perception_msgs</depend>
<depend>autoware_planning_msgs</depend>
<depend>autoware_utils_tf2</depend>
<depend>autoware_vehicle_msgs</depend>
<depend>builtin_interfaces</depend>
<depend>diagnostic_msgs</depend>
<depend>geometry_msgs</depend>
<depend>libboost-system-dev</depend>
<depend>logging_demo</depend>
<depend>pcl_conversions</depend>
<depend>pcl_ros</depend>
<depend>rclcpp</depend>
<depend>tf2</depend>
<depend>tf2_eigen</depend>
Expand Down
14 changes: 14 additions & 0 deletions autoware_utils_pcl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.14)
project(autoware_utils_pcl)

find_package(autoware_cmake REQUIRED)
autoware_package()

if(BUILD_TESTING)
file(GLOB_RECURSE test_files test/**/*.cpp)
ament_add_ros_isolated_gtest(test_${PROJECT_NAME} ${test_files})
ament_target_dependencies(test_${PROJECT_NAME} autoware_utils_tf2 pcl_conversions pcl_ros)
target_include_directories(test_${PROJECT_NAME} PRIVATE include)
endif()

ament_auto_package()
1 change: 1 addition & 0 deletions autoware_utils_pcl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# autoware_utils_pcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef AUTOWARE_UTILS__ROS__PCL_CONVERSION_HPP_
#define AUTOWARE_UTILS__ROS__PCL_CONVERSION_HPP_
#ifndef AUTOWARE_UTILS_PCL__CONVERSION_HPP_
#define AUTOWARE_UTILS_PCL__CONVERSION_HPP_

#include <pcl/common/transforms.h>
#include <pcl_conversions/pcl_conversions.h>

#include <vector>

namespace autoware_utils
namespace autoware_utils_pcl
{
/**
* @brief a faster implementation of converting sensor_msgs::msg::PointCloud2 to
Expand Down Expand Up @@ -67,6 +67,6 @@ void transform_point_cloud_from_ros_msg(
}
}

} // namespace autoware_utils
} // namespace autoware_utils_pcl

#endif // AUTOWARE_UTILS__ROS__PCL_CONVERSION_HPP_
#endif // AUTOWARE_UTILS_PCL__CONVERSION_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef AUTOWARE_UTILS__ROS__MANAGED_TRANSFORM_BUFFER_HPP_
#define AUTOWARE_UTILS__ROS__MANAGED_TRANSFORM_BUFFER_HPP_

#include "autoware_utils/ros/transform_listener.hpp"
#ifndef AUTOWARE_UTILS_PCL__MANAGED_TRANSFORM_BUFFER_HPP_
#define AUTOWARE_UTILS_PCL__MANAGED_TRANSFORM_BUFFER_HPP_

#include <autoware_utils_tf2/transform_listener.hpp>
#include <eigen3/Eigen/Core>
#include <pcl_ros/transforms.hpp>
#include <rclcpp/rclcpp.hpp>
Expand Down Expand Up @@ -47,7 +46,7 @@ struct hash<std::pair<std::string, std::string>>
};
} // namespace std

namespace autoware_utils
namespace autoware_utils_pcl
{
using std::chrono_literals::operator""ms;
using Key = std::pair<std::string, std::string>;
Expand All @@ -74,7 +73,7 @@ class ManagedTransformBuffer
return get_static_transform(target_frame, source_frame, eigen_transform);
};
} else {
tf_listener_ = std::make_unique<autoware_utils::TransformListener>(node);
tf_listener_ = std::make_unique<autoware_utils_tf2::TransformListener>(node);
get_transform_ = [this](
const std::string & target_frame, const std::string & source_frame,
Eigen::Matrix4f & eigen_transform) {
Expand Down Expand Up @@ -174,7 +173,7 @@ class ManagedTransformBuffer
}

// Get the transform from the TF tree
tf_listener_ = std::make_unique<autoware_utils::TransformListener>(node_);
tf_listener_ = std::make_unique<autoware_utils_tf2::TransformListener>(node_);
auto tf = tf_listener_->get_transform(
target_frame, source_frame, rclcpp::Time(0), rclcpp::Duration(1000ms));
tf_listener_.reset();
Expand Down Expand Up @@ -219,10 +218,10 @@ class ManagedTransformBuffer

TFMap buffer_;
rclcpp::Node * const node_;
std::unique_ptr<autoware_utils::TransformListener> tf_listener_;
std::unique_ptr<autoware_utils_tf2::TransformListener> tf_listener_;
std::function<bool(const std::string &, const std::string &, Eigen::Matrix4f &)> get_transform_;
};

} // namespace autoware_utils
} // namespace autoware_utils_pcl

#endif // AUTOWARE_UTILS__ROS__MANAGED_TRANSFORM_BUFFER_HPP_
#endif // AUTOWARE_UTILS_PCL__MANAGED_TRANSFORM_BUFFER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef AUTOWARE_UTILS__TRANSFORM__TRANSFORMS_HPP_
#define AUTOWARE_UTILS__TRANSFORM__TRANSFORMS_HPP_
#ifndef AUTOWARE_UTILS_PCL__TRANSFORM_HPP_
#define AUTOWARE_UTILS_PCL__TRANSFORM_HPP_

#include <Eigen/Core>
#include <rclcpp/rclcpp.hpp>

#include <pcl/common/transforms.h>
#include <pcl/point_cloud.h>

namespace autoware_utils
namespace autoware_utils_pcl
{
template <typename PointT>
void transform_pointcloud(
Expand All @@ -46,6 +46,6 @@ void transform_pointcloud(
pcl::transformPointCloud(cloud_in, cloud_out, transform);
}
}
} // namespace autoware_utils
} // namespace autoware_utils_pcl

#endif // AUTOWARE_UTILS__TRANSFORM__TRANSFORMS_HPP_
#endif // AUTOWARE_UTILS_PCL__TRANSFORM_HPP_
28 changes: 28 additions & 0 deletions autoware_utils_pcl/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>autoware_utils_pcl</name>
<version>1.1.0</version>
<description>The autoware_utils_pcl package</description>
<maintainer email="egon.kang@autocore.ai">Jian Kang</maintainer>
<maintainer email="ryohsuke.mitsudome@tier4.jp">Ryohsuke Mitsudome</maintainer>
<maintainer email="esteve.fernandez@tier4.jp">Esteve Fernandez</maintainer>
<maintainer email="yutaka.kondo@tier4.jp">Yutaka Kondo</maintainer>
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_utils_tf2</depend>
<depend>pcl_conversions</depend>
<depend>pcl_ros</depend>

<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
23 changes: 23 additions & 0 deletions autoware_utils_pcl/test/src/build.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2025 The Autoware Contributors
//
// 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 <autoware_utils_pcl/conversion.hpp>
#include <autoware_utils_pcl/managed_transform_buffer.hpp>
#include <autoware_utils_pcl/transform.hpp>

#include <gtest/gtest.h>

TEST(AutowareUtilsPcl, Build)
{
}
26 changes: 26 additions & 0 deletions autoware_utils_pcl/test/test_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2025 The Autoware Contributors
//
// 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 <rclcpp/rclcpp.hpp>

#include <gtest/gtest.h>

int main(int argc, char * argv[])
{
testing::InitGoogleTest(&argc, argv);
rclcpp::init(argc, argv);
bool result = RUN_ALL_TESTS();
rclcpp::shutdown();
return result;
}
14 changes: 14 additions & 0 deletions autoware_utils_tf2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.14)
project(autoware_utils_tf2)

find_package(autoware_cmake REQUIRED)
autoware_package()

if(BUILD_TESTING)
file(GLOB_RECURSE test_files test/**/*.cpp)
ament_add_ros_isolated_gtest(test_${PROJECT_NAME} ${test_files})
ament_target_dependencies(test_${PROJECT_NAME} geometry_msgs rclcpp tf2_ros)
target_include_directories(test_${PROJECT_NAME} PRIVATE include)
endif()

ament_auto_package()
1 change: 1 addition & 0 deletions autoware_utils_tf2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# autoware_utils_tf2
Loading
Loading