cube.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_CUBE_H_
37 #define JSK_RECOGNITION_UTILS_GEO_CUBE_H_
38 
41 #include <jsk_recognition_msgs/BoundingBoxArray.h>
42 
43 namespace jsk_recognition_utils
44 {
45  class Cube
46  {
47  public:
49  Cube(const Eigen::Vector3f& pos, const Eigen::Quaternionf& rot);
50  Cube(const Eigen::Vector3f& pos, const Eigen::Quaternionf& rot,
51  const std::vector<double>& dimensions);
52  Cube(const Eigen::Vector3f& pos, const Eigen::Quaternionf& rot,
53  const Eigen::Vector3f& dimensions);
54  Cube(const Eigen::Vector3f& pos, // centroid
55  const Line& line_a, const Line& line_b, const Line& line_c);
56  Cube(const jsk_recognition_msgs::BoundingBox& box);
57  virtual ~Cube();
58  std::vector<Segment::Ptr> edges();
60  std::vector<double> getDimensions() const { return dimensions_; };
61  void setDimensions(const std::vector<double>& new_dimensions) {
62  dimensions_[0] = new_dimensions[0];
63  dimensions_[1] = new_dimensions[1];
64  dimensions_[2] = new_dimensions[2];
65  }
66  jsk_recognition_msgs::BoundingBox toROSMsg();
67 
76 
81  Vertices transformVertices(const Eigen::Affine3f& pose_offset);
82 
88  std::vector<Polygon::Ptr> faces();
89 
98  virtual Eigen::Vector3f nearestPoint(const Eigen::Vector3f& p,
99  double& distance);
100  protected:
101  Eigen::Vector3f pos_;
102  Eigen::Quaternionf rot_;
103  std::vector<double> dimensions_;
104 
109  virtual Polygon::Ptr buildFace(const Eigen::Vector3f v0,
110  const Eigen::Vector3f v1,
111  const Eigen::Vector3f v2,
112  const Eigen::Vector3f v3);
113 
118  virtual Eigen::Vector3f buildVertex(double i, double j, double k);
119 
120  private:
121 
122  };
123 }
124 
125 #endif
jsk_recognition_utils::Cube::pos_
Eigen::Vector3f pos_
Definition: cube.h:165
jsk_recognition_utils::Cube::buildFace
virtual Polygon::Ptr buildFace(const Eigen::Vector3f v0, const Eigen::Vector3f v1, const Eigen::Vector3f v2, const Eigen::Vector3f v3)
A helper method to build polygon from 4 vertices.
Definition: cube.cpp:243
jsk_recognition_utils::Cube::toROSMsg
jsk_recognition_msgs::BoundingBox toROSMsg()
Definition: cube.cpp:203
boost::shared_ptr
polygon_array_publisher.p
p
Definition: polygon_array_publisher.py:123
jsk_recognition_utils::Cube::~Cube
virtual ~Cube()
Definition: cube.cpp:118
jsk_recognition_utils
Definition: color_utils.h:41
polygon.h
jsk_recognition_utils::Cube::edges
std::vector< Segment::Ptr > edges()
Definition: cube.cpp:123
jsk_recognition_utils::Cube::nearestPoint
virtual Eigen::Vector3f nearestPoint(const Eigen::Vector3f &p, double &distance)
compute minimum distance from point p to cube surface.
Definition: cube.cpp:292
jsk_recognition_utils::Cube::buildVertex
virtual Eigen::Vector3f buildVertex(double i, double j, double k)
A helper method to build vertex from x-y-z relatiev coordinates.
Definition: cube.cpp:284
jsk_recognition_utils::Cube::rot_
Eigen::Quaternionf rot_
Definition: cube.h:166
jsk_recognition_utils::Cube::setDimensions
void setDimensions(const std::vector< double > &new_dimensions)
Definition: cube.h:125
jsk_recognition_utils::Cube::Ptr
boost::shared_ptr< Cube > Ptr
Definition: cube.h:112
jsk_recognition_utils::Cube::vertices
Vertices vertices()
returns vertices as an array of Eigen::Vectro3f. The order of the vertices is: [1,...
Definition: cube.cpp:219
convex_polygon.h
jsk_recognition_utils::Cube::transformVertices
Vertices transformVertices(const Eigen::Affine3f &pose_offset)
returns vertices transformed by pose_offset.
Definition: cube.cpp:233
jsk_recognition_utils::Cube::getDimensions
std::vector< double > getDimensions() const
Definition: cube.h:124
jsk_recognition_utils::Cube::faces
std::vector< Polygon::Ptr > faces()
returns all the 6 faces as Polygon::Ptr. TODO: is it should be ConvexPolygon?
Definition: cube.cpp:256
jsk_recognition_utils::Polygon::Ptr
boost::shared_ptr< Polygon > Ptr
Definition: polygon.h:122
jsk_recognition_utils::ConvexPolygon::Ptr
boost::shared_ptr< ConvexPolygon > Ptr
Definition: convex_polygon.h:115
jsk_recognition_utils::Cube::intersectConvexPolygon
ConvexPolygon::Ptr intersectConvexPolygon(Plane &plane)
Definition: cube.cpp:174
jsk_recognition_utils::Cube::dimensions_
std::vector< double > dimensions_
Definition: cube.h:167
jsk_recognition_utils::Vertices
std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > Vertices
Definition: types.h:80
jsk_recognition_utils::Cube::Cube
Cube(const Eigen::Vector3f &pos, const Eigen::Quaternionf &rot)
Definition: cube.cpp:42


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