15 #ifndef NAV2_MAP_SERVER__VECTOR_OBJECT_SHAPES_HPP_
16 #define NAV2_MAP_SERVER__VECTOR_OBJECT_SHAPES_HPP_
24 #include "geometry_msgs/msg/polygon.hpp"
25 #include "geometry_msgs/msg/point32.hpp"
26 #include "nav_msgs/msg/occupancy_grid.hpp"
28 #include "nav2_ros_common/tf2_factories.hpp"
30 #include "nav2_msgs/msg/polygon_object.hpp"
31 #include "nav2_msgs/msg/circle_object.hpp"
32 #include "nav2_ros_common/lifecycle_node.hpp"
34 #include "nav2_map_server/vector_object_utils.hpp"
36 namespace nav2_map_server
55 explicit Shape(
const nav2::LifecycleNode::WeakPtr & node);
73 bool obtainShapeUUID(
const std::string & shape_name,
unsigned char * out_uuid);
102 virtual bool isUUID(
const unsigned char * uuid)
const = 0;
128 const std::string & to_frame,
129 const nav2::TransformBuffer::SharedPtr tf_buffer,
130 const double transform_tolerance) = 0;
140 virtual void getBoundaries(
double & min_x,
double & min_y,
double & max_x,
double & max_y) = 0;
159 const double py, std::vector<std::pair<double, double>> & spans)
const = 0;
167 bool putFill(nav_msgs::msg::OccupancyGrid::SharedPtr map,
const OverlayType overlay_type);
176 nav_msgs::msg::OccupancyGrid::SharedPtr map,
const OverlayType overlay_type) = 0;
188 int8_t * cells,
const size_t count,
const int8_t shape_val,
189 const OverlayType overlay_type);
207 explicit Polygon(
const nav2::LifecycleNode::WeakPtr & node);
232 bool isUUID(
const unsigned char * uuid)
const;
251 nav2_msgs::msg::PolygonObject::SharedPtr
getParams()
const;
257 bool setParams(
const nav2_msgs::msg::PolygonObject::SharedPtr params);
267 const std::string & to_frame,
268 const nav2::TransformBuffer::SharedPtr tf_buffer,
269 const double transform_tolerance);
278 void getBoundaries(
double & min_x,
double & min_y,
double & max_x,
double & max_y);
293 void getRowSpans(
const double py, std::vector<std::pair<double, double>> & spans)
const;
300 void putBorders(nav_msgs::msg::OccupancyGrid::SharedPtr map,
const OverlayType overlay_type);
310 nav2_msgs::msg::PolygonObject::SharedPtr
params_;
324 explicit Circle(
const nav2::LifecycleNode::WeakPtr & node);
349 bool isUUID(
const unsigned char * uuid)
const;
368 nav2_msgs::msg::CircleObject::SharedPtr
getParams()
const;
374 bool setParams(
const nav2_msgs::msg::CircleObject::SharedPtr params);
384 const std::string & to_frame,
385 const nav2::TransformBuffer::SharedPtr tf_buffer,
386 const double transform_tolerance);
395 void getBoundaries(
double & min_x,
double & min_y,
double & max_x,
double & max_y);
410 void getRowSpans(
const double py, std::vector<std::pair<double, double>> & spans)
const;
417 void putBorders(nav_msgs::msg::OccupancyGrid::SharedPtr map,
const OverlayType overlay_type);
436 nav_msgs::msg::OccupancyGrid::ConstSharedPtr map,
437 unsigned int & mcx,
unsigned int & mcy);
447 unsigned int mx,
unsigned int my,
448 nav_msgs::msg::OccupancyGrid::SharedPtr map,
449 const OverlayType overlay_type);
452 nav2_msgs::msg::CircleObject::SharedPtr
params_;
454 geometry_msgs::msg::Point32::SharedPtr
center_;
bool isUUID(const unsigned char *uuid) const
Checks whether the shape is equal to a given UUID.
int8_t getValue() const
Gets the value of the shape.
bool toFrame(const std::string &to_frame, const nav2::TransformBuffer::SharedPtr tf_buffer, const double transform_tolerance)
Transforms shape coordinates to a new frame.
void putPoint(unsigned int mx, unsigned int my, nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type)
Put Circle's point on map.
bool isPointInside(const double px, const double py) const
Is the point inside the shape.
std::string getUUID() const
Gets UUID of the shape.
void getBoundaries(double &min_x, double &min_y, double &max_x, double &max_y)
Gets shape box-boundaries.
std::string getFrameID() const
Gets frame ID of the shape.
bool centerToMap(nav_msgs::msg::OccupancyGrid::ConstSharedPtr map, unsigned int &mcx, unsigned int &mcy)
Converts circle center to map coordinates considering FP-accuracy losing on small values when using c...
bool isFill() const
Whether the shape to be filled or only its borders to be put on map.
void getRowSpans(const double py, std::vector< std::pair< double, double >> &spans) const
Gets X-interval covered by the circle on the horizontal line y = py.
nav2_msgs::msg::CircleObject::SharedPtr params_
Input circle parameters (could be in any frame)
bool setParams(const nav2_msgs::msg::CircleObject::SharedPtr params)
Tries to update Circle parameters.
void putBorders(nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type)
Puts shape borders on map.
nav2_msgs::msg::CircleObject::SharedPtr getParams() const
Gets Circle parameters.
bool checkConsistency()
Checks that shape is consistent for further operation.
geometry_msgs::msg::Point32::SharedPtr center_
Circle center in the map's frame.
bool obtainParams(const std::string &shape_name)
Supporting routine obtaining ROS-parameters for the given vector object.
std::string getUUID() const
Gets UUID of the shape.
void getRowSpans(const double py, std::vector< std::pair< double, double >> &spans) const
Gets X-intervals covered by the polygon on the horizontal line y = py.
void getBoundaries(double &min_x, double &min_y, double &max_x, double &max_y)
Gets shape box-boundaries.
void putBorders(nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type)
Puts shape borders on map.
bool toFrame(const std::string &to_frame, const nav2::TransformBuffer::SharedPtr tf_buffer, const double transform_tolerance)
Transforms shape coordinates to a new frame.
bool isUUID(const unsigned char *uuid) const
Checks whether the shape is equal to a given UUID.
nav2_msgs::msg::PolygonObject::SharedPtr getParams() const
Gets Polygon parameters.
int8_t getValue() const
Gets the value of the shape.
bool setParams(const nav2_msgs::msg::PolygonObject::SharedPtr params)
Tries to update Polygon parameters.
std::string getFrameID() const
Gets frame ID of the shape.
nav2_msgs::msg::PolygonObject::SharedPtr params_
Input polygon parameters (could be in any frame)
bool checkConsistency()
Checks that shape is consistent for further operation.
bool isPointInside(const double px, const double py) const
Is the point inside the shape.
bool isFill() const
Whether the shape to be filled or only its borders to be put on map.
bool obtainParams(const std::string &shape_name)
Supporting routine obtaining ROS-parameters for the given vector object.
geometry_msgs::msg::Polygon::SharedPtr polygon_
Polygon in the map's frame.
Basic class, other vector objects to be inherited from.
virtual bool isFill() const =0
Whether the shape to be filled or only its borders to be put on map. Empty virtual method intended to...
virtual bool obtainParams(const std::string &shape_name)=0
Supporting routine obtaining ROS-parameters for the given vector object. Empty virtual method intende...
virtual void putBorders(nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type)=0
Puts shape borders on map. Empty virtual method intended to be used in child implementations.
bool obtainShapeUUID(const std::string &shape_name, unsigned char *out_uuid)
Supporting routine obtaining shape UUID from ROS-parameters for the given shape object.
virtual void getBoundaries(double &min_x, double &min_y, double &max_x, double &max_y)=0
Gets shape box-boundaries. Empty virtual method intended to be used in child implementations.
virtual bool isPointInside(const double px, const double py) const =0
Is the point inside the shape. Empty virtual method intended to be used in child implementations.
ShapeType type_
Type of shape.
ShapeType getType()
Returns type of the shape.
nav2::LifecycleNode::WeakPtr node_
VectorObjectServer node.
virtual std::string getFrameID() const =0
Gets frame ID of the shape. Empty virtual method intended to be used in child implementations.
virtual void getRowSpans(const double py, std::vector< std::pair< double, double >> &spans) const =0
Gets X-intervals covered by the shape on the horizontal line y = py. Intervals may be slightly wider ...
virtual bool toFrame(const std::string &to_frame, const nav2::TransformBuffer::SharedPtr tf_buffer, const double transform_tolerance)=0
Transforms shape coordinates to a new frame. Empty virtual method intended to be used in child implem...
virtual ~Shape()
Shape destructor.
Shape(const nav2::LifecycleNode::WeakPtr &node)
Shape basic class constructor.
bool putFill(nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type)
Puts filled shape on map.
static void processRun(int8_t *cells, const size_t count, const int8_t shape_val, const OverlayType overlay_type)
Updates a run of consecutive cells with given shape value according to the overlay type.
virtual int8_t getValue() const =0
Gets the value of the shape. Empty virtual method intended to be used in child implementations.
virtual std::string getUUID() const =0
Gets UUID of the shape. Empty virtual method intended to be used in child implementations.
virtual bool isUUID(const unsigned char *uuid) const =0
Checks whether the shape is equal to a given UUID. Empty virtual method intended to be used in child ...