increment.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009, Willow Garage, Inc.
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  * 
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  * 
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef FILTERS_MEAN_H
00031 #define FILTERS_MEAN_H
00032 
00033 #include <stdint.h>
00034 #include <cstring>
00035 #include <stdio.h>
00036 
00037 #include <boost/scoped_ptr.hpp>
00038 
00039 #include "filters/filter_base.h"
00040 
00041 namespace filters
00042 {
00043 
00047 template <typename T>
00048 class IncrementFilter: public FilterBase <T>
00049 {
00050 public:
00052   IncrementFilter();
00053 
00056   ~IncrementFilter();
00057 
00058   virtual bool configure();
00059 
00064   virtual bool update( const T & data_in, T& data_out);
00065   
00066 };
00067 
00068 
00069 template <typename T>
00070 IncrementFilter<T>::IncrementFilter()
00071 {
00072 }
00073 
00074 template <typename T>
00075 bool IncrementFilter<T>::configure()
00076 {
00077     
00078   return true;
00079 }
00080 
00081 template <typename T>
00082 IncrementFilter<T>::~IncrementFilter()
00083 {
00084 }
00085 
00086 
00087 template <typename T>
00088 bool IncrementFilter<T>::update(const T & data_in, T& data_out)
00089 {
00090   data_out = data_in + 1;  
00091 
00092   return true;
00093 };
00094 
00098 template <typename T>
00099 class MultiChannelIncrementFilter: public MultiChannelFilterBase <T>
00100 {
00101 public:
00103   MultiChannelIncrementFilter();
00104 
00107   ~MultiChannelIncrementFilter();
00108 
00109   virtual bool configure();
00110 
00115   virtual bool update( const std::vector<T> & data_in, std::vector<T>& data_out);
00116   
00117 protected:
00118   using MultiChannelFilterBase<T>::number_of_channels_;           
00119 
00120   
00121   
00122 };
00123 
00124 
00125 template <typename T>
00126 MultiChannelIncrementFilter<T>::MultiChannelIncrementFilter()
00127 {
00128 }
00129 
00130 template <typename T>
00131 bool MultiChannelIncrementFilter<T>::configure()
00132 {
00133   
00134   return true;
00135 }
00136 
00137 template <typename T>
00138 MultiChannelIncrementFilter<T>::~MultiChannelIncrementFilter()
00139 {
00140 }
00141 
00142 
00143 template <typename T>
00144 bool MultiChannelIncrementFilter<T>::update(const std::vector<T> & data_in, std::vector<T>& data_out)
00145 {
00146   //  ROS_ASSERT(data_in.size() == width_);
00147   //ROS_ASSERT(data_out.size() == width_);
00148   if (data_in.size() != number_of_channels_ || data_out.size() != number_of_channels_)
00149   {
00150     ROS_ERROR("Configured with wrong size config:%d in:%d out:%d", number_of_channels_, (int)data_in.size(), (int)data_out.size());
00151     return false;
00152   }
00153 
00154 
00155   //Return each value
00156   for (uint32_t i = 0; i < number_of_channels_; i++)
00157   {
00158     data_out[i] = data_in[i] + 1;
00159   }
00160 
00161   return true;
00162 };
00163 
00164 }
00165 #endif// FILTERS_INCREMENT_H


filters
Author(s):
autogenerated on Wed Aug 26 2015 11:38:25