grid_plane.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/o2r other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef JSK_RECOGNITION_UTILS_GEO_GRID_PLANE_H_
37 #define JSK_RECOGNITION_UTILS_GEO_GRID_PLANE_H_
38 
39 #include <Eigen/Geometry>
40 #include <pcl/point_cloud.h>
41 #include <pcl/PointIndices.h>
42 #include <pcl/point_types.h>
43 #include <boost/tuple/tuple.hpp>
44 #include <vector>
45 #include <set>
46 
49 
50 #include <jsk_recognition_msgs/SimpleOccupancyGrid.h>
51 
52 namespace jsk_recognition_utils
53 {
73  class GridPlane
74  {
75  public:
77  typedef boost::tuple<int, int> IndexPair;
78  typedef std::set<IndexPair> IndexPairSet;
79  GridPlane(ConvexPolygon::Ptr plane, const double resolution);
80  virtual ~GridPlane();
81  virtual GridPlane::Ptr clone(); // shallow copy
82  virtual size_t fillCellsFromPointCloud(
83  pcl::PointCloud<pcl::PointNormal>::Ptr& cloud,
84  double distance_threshold);
85  virtual size_t fillCellsFromPointCloud(
86  pcl::PointCloud<pcl::PointNormal>::Ptr& cloud,
87  double distance_threshold,
88  std::set<int>& non_plane_indices);
89  virtual size_t fillCellsFromPointCloud(
90  pcl::PointCloud<pcl::PointNormal>::Ptr& cloud,
91  double distance_threshold,
92  double normal_threshold,
93  std::set<int>& non_plane_indices);
94  virtual void fillCellsFromCube(Cube& cube);
95  virtual double getResolution() { return resolution_; }
96  virtual jsk_recognition_msgs::SimpleOccupancyGrid toROSMsg();
102  static GridPlane fromROSMsg(
103  const jsk_recognition_msgs::SimpleOccupancyGrid& rosmsg,
104  const Eigen::Affine3f& offset);
105  virtual bool isOccupied(const IndexPair& pair);
106 
111  virtual bool isOccupied(const Eigen::Vector3f& p);
112 
117  virtual bool isOccupiedGlobal(const Eigen::Vector3f& p);
118 
124  virtual IndexPair projectLocalPointAsIndexPair(const Eigen::Vector3f& p);
125 
130  virtual Eigen::Vector3f unprojectIndexPairAsLocalPoint(const IndexPair& pair);
131 
136  virtual Eigen::Vector3f unprojectIndexPairAsGlobalPoint(const IndexPair& pair);
137 
142  virtual void addIndexPair(IndexPair pair);
143 
148  virtual GridPlane::Ptr erode(int num);
149 
154  virtual ConvexPolygon::Ptr getPolygon() { return convex_; }
155 
160  virtual GridPlane::Ptr dilate(int num);
161  protected:
163  IndexPairSet cells_;
164  double resolution_;
165  private:
166 
167  };
168 
169 }
170 
171 #endif
GridPlane(ConvexPolygon::Ptr plane, const double resolution)
Definition: grid_plane.cpp:43
virtual IndexPair projectLocalPointAsIndexPair(const Eigen::Vector3f &p)
Project 3-D point to GridPlane::IndexPair. p should be represented in local coordinates.
Definition: grid_plane.cpp:54
num
boost::shared_ptr< GridPlane > Ptr
Definition: grid_plane.h:76
virtual GridPlane::Ptr erode(int num)
Erode grid cells with specified number of pixels.
Definition: grid_plane.cpp:91
virtual Eigen::Vector3f unprojectIndexPairAsLocalPoint(const IndexPair &pair)
Unproject GridPlane::IndexPair to 3-D local point.
Definition: grid_plane.cpp:151
virtual size_t fillCellsFromPointCloud(pcl::PointCloud< pcl::PointNormal >::Ptr &cloud, double distance_threshold)
Definition: grid_plane.cpp:288
virtual GridPlane::Ptr clone()
Definition: grid_plane.cpp:144
virtual Eigen::Vector3f unprojectIndexPairAsGlobalPoint(const IndexPair &pair)
Unproject GridPlane::IndexPair to 3-D global point.
Definition: grid_plane.cpp:159
std::set< IndexPair > IndexPairSet
Definition: grid_plane.h:78
virtual bool isOccupied(const IndexPair &pair)
Definition: grid_plane.cpp:118
virtual ConvexPolygon::Ptr getPolygon()
return ConvexPolygon pointer of this instance.
Definition: grid_plane.h:154
Grid based representation of planar region.
Definition: grid_plane.h:73
virtual double getResolution()
Definition: grid_plane.h:95
virtual bool isOccupiedGlobal(const Eigen::Vector3f &p)
p should be global coordinate
Definition: grid_plane.cpp:139
static GridPlane fromROSMsg(const jsk_recognition_msgs::SimpleOccupancyGrid &rosmsg, const Eigen::Affine3f &offset)
Construct GridPlane object from jsk_recognition_msgs::SimpleOccupancyGrid.
Definition: grid_plane.cpp:320
virtual void fillCellsFromCube(Cube &cube)
Definition: grid_plane.cpp:166
ConvexPolygon::Ptr convex_
Definition: grid_plane.h:162
p
virtual void addIndexPair(IndexPair pair)
Add IndexPair to this instance.
Definition: grid_plane.cpp:65
virtual jsk_recognition_msgs::SimpleOccupancyGrid toROSMsg()
Definition: grid_plane.cpp:296
boost::tuple< int, int > IndexPair
Definition: grid_plane.h:77
virtual GridPlane::Ptr dilate(int num)
Dilate grid cells with specified number of pixels.
Definition: grid_plane.cpp:70


jsk_recognition_utils
Author(s):
autogenerated on Mon May 3 2021 03:03:03