LaserScanAggregator.cpp
Go to the documentation of this file.
2
3#include <vector>
4
5#include <pcl/common/transforms.h>
6
8
10
11namespace armarx
12{
14 {
15 public:
16 void
17 project(pcl::PointCloud<pcl::PointXYZ>& cloud)
18 {
19 std::for_each(cloud.points.begin(), cloud.points.end(), [](auto& pt) { pt.z = 0.F; });
20 }
21 };
22
24 const LaserScanAggregator::SensorPoseMap& sensorPoses,
25 const LaserScanAggregator::RobotPoseQueue& robotPoseQueue,
26 const float minRange) :
27 sensorPoses(sensorPoses),
28 robotPoseQueue(robotPoseQueue),
29 rangeFilter(minRange),
30 cloud(new PointCloud)
31 {
32 }
33
34 void
35 LaserScanAggregator::add(const armem::LaserScanStamped& scan)
36 {
37 const auto& robot_T_sensor = sensorPoses.at(scan.header.frame);
38
39 const auto& timestamp = scan.header.timestamp;
40
41 if (not robotPoseQueue.has(timestamp.toMicroSeconds()))
42 {
43 ARMARX_INFO << "Cannot lookup pose for timestamp " << timestamp;
44 return;
45 }
46
47 const Eigen::Isometry3f map_T_robot =
48 robotPoseQueue.lookupInterpolate(timestamp.toMicroSeconds())->pose;
49 const Eigen::Isometry3f map_T_sensor = map_T_robot * robot_T_sensor;
50
51 auto cloudSensorFrame = toCartesian<Point>(scan.data);
52
53 // actually, would be more efficient to integrate filtering into toCartesian ...
54 rangeFilter.applyFilter(cloudSensorFrame);
55
56 PointCloud cloudMapFrame;
57 pcl::transformPointCloud(cloudSensorFrame, cloudMapFrame, map_T_sensor);
58
59 GroudPlaneProjector projector;
60 projector.project(cloudMapFrame);
61
62 *cloud += cloudMapFrame;
63 }
64
65 void
66 LaserScanAggregator::add(const std::vector<armem::LaserScanStamped>& scans)
67 {
68 std::for_each(
69 scans.begin(), scans.end(), [&](const armem::LaserScanStamped& scan) { add(scan); });
70 }
71
72 const LaserScanAggregator::PointCloud::Ptr&
74 {
75 return cloud;
76 }
77
78
79} // namespace armarx
std::string timestamp()
void project(pcl::PointCloud< pcl::PointXYZ > &cloud)
void add(const armem::LaserScanStamped &scan)
simox::math::InterpolatingTimeQueue< simox::math::PoseStamped > RobotPoseQueue
LaserScanAggregator(const SensorPoseMap &sensorPoses, const RobotPoseQueue &robotPoseQueue, float minRange)
const PointCloud::Ptr & pointCloud() const
std::unordered_map< std::string, Eigen::Isometry3f > SensorPoseMap
pcl::PointCloud< Point > PointCloud
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.