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/or 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:
164  double resolution_;
165  private:
166 
167  };
168 
169 }
170 
171 #endif
boost::shared_ptr
jsk_recognition_utils::GridPlane::toROSMsg
virtual jsk_recognition_msgs::SimpleOccupancyGrid toROSMsg()
Definition: grid_plane.cpp:296
jsk_recognition_utils::GridPlane::fillCellsFromPointCloud
virtual size_t fillCellsFromPointCloud(pcl::PointCloud< pcl::PointNormal >::Ptr &cloud, double distance_threshold)
Definition: grid_plane.cpp:288
polygon_array_publisher.p
p
Definition: polygon_array_publisher.py:123
jsk_recognition_utils::GridPlane::addIndexPair
virtual void addIndexPair(IndexPair pair)
Add IndexPair to this instance.
Definition: grid_plane.cpp:65
jsk_recognition_utils
Definition: color_utils.h:41
jsk_recognition_utils::GridPlane::clone
virtual GridPlane::Ptr clone()
Definition: grid_plane.cpp:144
jsk_recognition_utils::GridPlane::getResolution
virtual double getResolution()
Definition: grid_plane.h:159
jsk_recognition_utils::GridPlane::unprojectIndexPairAsGlobalPoint
virtual Eigen::Vector3f unprojectIndexPairAsGlobalPoint(const IndexPair &pair)
Unproject GridPlane::IndexPair to 3-D global point.
Definition: grid_plane.cpp:159
jsk_recognition_utils::GridPlane::projectLocalPointAsIndexPair
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
jsk_recognition_utils::GridPlane::IndexPairSet
std::set< IndexPair > IndexPairSet
Definition: grid_plane.h:142
jsk_recognition_utils::GridPlane::fromROSMsg
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
jsk_recognition_utils::GridPlane::isOccupied
virtual bool isOccupied(const IndexPair &pair)
Definition: grid_plane.cpp:118
jsk_recognition_utils::GridPlane::cells_
IndexPairSet cells_
Definition: grid_plane.h:227
jsk_recognition_utils::GridPlane::Ptr
boost::shared_ptr< GridPlane > Ptr
Definition: grid_plane.h:140
jsk_recognition_utils::GridPlane::resolution_
double resolution_
Definition: grid_plane.h:228
jsk_recognition_utils::GridPlane::~GridPlane
virtual ~GridPlane()
Definition: grid_plane.cpp:49
jsk_recognition_utils::GridPlane::IndexPair
boost::tuple< int, int > IndexPair
Definition: grid_plane.h:141
jsk_recognition_utils::GridPlane::getPolygon
virtual ConvexPolygon::Ptr getPolygon()
return ConvexPolygon pointer of this instance.
Definition: grid_plane.h:218
jsk_recognition_utils::GridPlane::unprojectIndexPairAsLocalPoint
virtual Eigen::Vector3f unprojectIndexPairAsLocalPoint(const IndexPair &pair)
Unproject GridPlane::IndexPair to 3-D local point.
Definition: grid_plane.cpp:151
jsk_recognition_utils::GridPlane::erode
virtual GridPlane::Ptr erode(int num)
Erode grid cells with specified number of pixels.
Definition: grid_plane.cpp:91
convex_polygon.h
cube.h
jsk_recognition_utils::GridPlane::isOccupiedGlobal
virtual bool isOccupiedGlobal(const Eigen::Vector3f &p)
p should be global coordinate
Definition: grid_plane.cpp:139
jsk_recognition_utils::GridPlane::fillCellsFromCube
virtual void fillCellsFromCube(Cube &cube)
Definition: grid_plane.cpp:166
jsk_recognition_utils::GridPlane::convex_
ConvexPolygon::Ptr convex_
Definition: grid_plane.h:226
jsk_recognition_utils::GridPlane::GridPlane
GridPlane(ConvexPolygon::Ptr plane, const double resolution)
Definition: grid_plane.cpp:43
jsk_recognition_utils::GridPlane::dilate
virtual GridPlane::Ptr dilate(int num)
Dilate grid cells with specified number of pixels.
Definition: grid_plane.cpp:70
jsk_recognition_utils::ConvexPolygon::Ptr
boost::shared_ptr< ConvexPolygon > Ptr
Definition: convex_polygon.h:115


jsk_recognition_utils
Author(s):
autogenerated on Tue Jan 7 2025 04:04:52