• Main Page
  • Related Pages
  • Classes
  • Files
  • File List

src/OccupancyGrid2D.hh

00001 /*
00002  * Copyright Staffan Gimåker 2007-2010.
00003  *
00004  * ---
00005  *
00006  * This file is part of peekabot.
00007  *
00008  * peekabot is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * peekabot is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 #ifndef PEEKABOT_OCCUPANCY_GRID_2D_HH_INCLUDED
00023 #define PEEKABOT_OCCUPANCY_GRID_2D_HH_INCLUDED
00024 
00025 #include <vector>
00026 #include <Eigen/Core>
00027 
00028 #include "SceneObject.hh"
00029 #include "ObjectVisitor.hh"
00030 #include "HandlerInformer.hh"
00031 
00032 
00033 namespace peekabot
00034 {
00035     class ScopedHandler;
00036 
00037     class OccupancyGrid2D : public SceneObject
00038     {
00039     public:
00044         OccupancyGrid2D(float cell_size) throw();
00045 
00048         OccupancyGrid2D(ScopedHandler *handler);
00049 
00050         virtual void accept(ObjectVisitor *visitor) throw();
00051 
00052         virtual ObjectType get_object_type() const;
00053 
00054         float get_cell_size() const;
00055 
00056         const RGBColor &get_unoccupied_color() const;
00057 
00058         void set_unoccupied_color(const RGBColor &color);
00059 
00060         const RGBColor &get_occupied_color() const;
00061 
00062         void set_occupied_color(const RGBColor &color);
00063 
00064         // belief = -1 <=> clear cell
00065         void set_cell(const Eigen::Vector2f &x, float belief) throw();
00066 
00067         void set_cells(const std::vector<std::pair<Eigen::Vector2f, float> > &cells) throw();
00068 
00071 
00072         typedef boost::signals2::signal<
00073             void (const std::vector<std::pair<Eigen::Vector2f, float> > &cells)
00074             > CellsSetSignal;
00075 
00076         typedef boost::signals2::signal<void ()> UnoccupiedColorSetSignal;
00077 
00078         typedef boost::signals2::signal<void ()> OccupiedColorSetSignal;
00079 
00080         inline CellsSetSignal &cells_set_signal() const
00081         {
00082             return m_cells_set_signal;
00083         }
00084 
00085         inline UnoccupiedColorSetSignal &unoccupied_color_set_signal() const
00086         {
00087             return m_unoccupied_color_set_signal;
00088         }
00089 
00090         inline OccupiedColorSetSignal &occupied_color_set_signal() const
00091         {
00092             return m_occupied_color_set_signal;
00093         }
00094 
00096 
00097     protected:
00098         virtual PropMap &get_prop_adapters();
00099 
00100     private:
00101         static void create_prop_adapters(PropMap &adapters);
00102 
00105 
00108         static void start_handler(
00109             const std::string & name,
00110             XMLHandler::AttributeMap &attributes,
00111             ScopedHandler *handler) throw();
00112 
00114 
00115     private:
00116         //static HandlerInformer ms_handler_informer;
00117 
00118         float m_cell_size;
00119 
00120         RGBColor m_unoccupied_color;
00121         RGBColor m_occupied_color;
00122 
00123         mutable CellsSetSignal m_cells_set_signal;
00124         mutable UnoccupiedColorSetSignal m_unoccupied_color_set_signal;
00125         mutable OccupiedColorSetSignal m_occupied_color_set_signal;
00126     };
00127 }
00128 
00129 #endif // PEEKABOT_OCCUPANCY_GRID_2D_HH_INCLUDED

Generated on Sun Jan 30 2011 for peekabot by  doxygen 1.7.1