pcdfilter_pa_ros_filter.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 *                                                                             *
00003 * pcdfilter_pa_ros_filter.h                                                   *
00004 * =========================                                                   *
00005 *                                                                             *
00006 *******************************************************************************
00007 *                                                                             *
00008 * github repository                                                           *
00009 *   https://github.com/peterweissig/ros_pcdfilter                             *
00010 *                                                                             *
00011 * Chair of Automation Technology, Technische Universität Chemnitz             *
00012 *   https://www.tu-chemnitz.de/etit/proaut                                    *
00013 *                                                                             *
00014 *******************************************************************************
00015 *                                                                             *
00016 * New BSD License                                                             *
00017 *                                                                             *
00018 * Copyright (c) 2015-2017, Peter Weissig, Technische Universität Chemnitz     *
00019 * All rights reserved.                                                        *
00020 *                                                                             *
00021 * Redistribution and use in source and binary forms, with or without          *
00022 * modification, are permitted provided that the following conditions are met: *
00023 *     * Redistributions of source code must retain the above copyright        *
00024 *       notice, this list of conditions and the following disclaimer.         *
00025 *     * Redistributions in binary form must reproduce the above copyright     *
00026 *       notice, this list of conditions and the following disclaimer in the   *
00027 *       documentation and/or other materials provided with the distribution.  *
00028 *     * Neither the name of the Technische Universität Chemnitz nor the       *
00029 *       names of its contributors may be used to endorse or promote products  *
00030 *       derived from this software without specific prior written permission. *
00031 *                                                                             *
00032 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" *
00033 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE   *
00034 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE  *
00035 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY      *
00036 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  *
00037 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR          *
00038 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER  *
00039 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          *
00040 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY   *
00041 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
00042 * DAMAGE.                                                                     *
00043 *                                                                             *
00044 ******************************************************************************/
00045 
00046 #ifndef __PCD_FILTER_PA_ROS_FILTER_H
00047 #define __PCD_FILTER_PA_ROS_FILTER_H
00048 
00049 // local headers
00050 #include "pcdfilter_pa/pcdfilter_pa_filter.h"
00051 
00052 // ros headers
00053 #include <tf/transform_datatypes.h>
00054 #include <tf/transform_listener.h>
00055 
00056 // additional libraries
00057 #include <opencv2/highgui/highgui.hpp>
00058 
00059 // standard headers
00060 #include <string>
00061 #include <vector>
00062 
00063 //**************************[cPcdFilterPaRosFilter]****************************
00064 class cPcdFilterPaRosFilter {
00065   public:
00066     enum eFiltertype {
00067         ftNONE     = cPcdFilterPaFilter::ftNONE,
00068         ftCUBE     = cPcdFilterPaFilter::ftCUBE,
00069         ftSPHERE   = cPcdFilterPaFilter::ftSPHERE,
00070         ftBLOCK    = cPcdFilterPaFilter::ftBLOCK,
00071         ftCYLINDER = cPcdFilterPaFilter::ftCYLINDER,
00072         ftCONE     = cPcdFilterPaFilter::ftCONE,
00073         ftLINK
00074     };
00075     enum {
00076         COUNT_PARAMETER = 3,
00077         COUNT_FRAME     = 2
00078     };
00079 
00080     cPcdFilterPaRosFilter();
00081     cPcdFilterPaRosFilter(const cPcdFilterPaRosFilter &other);
00082     cPcdFilterPaRosFilter& operator = (
00083       const cPcdFilterPaRosFilter &other);
00084 
00086     bool inverse_;
00087 
00089     eFiltertype type_;
00090 
00092     bool required_;
00093 
00095     double parameter_[COUNT_PARAMETER];
00096 
00098     std::string frame_[COUNT_FRAME];
00099 
00100     // additional offsets relative to frames
00101     tf::Transform offset_[COUNT_FRAME];
00102 
00104     std::string comment_;
00105 
00107     bool fromString(const std::string &filter);
00109     std::string toString(void) const;
00110 
00112     void reset(void);
00113 
00115     bool isValid(void) const;
00116 
00117   private:
00119     bool _skipWhitespace(const std::string &str, int &pos) const;
00120 
00122     bool _checkSymbol(const std::string &str, int &pos,
00123         const char symbol) const;
00124 
00126     std::string _getValue(const std::string &str, int &pos) const;
00127 
00129     std::string _getComment(const std::string &str) const;
00130 
00132     std::string _floatToStr(const double &value) const;
00133 
00135     bool _StrToFloat(const std::string &str, double &value) const;
00136 };
00137 
00138 //**************************[cPcdFilterPaRosFilters]***************************
00139 class cPcdFilterPaRosFilters {
00140   public:
00141     cPcdFilterPaRosFilters();
00142 
00143 
00144     // adds a new filter
00145     bool add(std::string filter);
00146 
00147     // clears all filters
00148     void clear(void);
00149 
00150     // return all filters
00151     std::vector<std::string> get(void) const;
00152 
00153     // returns simple filters based on numbers instead of frames
00154     bool update( const tf::TransformListener &tf_listener,
00155       const std::string base_frame, const ros::Time time,
00156       std::vector<cPcdFilterPaFilter> &result) const;
00157 
00158     // returns last added filter (also includes erroneous filters)
00159     std::string getLast(void) const;
00160 
00161     // return number of elements
00162     int size(void) const;
00163 
00164     // access single element
00165     cPcdFilterPaRosFilter& operator[](int i);
00166     // access single element (const)
00167     const cPcdFilterPaRosFilter& operator[](int i) const;
00168 
00169     // time before tf lookup fails - for updating filters
00170     double tf_lookup_time_;
00171 
00172   protected:
00173     // get tansform between two tfs
00174     double update_transform(const tf::Transform &start,
00175       const tf::Transform &goal, tf::Transform &result,
00176       const double relative_pos = 0.0) const;
00177 
00178 
00179     std::vector<cPcdFilterPaRosFilter> filters_;
00180 
00181     cPcdFilterPaRosFilter last_filter_;
00182 };
00183 
00184 #endif // __PCD_FILTER_PA_ROS_FILTER_H


pcdfilter_pa
Author(s):
autogenerated on Thu Aug 3 2017 03:00:01