~gimaker/peekabot/og3d-caching

« back to all changes in this revision

Viewing changes to src/OccupancyGrid3D.hh

  • Committer: Staffan Gimåker
  • Date: 2010-06-08 14:51:28 UTC
  • Revision ID: staffan@gimaker.se-20100608145128-df8d8it7ijxw03ib
Added experimental support for 3D occupancy grids.

Occupied cells (occupancy value larger than 0.5) are drawn as opaque cubes;
free and unexplored is not drawn at all.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright Staffan Gimåker 2007-2010.
 
3
 *
 
4
 * ---
 
5
 *
 
6
 * This file is part of peekabot.
 
7
 *
 
8
 * peekabot is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 3 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * peekabot is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#ifndef PEEKABOT_OCCUPANCY_GRID_3D_HH_INCLUDED
 
23
#define PEEKABOT_OCCUPANCY_GRID_3D_HH_INCLUDED
 
24
 
 
25
#include <vector>
 
26
#include <Eigen/Core>
 
27
 
 
28
#include "SceneObject.hh"
 
29
#include "ScalableObject.hh"
 
30
#include "ObjectVisitor.hh"
 
31
#include "HandlerInformer.hh"
 
32
 
 
33
 
 
34
namespace peekabot
 
35
{
 
36
    class ScopedHandler;
 
37
 
 
38
    class OccupancyGrid3D : public SceneObject,
 
39
                            public ScalableObject
 
40
    {
 
41
    public:
 
42
        OccupancyGrid3D(float cell_size) throw();
 
43
 
 
44
        /** \brief Construct object from XML data.
 
45
         */
 
46
        OccupancyGrid3D(ScopedHandler *handler);
 
47
 
 
48
        /** \brief Method for accepting \c ObjectVisitor objects.
 
49
         *
 
50
         * This method performs an automatic type cast by calling the \c visit()
 
51
         *  method of the visitor, allowing it to perform type-dependent task.
 
52
         */
 
53
        virtual void accept(ObjectVisitor *visitor) throw();
 
54
 
 
55
        float get_cell_size() const throw();
 
56
 
 
57
        // belief = -1 <=> clear cell
 
58
        void set_cell(const Eigen::Vector3f &x, float belief) throw();
 
59
 
 
60
        void set_cells(const std::vector<std::pair<Eigen::Vector3f, float> > &cells) throw();
 
61
 
 
62
        /// \name Signals
 
63
        /// @{
 
64
 
 
65
        typedef boost::signal<
 
66
            void (OccupancyGrid3D *object,
 
67
                  const std::vector<std::pair<Eigen::Vector3f, float> > &cells)
 
68
            > OnCellsSet;
 
69
 
 
70
        OnCellsSet m_on_cells_set;
 
71
 
 
72
        /// @}
 
73
 
 
74
    private:
 
75
        /// \name XML handler methods
 
76
        /// @{
 
77
 
 
78
        /** \brief Element start handler for XML parsing.
 
79
         */
 
80
        static void start_handler(
 
81
            const std::string & name,
 
82
            XMLHandler::AttributeMap &attributes,
 
83
            ScopedHandler *handler) throw();
 
84
 
 
85
        /// @}
 
86
 
 
87
    private:
 
88
        //static HandlerInformer ms_handler_informer;
 
89
 
 
90
        float m_cell_size;
 
91
    };
 
92
}
 
93
 
 
94
#endif // PEEKABOT_OCCUPANCY_GRID_3D_HH_INCLUDED