laser_scan_assembler_srv.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 
37 #include "sensor_msgs/LaserScan.h"
39 #include "filters/filter_chain.h"
40 
41 using namespace laser_geometry;
42 using namespace std ;
43 
44 namespace laser_assembler
45 {
46 
57 class LaserScanAssemblerSrv : public BaseAssemblerSrv<sensor_msgs::LaserScan>
58 {
59 public:
60  LaserScanAssemblerSrv() : filter_chain_("sensor_msgs::LaserScan")
61  {
62  // ***** Set Laser Projection Method *****
63  private_ns_.param("ignore_laser_skew", ignore_laser_skew_, true);
64 
65  // configure the filter chain from the parameter server
66  filter_chain_.configure("filters", private_ns_);
67  }
68 
70  {
71 
72  }
73 
74  unsigned int GetPointsInScan(const sensor_msgs::LaserScan& scan)
75  {
76  return scan.ranges.size();
77  }
78 
79  void ConvertToCloud(const string& fixed_frame_id, const sensor_msgs::LaserScan& scan_in, sensor_msgs::PointCloud& cloud_out)
80  {
81  // apply filters on laser scan
82  filter_chain_.update (scan_in, scan_filtered_);
83 
84  // convert laser scan to point cloud
85  if (ignore_laser_skew_) // Do it the fast (approximate) way
86  {
87  projector_.projectLaser(scan_filtered_, cloud_out);
88  if (cloud_out.header.frame_id != fixed_frame_id)
89  tf_->transformPointCloud(fixed_frame_id, cloud_out, cloud_out);
90  }
91  else // Do it the slower (more accurate) way
92  {
94  projector_.transformLaserScanToPointCloud (fixed_frame_id, scan_filtered_, cloud_out, *tf_, mask);
95  }
96  return;
97  }
98 
99 private:
102 
104  mutable sensor_msgs::LaserScan scan_filtered_;
105 
106 };
107 
108 }
109 
110 using namespace laser_assembler ;
111 
112 int main(int argc, char **argv)
113 {
114  ros::init(argc, argv, "laser_scan_assembler");
115  ros::NodeHandle n;
116  ROS_WARN("The laser_scan_assembler_srv is deprecated. Please switch to "
117  "using the laser_scan_assembler. Documentation is available at "
118  "http://www.ros.org/wiki/laser_assembler");
119  LaserScanAssemblerSrv pc_assembler;
120  pc_assembler.start();
121  ros::spin();
122 
123  return 0;
124 }
Maintains a history of point clouds and generates an aggregate point cloud upon request.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Maintains a history of laser scans and generates a point cloud upon request.
#define ROS_WARN(...)
ROSCPP_DECL void spin(Spinner &spinner)
unsigned int GetPointsInScan(const sensor_msgs::LaserScan &scan)
Returns the number of points in the current scan.
filters::FilterChain< sensor_msgs::LaserScan > filter_chain_
void ConvertToCloud(const string &fixed_frame_id, const sensor_msgs::LaserScan &scan_in, sensor_msgs::PointCloud &cloud_out)
int main(int argc, char **argv)
void start()
Tells the assembler to start listening to input data It is possible that a derived class needs to ini...


laser_assembler
Author(s): Vijay Pradeep
autogenerated on Thu Jun 27 2019 19:56:21