Skip to content

Commit 7d5d682

Browse files
authored
Merge pull request jsk-ros-pkg#2863 from furushchev/fix/jsk-ros-pkg/particle-cuboid
[ROS-O] Add ParticleCuboid::weightedAverage method
2 parents d24721c + 146824c commit 7d5d682

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

jsk_pcl_ros/include/jsk_pcl_ros/pcl/particle_cuboid.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,26 @@ namespace pcl
302302
}
303303

304304
inline jsk_pcl_ros::Cube::Ptr toCube() const
305-
{
306-
Eigen::Affine3f pose = toEigenMatrix();
307-
Eigen::Vector3f dimensions(dx, dy, dz);
308-
jsk_pcl_ros::Cube::Ptr cube(new jsk_pcl_ros::Cube(Eigen::Vector3f(pose.translation()),
309-
Eigen::Quaternionf(pose.rotation()),
310-
dimensions));
311-
return cube;
312-
}
305+
{
306+
Eigen::Affine3f pose = toEigenMatrix();
307+
Eigen::Vector3f dimensions(dx, dy, dz);
308+
jsk_pcl_ros::Cube::Ptr cube(new jsk_pcl_ros::Cube(Eigen::Vector3f(pose.translation()),
309+
Eigen::Quaternionf(pose.rotation()),
310+
dimensions));
311+
return cube;
312+
}
313313

314+
// As of https://github.com/PointCloudLibrary/pcl/pull/5538,
315+
// trackers must implements averaging method
316+
template <class InputIterator>
317+
static ParticleCuboid weightedAverage(InputIterator first, InputIterator last)
318+
{
319+
ParticleCuboid wa;
320+
for (auto cuboid = first; cuboid != last; ++cuboid) {
321+
wa = wa + *(cuboid) * cuboid->weight;
322+
}
323+
return wa;
324+
}
314325

315326
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
316327
};

0 commit comments

Comments
 (0)