|
5 | 5 | #include <pcl/point_types.h>
|
6 | 6 | #include <pcl/filters/voxel_grid.h>
|
7 | 7 | #include <pcl/filters/passthrough.h>
|
8 |
| -#include <boost/thread/mutex.hpp> |
9 | 8 |
|
10 | 9 | /**
|
11 | 10 | * Stores incoming point clouds in a map transforming
|
@@ -35,12 +34,11 @@ class PointCloudMapper
|
35 | 34 | cloud_sub_ = nh_.subscribe<PointCloud>("input", 1, &PointCloudMapper::callback, this);
|
36 | 35 | bool latched = true;
|
37 | 36 | cloud_pub_ = nh_priv_.advertise<PointCloud>("output", 1, latched);
|
38 |
| - pub_timer_ = nh_.createTimer(ros::Duration(3.0), &PointCloudMapper::publishCallback, this); |
| 37 | + pub_timer_ = nh_.createWallTimer(ros::WallDuration(3.0), &PointCloudMapper::publishCallback, this); |
39 | 38 | }
|
40 | 39 |
|
41 | 40 | void callback(const PointCloud::ConstPtr& cloud)
|
42 | 41 | {
|
43 |
| - m_.lock (); |
44 | 42 | ROS_INFO_STREAM("Received cloud with " << cloud->points.size() << " points.");
|
45 | 43 | PointCloud transformed_cloud;
|
46 | 44 | ros::Time points_time;
|
@@ -68,10 +66,9 @@ class PointCloudMapper
|
68 | 66 | }
|
69 | 67 |
|
70 | 68 | ROS_INFO_STREAM("Map has " << accumulated_cloud_.points.size() << " points.");
|
71 |
| - m_.unlock(); |
72 | 69 | }
|
73 | 70 |
|
74 |
| - void publishCallback(const ros::TimerEvent&) |
| 71 | + void publishCallback(const ros::WallTimerEvent&) |
75 | 72 | {
|
76 | 73 | // Publish the accumulated cloud if last publication was more than 5 seconds before.
|
77 | 74 | ros::WallDuration elapsed_time = ros::WallTime::now() - last_pub_time_;
|
@@ -135,15 +132,14 @@ class PointCloudMapper
|
135 | 132 | ros::NodeHandle nh_;
|
136 | 133 | ros::NodeHandle nh_priv_;
|
137 | 134 |
|
138 |
| - ros::Timer pub_timer_; |
| 135 | + ros::WallTimer pub_timer_; |
139 | 136 |
|
140 | 137 | ros::Subscriber cloud_sub_;
|
141 | 138 | ros::Publisher cloud_pub_;
|
142 | 139 |
|
143 | 140 | std::string fixed_frame_;
|
144 | 141 | tf::TransformListener tf_listener_;
|
145 | 142 | PointCloud accumulated_cloud_;
|
146 |
| - boost::mutex m_; |
147 | 143 | ros::WallTime last_pub_time_;
|
148 | 144 | };
|
149 | 145 |
|
|
0 commit comments