Skip to content

Commit 6551dad

Browse files
committed
fix: add select option for transform lookup time
Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp>
1 parent da5850e commit 6551dad

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

launch/tier4_perception_launch/launch/object_recognition/detection/filter/pointcloud_map_filter.launch.py

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def create_compare_map_pipeline(self):
110110
self.pointcloud_map_filter_param,
111111
{
112112
"input_frame": "map",
113+
"use_pc_stamp_for_dynamic_transform_lookup": True,
113114
},
114115
],
115116
extra_arguments=[

sensing/autoware_pointcloud_preprocessor/include/autoware/pointcloud_preprocessor/filter.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ class Filter : public rclcpp::Node
172172
/** \brief The flag to indicate if only static TF are used. */
173173
bool has_static_tf_only_;
174174

175+
bool use_pc_stamp_for_dynamic_transform_lookup_{false};
176+
175177
/** \brief Internal mutex. */
176178
std::mutex mutex_;
177179

sensing/autoware_pointcloud_preprocessor/src/distortion_corrector/distortion_corrector.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void DistortionCorrectorBase::get_imu_transformation(
8989
}
9090

9191
Eigen::Matrix4f eigen_imu_to_base_link;
92-
imu_transform_exists_ =
93-
managed_tf_buffer_->get_transform(base_frame, imu_frame, eigen_imu_to_base_link);
92+
imu_transform_exists_ = managed_tf_buffer_->get_transform(
93+
base_frame, imu_frame, rclcpp::Time(0), eigen_imu_to_base_link);
9494
tf2::Transform tf2_imu_to_base_link = convert_matrix_to_transform(eigen_imu_to_base_link);
9595

9696
geometry_imu_to_base_link_ptr_ = std::make_shared<geometry_msgs::msg::TransformStamped>();
@@ -431,8 +431,8 @@ void DistortionCorrector2D::set_pointcloud_transform(
431431
}
432432

433433
Eigen::Matrix4f eigen_lidar_to_base_link;
434-
pointcloud_transform_exists_ =
435-
managed_tf_buffer_->get_transform(base_frame, lidar_frame, eigen_lidar_to_base_link);
434+
pointcloud_transform_exists_ = managed_tf_buffer_->get_transform(
435+
base_frame, lidar_frame, rclcpp::Time(0), eigen_lidar_to_base_link);
436436
tf2_lidar_to_base_link_ = convert_matrix_to_transform(eigen_lidar_to_base_link);
437437
tf2_base_link_to_lidar_ = tf2_lidar_to_base_link_.inverse();
438438
pointcloud_transform_needed_ = base_frame != lidar_frame && pointcloud_transform_exists_;
@@ -445,8 +445,8 @@ void DistortionCorrector3D::set_pointcloud_transform(
445445
return;
446446
}
447447

448-
pointcloud_transform_exists_ =
449-
managed_tf_buffer_->get_transform(base_frame, lidar_frame, eigen_lidar_to_base_link_);
448+
pointcloud_transform_exists_ = managed_tf_buffer_->get_transform(
449+
base_frame, lidar_frame, rclcpp::Time(0), eigen_lidar_to_base_link_);
450450
eigen_base_link_to_lidar_ = eigen_lidar_to_base_link_.inverse();
451451
pointcloud_transform_needed_ = base_frame != lidar_frame && pointcloud_transform_exists_;
452452
}

sensing/autoware_pointcloud_preprocessor/src/filter.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ autoware::pointcloud_preprocessor::Filter::Filter(
7373
tf_input_frame_ = static_cast<std::string>(declare_parameter("input_frame", ""));
7474
tf_output_frame_ = static_cast<std::string>(declare_parameter("output_frame", ""));
7575
has_static_tf_only_ = static_cast<bool>(declare_parameter("has_static_tf_only", false));
76+
use_pc_stamp_for_dynamic_transform_lookup_ =
77+
static_cast<bool>(declare_parameter("use_pc_stamp_for_dynamic_transform_lookup", false));
7678
max_queue_size_ = static_cast<std::size_t>(declare_parameter("max_queue_size", 5));
7779

7880
// ---[ Optional parameters
@@ -123,8 +125,8 @@ void autoware::pointcloud_preprocessor::Filter::setupTF()
123125
}
124126
has_static_tf_only_ = true;
125127
}
126-
managed_tf_buffer_ =
127-
std::make_unique<autoware_utils::ManagedTransformBuffer>(this, has_static_tf_only_);
128+
managed_tf_buffer_ = std::make_unique<autoware_utils::ManagedTransformBuffer>(
129+
this, has_static_tf_only_, use_pc_stamp_for_dynamic_transform_lookup_);
128130
}
129131

130132
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -307,9 +309,12 @@ bool autoware::pointcloud_preprocessor::Filter::calculate_transform_matrix(
307309
RCLCPP_DEBUG(
308310
this->get_logger(), "[get_transform_matrix] Transforming input dataset from %s to %s.",
309311
from.header.frame_id.c_str(), target_frame.c_str());
310-
312+
rclcpp::Time lookup_time = rclcpp::Time(0);
313+
if (use_pc_stamp_for_dynamic_transform_lookup_) {
314+
lookup_time = rclcpp::Time(from.header.stamp);
315+
}
311316
if (!managed_tf_buffer_->get_transform(
312-
target_frame, from.header.frame_id, transform_info.eigen_transform)) {
317+
target_frame, from.header.frame_id, lookup_time, transform_info.eigen_transform)) {
313318
return false;
314319
}
315320

0 commit comments

Comments
 (0)