Skip to content

Commit b0ba3a7

Browse files
committed
Merge pull request #1 from YoheiKakiuchi/groovy-devel
Adding code for using PointCloud2
2 parents 687631f + ee83ff8 commit b0ba3a7

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

include/laser_assembler/base_assembler.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@
3838
#include "tf/transform_listener.h"
3939
#include "tf/message_filter.h"
4040
#include "sensor_msgs/PointCloud.h"
41+
#include "sensor_msgs/point_cloud_conversion.h"
4142
#include "message_filters/subscriber.h"
4243

4344
#include <deque>
4445

4546
// Service
4647
#include "laser_assembler/AssembleScans.h"
48+
#include "laser_assembler/AssembleScans2.h"
4749

4850
#include "boost/thread.hpp"
4951
#include "math.h"
@@ -99,6 +101,8 @@ class BaseAssembler
99101
// ROS Input/Ouptut Handling
100102
ros::ServiceServer build_cloud_server_;
101103
ros::ServiceServer assemble_scans_server_;
104+
ros::ServiceServer build_cloud_server2_;
105+
ros::ServiceServer assemble_scans_server2_;
102106
message_filters::Subscriber<T> scan_sub_;
103107
message_filters::Connection tf_filter_connection_;
104108

@@ -109,7 +113,8 @@ class BaseAssembler
109113
//! \brief Service Callback function called whenever we need to build a cloud
110114
bool buildCloud(AssembleScans::Request& req, AssembleScans::Response& resp) ;
111115
bool assembleScans(AssembleScans::Request& req, AssembleScans::Response& resp) ;
112-
116+
bool buildCloud2(AssembleScans2::Request& req, AssembleScans2::Response& resp) ;
117+
bool assembleScans2(AssembleScans2::Request& req, AssembleScans2::Response& resp) ;
113118

114119
//! \brief Stores history of scans
115120
std::deque<sensor_msgs::PointCloud> scan_hist_ ;
@@ -175,6 +180,8 @@ BaseAssembler<T>::BaseAssembler(const std::string& max_size_param_name) : privat
175180
// ***** Start Services *****
176181
build_cloud_server_ = n_.advertiseService("build_cloud", &BaseAssembler<T>::buildCloud, this);
177182
assemble_scans_server_ = n_.advertiseService("assemble_scans", &BaseAssembler<T>::assembleScans, this);
183+
build_cloud_server2_ = n_.advertiseService("build_cloud2", &BaseAssembler<T>::buildCloud2, this);
184+
assemble_scans_server2_ = n_.advertiseService("assemble_scans2", &BaseAssembler<T>::assembleScans2, this);
178185

179186
// ***** Start Listening to Data *****
180187
// (Well, don't start listening just yet. Keep this as null until we actually start listening, when start() is called)
@@ -341,4 +348,26 @@ bool BaseAssembler<T>::assembleScans(AssembleScans::Request& req, AssembleScans:
341348
return true ;
342349
}
343350

351+
template <class T>
352+
bool BaseAssembler<T>::buildCloud2(AssembleScans2::Request& req, AssembleScans2::Response& resp)
353+
{
354+
ROS_WARN("Service 'build_cloud' is deprecated. Call 'assemble_scans' instead");
355+
return assembleScans2(req, resp);
356+
}
357+
358+
template <class T>
359+
bool BaseAssembler<T>::assembleScans2(AssembleScans2::Request& req, AssembleScans2::Response& resp)
360+
{
361+
AssembleScans::Request tmp_req;
362+
AssembleScans::Response tmp_res;
363+
tmp_req.begin = req.begin;
364+
tmp_req.end = req.end;
365+
bool ret = assembleScans(tmp_req, tmp_res);
366+
367+
if ( ret )
368+
{
369+
sensor_msgs::convertPointCloudToPointCloud2(tmp_res.cloud, resp.cloud);
370+
}
371+
return ret;
372+
}
344373
}

srv/AssembleScans2.srv

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# The time interval on which we want to aggregate scans
2+
time begin
3+
# The end of the interval on which we want to assemble scans or clouds
4+
time end
5+
---
6+
# The point cloud holding the assembled clouds or scans.
7+
# This cloud is in the frame specified by the ~fixed_frame node parameter.
8+
# cloud is empty if no scans are received in the requested interval.
9+
sensor_msgs/PointCloud2 cloud

0 commit comments

Comments
 (0)