1515#ifndef NAV2_MAP_SERVER__VECTOR_OBJECT_SHAPES_HPP_
1616#define NAV2_MAP_SERVER__VECTOR_OBJECT_SHAPES_HPP_
1717
18- #include < cmath>
1918#include < memory>
2019#include < string>
21- #include < vector>
2220
21+ #include " rclcpp/rclcpp.hpp"
2322#include " geometry_msgs/msg/polygon.hpp"
2423#include " geometry_msgs/msg/point32.hpp"
2524#include " nav_msgs/msg/occupancy_grid.hpp"
@@ -71,42 +70,6 @@ class Shape
7170 */
7271 bool obtainShapeUUID (const std::string & shape_name, unsigned char * out_uuid);
7372
74- /* *
75- * @brief Supporting routine obtaining ROS-parameters for the given vector object.
76- * Empty virtual method intended to be used in child implementations
77- * @param shape_name Name of the shape
78- * @return True if all parameters were obtained or false in failure case
79- */
80- virtual bool obtainParams (const std::string & shape_name) = 0;
81-
82- /* *
83- * @brief Gets shape boundaries.
84- * Empty virtual method intended to be used in child implementations
85- * @param min_x output min X-boundary of shape
86- * @param min_y output min Y-boundary of shape
87- * @param max_x output max X-boundary of shape
88- * @param max_y output max Y-boundary of shape
89- */
90- virtual void getBoundaries (double & min_x, double & min_y, double & max_x, double & max_y) = 0;
91-
92- /* *
93- * @brief Is the point inside the shape.
94- * Empty virtual method intended to be used in child implementations
95- * @param px X-coordinate of the given point to check
96- * @param py Y-coordinate of the given point to check
97- * @return True if given point inside the shape
98- */
99- virtual bool isPointInside (const double px, const double py) const = 0;
100-
101- /* *
102- * @brief Puts shape borders on map.
103- * Empty virtual method intended to be used in child implementations
104- * @param map Output map pointer
105- * @param overlay_type Overlay type
106- */
107- virtual void putBorders (
108- nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type) = 0;
109-
11073 /* *
11174 * @brief Gets the value of the shape.
11275 * Empty virtual method intended to be used in child implementations
@@ -143,6 +106,14 @@ class Shape
143106 */
144107 virtual bool isFill () const = 0;
145108
109+ /* *
110+ * @brief Supporting routine obtaining ROS-parameters for the given vector object.
111+ * Empty virtual method intended to be used in child implementations
112+ * @param shape_name Name of the shape
113+ * @return True if all parameters were obtained or false in failure case
114+ */
115+ virtual bool obtainParams (const std::string & shape_name) = 0;
116+
146117 /* *
147118 * @brief Transforms shape coordinates to a new frame.
148119 * Empty virtual method intended to be used in child implementations
@@ -156,67 +127,52 @@ class Shape
156127 const std::shared_ptr<tf2_ros::Buffer> tf_buffer,
157128 const double transform_tolerance) = 0;
158129
159- protected:
160- // / @brief Type of shape
161- ShapeType type_;
162-
163- // / @brief VectorObjectServer node
164- nav2_util::LifecycleNode::WeakPtr node_;
165- };
166-
167- // / @brief Polygon shape class
168- class Polygon : public Shape
169- {
170- public:
171- /*
172- * @brief Polygon class constructor
173- * @param node Vector Object server node pointer
174- * @note setParams()/obtainParams() should be called after to configure the shape
175- */
176- explicit Polygon (const nav2_util::LifecycleNode::WeakPtr & node);
177-
178- /* *
179- * @brief Supporting routine obtaining ROS-parameters for the given vector object.
180- * @param shape_name Name of the shape
181- * @return True if all parameters were obtained or false in failure case
182- */
183- bool obtainParams (const std::string & shape_name);
184-
185130 /* *
186- * @brief Gets shape boundaries
131+ * @brief Gets shape boundaries.
132+ * Empty virtual method intended to be used in child implementations
187133 * @param min_x output min X-boundary of shape
188134 * @param min_y output min Y-boundary of shape
189135 * @param max_x output max X-boundary of shape
190136 * @param max_y output max Y-boundary of shape
191137 */
192- void getBoundaries (double & min_x, double & min_y, double & max_x, double & max_y);
138+ virtual void getBoundaries (double & min_x, double & min_y, double & max_x, double & max_y) = 0 ;
193139
194140 /* *
195141 * @brief Is the point inside the shape.
142+ * Empty virtual method intended to be used in child implementations
196143 * @param px X-coordinate of the given point to check
197144 * @param py Y-coordinate of the given point to check
198145 * @return True if given point inside the shape
199146 */
200- bool isPointInside (const double px, const double py) const ;
147+ virtual bool isPointInside (const double px, const double py) const = 0 ;
201148
202149 /* *
203150 * @brief Puts shape borders on map.
151+ * Empty virtual method intended to be used in child implementations
204152 * @param map Output map pointer
205153 * @param overlay_type Overlay type
206154 */
207- void putBorders (nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type);
155+ virtual void putBorders (
156+ nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type) = 0;
208157
209- /* *
210- * @brief Gets Polygon parameters
211- * @return Polygon parameters
212- */
213- nav2_msgs::msg::PolygonObject::SharedPtr getParams () const ;
158+ protected:
159+ // / @brief Type of shape
160+ ShapeType type_;
214161
215- /* *
216- * @brief Tries to update Polygon parameters
217- * @return False in case of inconsistent shape
162+ // / @brief VectorObjectServer node
163+ nav2_util::LifecycleNode::WeakPtr node_;
164+ };
165+
166+ // / @brief Polygon shape class
167+ class Polygon : public Shape
168+ {
169+ public:
170+ /*
171+ * @brief Polygon class constructor
172+ * @param node Vector Object server node pointer
173+ * @note setParams()/obtainParams() should be called after to configure the shape
218174 */
219- bool setParams (const nav2_msgs::msg::PolygonObject::SharedPtr params );
175+ explicit Polygon (const nav2_util::LifecycleNode::WeakPtr & node );
220176
221177 /* *
222178 * @brief Gets the value of the shape.
@@ -249,6 +205,25 @@ class Polygon : public Shape
249205 */
250206 bool isFill () const ;
251207
208+ /* *
209+ * @brief Supporting routine obtaining ROS-parameters for the given vector object.
210+ * @param shape_name Name of the shape
211+ * @return True if all parameters were obtained or false in failure case
212+ */
213+ bool obtainParams (const std::string & shape_name);
214+
215+ /* *
216+ * @brief Gets Polygon parameters
217+ * @return Polygon parameters
218+ */
219+ nav2_msgs::msg::PolygonObject::SharedPtr getParams () const ;
220+
221+ /* *
222+ * @brief Tries to update Polygon parameters
223+ * @return False in case of inconsistent shape
224+ */
225+ bool setParams (const nav2_msgs::msg::PolygonObject::SharedPtr params);
226+
252227 /* *
253228 * @brief Transforms shape coordinates to a new frame.
254229 * @param to_frame Frame ID to transform to
@@ -261,37 +236,6 @@ class Polygon : public Shape
261236 const std::shared_ptr<tf2_ros::Buffer> tf_buffer,
262237 const double transform_tolerance);
263238
264- protected:
265- /* *
266- * @brief Checks that shape is consistent for further operation
267- * @return False in case of inconsistent shape
268- */
269- bool checkConsistency ();
270-
271- // / @brief Input polygon parameters (could be in any frame)
272- nav2_msgs::msg::PolygonObject::SharedPtr params_;
273- // / @brief Polygon in the map's frame
274- geometry_msgs::msg::Polygon::SharedPtr polygon_;
275- };
276-
277- // / @brief Circle shape class
278- class Circle : public Shape
279- {
280- public:
281- /*
282- * @brief Circle class constructor
283- * @param node Vector Object server node pointer
284- * @note setParams()/obtainParams() should be called after to configure the shape
285- */
286- explicit Circle (const nav2_util::LifecycleNode::WeakPtr & node);
287-
288- /* *
289- * @brief Supporting routine obtaining ROS-parameters for the given vector object.
290- * @param shape_name Name of the shape
291- * @return True if all parameters were obtained or false in failure case
292- */
293- bool obtainParams (const std::string & shape_name);
294-
295239 /* *
296240 * @brief Gets shape boundaries
297241 * @param min_x output min X-boundary of shape
@@ -316,17 +260,29 @@ class Circle : public Shape
316260 */
317261 void putBorders (nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type);
318262
263+ protected:
319264 /* *
320- * @brief Gets Circle parameters
321- * @return Circle parameters
265+ * @brief Checks that shape is consistent for further operation
266+ * @return False in case of inconsistent shape
322267 */
323- nav2_msgs::msg::CircleObject::SharedPtr getParams () const ;
268+ bool checkConsistency () ;
324269
325- /* *
326- * @brief Tries to update Circle parameters
327- * @return False in case of inconsistent shape
270+ // / @brief Input polygon parameters (could be in any frame)
271+ nav2_msgs::msg::PolygonObject::SharedPtr params_;
272+ // / @brief Polygon in the map's frame
273+ geometry_msgs::msg::Polygon::SharedPtr polygon_;
274+ };
275+
276+ // / @brief Circle shape class
277+ class Circle : public Shape
278+ {
279+ public:
280+ /*
281+ * @brief Circle class constructor
282+ * @param node Vector Object server node pointer
283+ * @note setParams()/obtainParams() should be called after to configure the shape
328284 */
329- bool setParams (const nav2_msgs::msg::CircleObject::SharedPtr params );
285+ explicit Circle (const nav2_util::LifecycleNode::WeakPtr & node );
330286
331287 /* *
332288 * @brief Gets the value of the shape.
@@ -359,6 +315,25 @@ class Circle : public Shape
359315 */
360316 bool isFill () const ;
361317
318+ /* *
319+ * @brief Supporting routine obtaining ROS-parameters for the given vector object.
320+ * @param shape_name Name of the shape
321+ * @return True if all parameters were obtained or false in failure case
322+ */
323+ bool obtainParams (const std::string & shape_name);
324+
325+ /* *
326+ * @brief Gets Circle parameters
327+ * @return Circle parameters
328+ */
329+ nav2_msgs::msg::CircleObject::SharedPtr getParams () const ;
330+
331+ /* *
332+ * @brief Tries to update Circle parameters
333+ * @return False in case of inconsistent shape
334+ */
335+ bool setParams (const nav2_msgs::msg::CircleObject::SharedPtr params);
336+
362337 /* *
363338 * @brief Transforms shape coordinates to a new frame.
364339 * @param to_frame Frame ID to transform to
@@ -371,6 +346,30 @@ class Circle : public Shape
371346 const std::shared_ptr<tf2_ros::Buffer> tf_buffer,
372347 const double transform_tolerance);
373348
349+ /* *
350+ * @brief Gets shape boundaries
351+ * @param min_x output min X-boundary of shape
352+ * @param min_y output min Y-boundary of shape
353+ * @param max_x output max X-boundary of shape
354+ * @param max_y output max Y-boundary of shape
355+ */
356+ void getBoundaries (double & min_x, double & min_y, double & max_x, double & max_y);
357+
358+ /* *
359+ * @brief Is the point inside the shape.
360+ * @param px X-coordinate of the given point to check
361+ * @param py Y-coordinate of the given point to check
362+ * @return True if given point inside the shape
363+ */
364+ bool isPointInside (const double px, const double py) const ;
365+
366+ /* *
367+ * @brief Puts shape borders on map.
368+ * @param map Output map pointer
369+ * @param overlay_type Overlay type
370+ */
371+ void putBorders (nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type);
372+
374373protected:
375374 /* *
376375 * @brief Checks that shape is consistent for further operation
0 commit comments