Skip to content

Commit

Permalink
Add ParticleCuboid::weightedAverage method
Browse files Browse the repository at this point in the history
  • Loading branch information
furushchev committed Feb 20, 2025
1 parent 77ef079 commit 146824c
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions jsk_pcl_ros/include/jsk_pcl_ros/pcl/particle_cuboid.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,26 @@ namespace pcl
}

inline jsk_pcl_ros::Cube::Ptr toCube() const
{
Eigen::Affine3f pose = toEigenMatrix();
Eigen::Vector3f dimensions(dx, dy, dz);
jsk_pcl_ros::Cube::Ptr cube(new jsk_pcl_ros::Cube(Eigen::Vector3f(pose.translation()),
Eigen::Quaternionf(pose.rotation()),
dimensions));
return cube;
}
{
Eigen::Affine3f pose = toEigenMatrix();
Eigen::Vector3f dimensions(dx, dy, dz);
jsk_pcl_ros::Cube::Ptr cube(new jsk_pcl_ros::Cube(Eigen::Vector3f(pose.translation()),
Eigen::Quaternionf(pose.rotation()),
dimensions));
return cube;
}

// As of https://github.com/PointCloudLibrary/pcl/pull/5538,
// trackers must implements averaging method
template <class InputIterator>
static ParticleCuboid weightedAverage(InputIterator first, InputIterator last)
{
ParticleCuboid wa;
for (auto cuboid = first; cuboid != last; ++cuboid) {
wa = wa + *(cuboid) * cuboid->weight;
}
return wa;
}

EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
Expand Down

0 comments on commit 146824c

Please sign in to comment.