update to tf3

This commit is contained in:
2025-11-17 15:03:25 +07:00
parent 624f24fdd4
commit 5e9993268f
5 changed files with 64 additions and 64 deletions

View File

@@ -41,9 +41,9 @@
#include <sensor_msgs/LaserScan.h>
#include <sensor_msgs/PointCloud2.h>
#include <tf2/buffer_core.h>
#include<tf2/convert.h>
#include "tf2/LinearMath/Transform.h"
#include <tf3/buffer_core.h>
#include<tf3/convert.h>
#include "tf3/LinearMath/Transform.h"
namespace laser_geometry
{
@@ -271,10 +271,10 @@ void LaserProjection::transformLaserScanToPointCloud_(
const std::string & target_frame,
const sensor_msgs::LaserScan & scan_in,
sensor_msgs::PointCloud2 & cloud_out,
tf2::Quaternion quat_start,
tf2::Vector3 origin_start,
tf2::Quaternion quat_end,
tf2::Vector3 origin_end,
tf3::Quaternion quat_start,
tf3::Vector3 origin_start,
tf3::Quaternion quat_end,
tf3::Vector3 origin_end,
double range_cutoff,
int channel_options)
{
@@ -318,7 +318,7 @@ void LaserProjection::transformLaserScanToPointCloud_(
cloud_out.header.frame_id = target_frame;
tf2::Transform cur_transform;
tf3::Transform cur_transform;
double ranges_norm = 1 / (static_cast<double>(scan_in.ranges.size()) - 1.0);
@@ -337,15 +337,15 @@ void LaserProjection::transformLaserScanToPointCloud_(
// TODO(anon): Make a function that performs both the slerp and linear interpolation needed to
// interpolate a Full Transform (Quaternion + Vector)
// Interpolate translation
tf2::Vector3 v(0, 0, 0);
tf3::Vector3 v(0, 0, 0);
v.setInterpolate3(origin_start, origin_end, ratio);
cur_transform.setOrigin(v);
// Compute the slerp-ed rotation
cur_transform.setRotation(slerp(quat_start, quat_end, ratio));
tf2::Vector3 point_in(pstep[0], pstep[1], pstep[2]);
tf2::Vector3 point_out = cur_transform * point_in;
tf3::Vector3 point_in(pstep[0], pstep[1], pstep[2]);
tf3::Vector3 point_out = cur_transform * point_in;
// Copy transformed point into cloud
pstep[0] = static_cast<float>(point_out.x());
@@ -356,7 +356,7 @@ void LaserProjection::transformLaserScanToPointCloud_(
if (has_viewpoint) {
auto vpstep =
reinterpret_cast<float *>(&cloud_out.data[i * cloud_out.point_step + vp_x_offset]);
point_in = tf2::Vector3(vpstep[0], vpstep[1], vpstep[2]);
point_in = tf3::Vector3(vpstep[0], vpstep[1], vpstep[2]);
point_out = cur_transform * point_in;
// Copy transformed point into cloud
@@ -421,7 +421,7 @@ void LaserProjection::transformLaserScanToPointCloud_(
const std::string & target_frame,
const sensor_msgs::LaserScan & scan_in,
sensor_msgs::PointCloud2 & cloud_out,
tf2::BufferCore & tf,
tf3::BufferCore & tf,
double range_cutoff,
int channel_options)
{
@@ -436,31 +436,31 @@ void LaserProjection::transformLaserScanToPointCloud_(
end_time = start_time + duration;
}
tf2::Time st = convertTime(start_time);
tf2::Time e = convertTime(end_time);
tf3::Time st = convertTime(start_time);
tf3::Time e = convertTime(end_time);
tf2::TransformStampedMsg start_transform_msg = tf.lookupTransform(
tf3::TransformStampedMsg start_transform_msg = tf.lookupTransform(
target_frame, scan_in.header.frame_id, st);
tf2::TransformStampedMsg end_transform_msg = tf.lookupTransform(
tf3::TransformStampedMsg end_transform_msg = tf.lookupTransform(
target_frame, scan_in.header.frame_id, e);
geometry_msgs::TransformStamped start_transform = convertToTransformStamped(start_transform_msg);
geometry_msgs::TransformStamped end_transform = convertToTransformStamped(end_transform_msg);
tf2::Quaternion quat_start(start_transform.transform.rotation.x,
tf3::Quaternion quat_start(start_transform.transform.rotation.x,
start_transform.transform.rotation.y,
start_transform.transform.rotation.z,
start_transform.transform.rotation.w);
tf2::Quaternion quat_end(end_transform.transform.rotation.x,
tf3::Quaternion quat_end(end_transform.transform.rotation.x,
end_transform.transform.rotation.y,
end_transform.transform.rotation.z,
end_transform.transform.rotation.w);
tf2::Vector3 origin_start(start_transform.transform.translation.x,
tf3::Vector3 origin_start(start_transform.transform.translation.x,
start_transform.transform.translation.y,
start_transform.transform.translation.z);
tf2::Vector3 origin_end(end_transform.transform.translation.x,
tf3::Vector3 origin_end(end_transform.transform.translation.x,
end_transform.transform.translation.y,
end_transform.transform.translation.z);
transformLaserScanToPointCloud_(