se2ez
geometry.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef SE2EZ_CORE_GEOMETRY_
4 #define SE2EZ_CORE_GEOMETRY_
5 
6 #include <Eigen/Core>
7 #include <Eigen/Geometry>
8 
10 #include <se2ez/core/math.h>
11 
12 namespace se2ez
13 {
14  /** \cond IGNORE */
15  SE2EZ_CLASS_FORWARD(Geometry)
16  /** \endcond */
17 
18  /** \class se2ez::GeometryPtr
19  \brief A shared pointer wrapper for se2ez::Geometry. */
20 
21  /** \class se2ez::GeometryConstPtr
22  \brief A const shared pointer wrapper for se2ez::Geometry. */
23 
24  class Geometry
25  {
26  public:
28 
29  /** \brief Type of geometry.
30  */
31  enum Type
32  {
33  BOX = 0, ///< A rectangular prism.
34  CIRCLE = 1, ///< A filled circle.
35  CONVEX = 2, ///< A convex polygon.
36  SIMPLE = 3 ///< A simple polygon (no holes).
37  };
38 
39  /** \brief Maximum value a geometry type can have */
40  static const unsigned int TYPE_MAX = SIMPLE;
41 
42  /** \brief String representation of geometry type. */
43  static const std::string TYPE_STRINGS[];
44 
45  /** \brief Try to convert a string into a geometry type. Not case-sensitive.
46  * \param[in] geometry String of geometry type. See TYPE_STRINGS.
47  * \return The type of geometry specified by the string, or an exception on failure.
48  */
49  static Type stringToType(const std::string &geometry);
50 
51  /** \brief Converts a geometry type into its string representation.
52  * \param[in] type The type to convert.
53  * \return The geometry type as a string.
54  */
55  static const std::string &typeToString(const Type &type);
56 
57  /** \name Constructors
58  \{ */
59 
60  /** \brief Constructor.
61  * \param[in] g geometry to copy values from;
62  */
63  Geometry(const GeometryPtr &g);
64 
65  /** \brief Constructor.
66  * \param[in] type Type of the geometry(box or circle).
67  * \param[in] dimensions The dimensions of this geometry.
68  * \param[in] offset The offset of this geometry from its root frame.
69  * \param[in] color Color to display for this geometry.
70  */
71  Geometry(Type type, const Eigen::VectorXd &dimensions, const Eigen::Isometry2d &offset,
72  const Eigen::Vector4d &color = {0., 0., 0., 1.});
73 
74  /** \brief Constructor.
75  * \param[in] type Type of the geometry (box or circle).
76  * \param[in] dimensions The dimensions of this geometry.
77  * \param[in] offset The offset of this geometry from its root frame.
78  * \param[in] color Color to display for this geometry.
79  */
80  Geometry(Type type, const Eigen::VectorXd &dimensions, const Eigen::Vector3d &offset,
81  const Eigen::Vector4d &color = {0., 0., 0., 1.});
82 
83  /** \brief Constructor.
84  * \param[in] type Type of the geometry (convex or polygon).
85  * \param[in] points Points of the polygon.
86  * \param[in] offset The offset of this geometry from its root frame.
87  * \param[in] color Color to display for this geometry.
88  */
89  Geometry(Type type, const tf::EigenVector<Eigen::Vector2d> &points, const Eigen::Isometry2d &offset,
90  const Eigen::Vector4d &color = {0., 0., 0., 1.});
91 
92  /** \brief Constructor.
93  * \param[in] type Type of the geometry (convex or polygon).
94  * \param[in] points Points of the polygon.
95  * \param[in] offset The offset of this geometry from its root frame.
96  * \param[in] color Color to display for this geometry.
97  */
98  Geometry(Type type, const tf::EigenVector<Eigen::Vector2d> &points, const Eigen::Vector3d &offset,
99  const Eigen::Vector4d &color = {0., 0., 0., 1.});
100 
101  // non-copyable
102  Geometry(const Geometry &) = delete;
103  Geometry(Geometry &&) = delete;
104 
105  /** \} */
106 
107  /** \name Debug
108  \{ */
109 
110  /** \brief Returns a string representation of the geometry.
111  * \return A string of the geometry.
112  */
113  std::string printGeometry() const;
114 
115  /** \} */
116 
117  const Type type; ///< Type of geometry.
118  Eigen::VectorXd dimensions; ///< The geometry's dimensions.
119  tf::EigenVector<Eigen::Vector2d> points; ///< Point list for polygons.
120  Eigen::Isometry2d offset; ///< Offset of geometry from base frame.
121  bool isOffset; ///< Is this geometry offset?
122  Eigen::Vector4d color; ///< The color to display this geometry as.
123  };
124 
125 } // namespace se2ez
126 
127 #endif
Eigen::Isometry2d offset
Offset of geometry from base frame.
Definition: geometry.h:120
Eigen::VectorXd dimensions
The geometry&#39;s dimensions.
Definition: geometry.h:118
const Type type
Type of geometry.
Definition: geometry.h:117
tf::EigenVector< Eigen::Vector2d > points
Point list for polygons.
Definition: geometry.h:119
Type
Type of geometry.
Definition: geometry.h:31
A shared pointer wrapper for se2ez::Geometry.
#define SE2EZ_EIGEN_CLASS
Definition: class_forward.h:14
bool isOffset
Is this geometry offset?
Definition: geometry.h:121
Main namespace.
Definition: collision.h:11
#define SE2EZ_CLASS_FORWARD(C)
Definition: class_forward.h:9
Eigen::Vector4d color
The color to display this geometry as.
Definition: geometry.h:122