Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef JSK_RECOGNITION_UTILS_GRID_MAP_H_
00036 #define JSK_RECOGNITION_UTILS_GRID_MAP_H_
00037 #include <jsk_recognition_msgs/SparseOccupancyGrid.h>
00038
00039 #include "jsk_recognition_utils/grid_index.h"
00040 #include "jsk_recognition_utils/grid_line.h"
00041 #include <pcl/point_types.h>
00042 #include <pcl/point_cloud.h>
00043 #include <map>
00044 #include <set>
00045 #include <Eigen/Geometry>
00046 #include <boost/tuple/tuple.hpp>
00047
00048 #include "jsk_recognition_utils/geo_util.h"
00049 #include <opencv2/opencv.hpp>
00050
00051 namespace jsk_recognition_utils
00052 {
00053
00054
00055 class GridMap
00056 {
00057 public:
00058 typedef boost::shared_ptr<GridMap> Ptr;
00059 typedef std::set<int> RowIndices;
00060 typedef std::map<int, RowIndices> Columns;
00061 typedef Columns::iterator ColumnIterator;
00062 typedef std::set<int>::iterator RowIterator;
00063 GridMap(double resolution, const std::vector<float>& coefficients);
00064 virtual ~GridMap();
00065 virtual void registerPoint(const pcl::PointXYZRGB& point);
00066 virtual std::vector<GridIndex::Ptr> registerLine(const pcl::PointXYZRGB& from, const pcl::PointXYZRGB& to);
00067 virtual void removeIndex(const GridIndex::Ptr& index);
00068 virtual void registerPointCloud(pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud);
00069 virtual GridIndex::Ptr registerIndex(const GridIndex::Ptr& index);
00070 virtual GridIndex::Ptr registerIndex(const int x, const int y);
00071 virtual void pointToIndex(const pcl::PointXYZRGB& point, GridIndex::Ptr index);
00072 virtual void pointToIndex(const Eigen::Vector3f& point, GridIndex::Ptr index);
00073 virtual void indicesToPointCloud(const std::vector<GridIndex::Ptr>& indices,
00074 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud);
00075 virtual bool getValue(const GridIndex::Ptr& index);
00076 virtual bool getValue(const GridIndex& index);
00077 virtual bool getValue(const int x, const int y);
00078 virtual void gridToPoint(GridIndex::Ptr index, Eigen::Vector3f& pos);
00079 virtual void gridToPoint(const GridIndex& index, Eigen::Vector3f& pos);
00080 virtual void gridToPoint2(const GridIndex& index, Eigen::Vector3f& pos);
00081 virtual void fillRegion(const Eigen::Vector3f& start, std::vector<GridIndex::Ptr>& output);
00082 virtual void fillRegion(const GridIndex::Ptr start, std::vector<GridIndex::Ptr>& output);
00083
00084 virtual void originPose(Eigen::Affine3f& output);
00085 virtual void originPose(Eigen::Affine3d& output);
00086 virtual void toMsg(jsk_recognition_msgs::SparseOccupancyGrid& grid);
00087 virtual Plane toPlane();
00088 virtual Plane::Ptr toPlanePtr();
00089 virtual void vote();
00090 virtual unsigned int getVoteNum();
00091 virtual void setGeneration(unsigned int generation);
00092 virtual unsigned int getGeneration();
00093 virtual std::vector<float> getCoefficients();
00094 virtual bool isBinsOccupied(const Eigen::Vector3f& p);
00095 virtual int normalizedWidth();
00096 virtual int normalizedHeight();
00097 virtual boost::tuple<int, int> minMaxX();
00098 virtual boost::tuple<int, int> minMaxY();
00099 virtual int widthOffset();
00100 virtual int heightOffset();
00101 virtual int normalizedIndex(int width_offset, int height_offset,
00102 int step,
00103 int elem_size,
00104 int original_x, int original_y);
00105 virtual cv::Mat toImage();
00106 virtual bool check4Neighbor(int x, int y);
00107 virtual ConvexPolygon::Ptr toConvexPolygon();
00108 virtual pcl::PointCloud<pcl::PointXYZ>::Ptr toPointCloud();
00109 virtual void decrease(int i);
00110 virtual void add(GridMap& other);
00111 protected:
00112 virtual void decreaseOne();
00113
00114 double resolution_;
00115 Eigen::Vector3f O_;
00116
00117
00118 Eigen::Vector3f normal_;
00119 double d_;
00120
00121 Eigen::Vector3f ex_, ey_;
00122
00123 std::vector<GridLine::Ptr> lines_;
00124 Columns data_;
00125 unsigned int vote_;
00126 unsigned int generation_;
00127 private:
00128 };
00129
00130 }
00131
00132 #endif