octomap_filter_base.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * \file
00003  *
00004  * $Id:$
00005  *
00006  * Copyright (C) Brno University of Technology
00007  *
00008  * This file is part of software developed by dcgm-robotics@FIT group.
00009  *
00010  * Author: Vit Stancl (stancl@fit.vutbr.cz)
00011  * Supervised by: Michal Spanel (spanel@fit.vutbr.cz)
00012  * Date: dd/mm/2012
00013  *
00014  * This file is free software: you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as published by
00016  * the Free Software Foundation, either version 3 of the License, or
00017  * (at your option) any later version.
00018  *
00019  * This file is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU Lesser General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this file.  If not, see <http://www.gnu.org/licenses/>.
00026  */
00027 
00028 #include <srs_env_model/but_server/plugins/octomap_plugin_tools/octomap_filter_base.h>
00029 
00030 srs_env_model::COcTreeFilterBase::COcTreeFilterBase( const std::string & octree_frame_id, ERunMode mode /*= FILTER_ALLWAYS*/ )
00031 : m_mode(mode)
00032 , m_framesSkipped(0)
00033 , m_framesCount(0)
00034 , m_lap( m_timer.elapsed_min() )
00035 , m_treeFrameId( octree_frame_id )
00036 {
00037         m_timer.restart();
00038 }
00039 
00043 void srs_env_model::COcTreeFilterBase::setFrameSkip( unsigned skip )
00044 {
00045         m_framesSkipped = skip;
00046 }
00047 
00052 bool srs_env_model::COcTreeFilterBase::setTimerLap( double lap )
00053 {
00054         if( lap > m_timer.elapsed_min() && lap < m_timer.elapsed_max() )
00055         {
00056                 m_lap = lap;
00057                 m_timer.restart();
00058                 return true;
00059         }
00060 
00061         return false;
00062 }
00063 
00067 void srs_env_model::COcTreeFilterBase::filter( tButServerOcTree & tree, bool bPruneAfterFinish /*= true*/ )
00068 {
00069         ++m_framesCount;
00070 
00071         if( useFrame() )
00072         {
00073                 filterInternal( tree );
00074                 if(bPruneAfterFinish)
00075                         tree.prune();
00076         }
00077 }
00078 
00082 bool srs_env_model::COcTreeFilterBase::useFrame()
00083 {
00084         switch( m_mode )
00085         {
00086         case FILTER_ALLWAYS:
00087 //              std::cerr << "Allways" << std::endl;
00088                 return true;
00089 
00090         case FILTER_TEST_FRAME:
00091 //              std::cerr << "Frame" << std::endl;
00092                 if( m_framesCount > m_framesSkipped )
00093                 {
00094                         m_framesCount = 0;
00095                         return true;
00096                 }
00097 
00098                 return false;
00099 
00100         case FILTER_TEST_TIME:
00101 //              std::cerr << "Time. Elapsed: " << m_timer.elapsed() << std::endl;
00102                 if( m_timer.elapsed() > m_lap)
00103                 {
00104 //                      std::cerr << "Time elapsed: " << m_timer.elapsed() << ", lap: " << m_lap << std::endl;
00105                         m_timer.restart();
00106                         return true;
00107                 }
00108 
00109                 return false;
00110 
00111         default:
00112                 return false;
00113         }
00114 
00115         return false;
00116 }


srs_env_model
Author(s): Vit Stancl (stancl@fit.vutbr.cz), Tomas Lokaj, Jan Gorig, Michal Spanel (spanel@fit.vutbr.cz)
autogenerated on Sun Jan 5 2014 11:50:48