Fawkes API Fawkes Development Version

filter.cpp

00001 
00002 /***************************************************************************
00003  *  filter.cpp - Laser data filter interface
00004  *
00005  *  Created: Fri Oct 10 17:12:29 2008
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #include "filter.h"
00024 #include <cstdlib>
00025 
00026 /** @class LaserDataFilter "filter.h"
00027  * Laser data filter.
00028  * With this interface laser filter are described. These filters take laser
00029  * readings as input, mangle them and return a new array of filtered laser data.
00030  * @author Tim Niemueller
00031  *
00032  * @fn void LaserDataFilter::filter(const float *data, unsigned int data_size) = 0
00033  * Filter the incoming data.
00034  * Function shall create the _filtered_data float array with the same size as
00035  * the incoming data and write filtered data to this interface or copy through
00036  * the original value if the filter does not apply.
00037  * @param data the laser data
00038  * @param data_size the number of elements in the data array
00039  */
00040 
00041 /** @var LaserDataFilter::_filtered_data
00042  * Allocate a float array and assign your filtered values or copy through the
00043  * original values if unmodified.
00044  */
00045 
00046 /** @var LaserDataFilter::_filtered_data_size
00047  * Size in bytes of _filtered_data.
00048  */
00049 
00050 /** @var LaserDataFilter::_free_filtered_data
00051  * True to have _filtered_data deleted automatically on destruction.
00052  */
00053 
00054 /** Constructor. */
00055 LaserDataFilter::LaserDataFilter()
00056 {
00057   _filtered_data      = NULL;
00058   _filtered_data_size = 0;
00059   _free_filtered_data = true;
00060 }
00061 
00062 
00063 /** Virtual empty destructor. */
00064 LaserDataFilter::~LaserDataFilter()
00065 {
00066   if (_filtered_data && _free_filtered_data)  free(_filtered_data);
00067 }
00068 
00069 
00070 /** Get filtered data array
00071  * @return a float array of the same size as the last array given to filter()
00072  * or NULL if filter() was never called.
00073  */
00074 float *
00075 LaserDataFilter::filtered_data()
00076 {
00077   return _filtered_data;
00078 }
00079 
00080 
00081 /** Get size of filtered data array
00082  * @return size of filtered data array or 0 if filter() was never called.
00083  */
00084 unsigned int
00085 LaserDataFilter::filtered_data_size()
00086 {
00087   return _filtered_data_size;
00088 }
00089 
00090 
00091 /** Get filtered data array and size.
00092  * @param data upon return contains pointer to filtered data
00093  * @param data_size upon return contains data size
00094  */
00095 void
00096 LaserDataFilter::filtered_data(float *&data, unsigned int &data_size)
00097 {
00098   data      = _filtered_data;
00099   data_size = _filtered_data_size;
00100 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends