measurement_buffer.hpp
Go to the documentation of this file.
1 /********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2018, Simbe Robotics, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Simbe Robotics, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * Author: Steve Macenski (steven.macenski@simberobotics.com)
36  * Purpose: buffer incoming measurements for grid
37  *********************************************************************/
38 
39 #ifndef MEASUREMENT_BUFFER_H_
40 #define MEASUREMENT_BUFFER_H_
41 
42 // measurement structs
44 // PCL
45 #include <pcl_ros/transforms.h>
46 #include <pcl/filters/voxel_grid.h>
48 #include <pcl/filters/passthrough.h>
49 // STL
50 #include <vector>
51 #include <list>
52 #include <string>
53 // ROS
54 #include <ros/ros.h>
55 #include <ros/time.h>
56 // TF
57 #include <tf2_ros/buffer.h>
59 // msgs
60 #include <sensor_msgs/PointCloud2.h>
61 #include <geometry_msgs/Quaternion.h>
62 #include <geometry_msgs/PoseStamped.h>
63 #include <geometry_msgs/TransformStamped.h>
64 // Mutex
65 #include <boost/thread.hpp>
66 
67 namespace buffer
68 {
69 
70 // conveniences for line lengths
71 typedef std::list<observation::MeasurementReading>::iterator readings_iter;
72 typedef sensor_msgs::PointCloud2::Ptr point_cloud_ptr;
73 
74 // Measurement buffer
76 {
77 public:
78  MeasurementBuffer(const std::string& topic_name, \
79  const double& observation_keep_time, \
80  const double& expected_update_rate, \
81  const double& min_obstacle_height, \
82  const double& max_obstacle_height, \
83  const double& obstacle_range, \
85  const std::string& global_frame, \
86  const std::string& sensor_frame, \
87  const double& tf_tolerance, \
88  const double& min_d, \
89  const double& max_d, \
90  const double& vFOV, \
91  const double& vFOVPadding, \
92  const double& hFOV, \
93  const double& decay_acceleration, \
94  const bool& marking, \
95  const bool& clearing, \
96  const double& voxel_size, \
97  const bool& voxel_filter, \
98  const int& voxel_min_points, \
99  const bool& enabled, \
100  const bool& clear_buffer_after_reading, \
101  const ModelType& model_type);
102 
103  ~MeasurementBuffer(void);
104 
105  // Buffers for different types of pointclouds
106  void BufferROSCloud(const sensor_msgs::PointCloud2& cloud);
107 
108  // Get measurements from the buffer
109  void GetReadings(std::vector<observation::MeasurementReading>& observations);
110 
111  // enabler setter getter
112  bool IsEnabled(void) const;
113  void SetEnabled(const bool& enabled);
114 
115  // State knoweldge if sensors are operating as expected
116  bool UpdatedAtExpectedRate(void) const;
117  void ResetLastUpdatedTime(void);
118  void ResetAllMeasurements(void);
119  bool ClearAfterReading(void);
120 
121  // Public mutex locks
122  void Lock(void);
123  void Unlock(void);
124 
125 private:
126  // Removing old observations from buffer
127  void RemoveStaleObservations(void);
128 
131  boost::recursive_mutex _lock;
134  std::list<observation::MeasurementReading> _observation_list;
141 };
142 
143 } // namespace buffer
144 
145 #endif // MEASUREMENT_BUFFER_H_
void GetReadings(std::vector< observation::MeasurementReading > &observations)
void SetEnabled(const bool &enabled)
const ros::Duration _observation_keep_time
std::list< observation::MeasurementReading > _observation_list
bool UpdatedAtExpectedRate(void) const
sensor_msgs::PointCloud2::Ptr point_cloud_ptr
MeasurementBuffer(const std::string &topic_name, const double &observation_keep_time, const double &expected_update_rate, const double &min_obstacle_height, const double &max_obstacle_height, const double &obstacle_range, tf2_ros::Buffer &tf, const std::string &global_frame, const std::string &sensor_frame, const double &tf_tolerance, const double &min_d, const double &max_d, const double &vFOV, const double &vFOVPadding, const double &hFOV, const double &decay_acceleration, const bool &marking, const bool &clearing, const double &voxel_size, const bool &voxel_filter, const int &voxel_min_points, const bool &enabled, const bool &clear_buffer_after_reading, const ModelType &model_type)
boost::recursive_mutex _lock
const ros::Duration _expected_update_rate
void BufferROSCloud(const sensor_msgs::PointCloud2 &cloud)
std::list< observation::MeasurementReading >::iterator readings_iter


spatio_temporal_voxel_layer
Author(s):
autogenerated on Wed May 3 2023 03:05:44