Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nav2_map_server::Polygon Class Reference

Polygon shape class. More...

#include <nav2_map_server/include/nav2_map_server/vector_object_shapes.hpp>

Inheritance diagram for nav2_map_server::Polygon:
Inheritance graph
[legend]
Collaboration diagram for nav2_map_server::Polygon:
Collaboration graph
[legend]

Public Member Functions

 Polygon (const nav2::LifecycleNode::WeakPtr &node)
 
int8_t getValue () const
 Gets the value of the shape. More...
 
std::string getFrameID () const
 Gets frame ID of the shape. More...
 
std::string getUUID () const
 Gets UUID of the shape. More...
 
bool isUUID (const unsigned char *uuid) const
 Checks whether the shape is equal to a given UUID. More...
 
bool isFill () const
 Whether the shape to be filled or only its borders to be put on map. More...
 
bool obtainParams (const std::string &shape_name)
 Supporting routine obtaining ROS-parameters for the given vector object. More...
 
nav2_msgs::msg::PolygonObject::SharedPtr getParams () const
 Gets Polygon parameters. More...
 
bool setParams (const nav2_msgs::msg::PolygonObject::SharedPtr params)
 Tries to update Polygon parameters. More...
 
bool toFrame (const std::string &to_frame, const std::shared_ptr< tf2_ros::Buffer > tf_buffer, const double transform_tolerance)
 Transforms shape coordinates to a new frame. More...
 
void getBoundaries (double &min_x, double &min_y, double &max_x, double &max_y)
 Gets shape box-boundaries. More...
 
bool isPointInside (const double px, const double py) const
 Is the point inside the shape. More...
 
void putBorders (nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type)
 Puts shape borders on map. More...
 
- Public Member Functions inherited from nav2_map_server::Shape
 Shape (const nav2::LifecycleNode::WeakPtr &node)
 Shape basic class constructor. More...
 
virtual ~Shape ()
 Shape destructor.
 
ShapeType getType ()
 Returns type of the shape. More...
 
bool obtainShapeUUID (const std::string &shape_name, unsigned char *out_uuid)
 Supporting routine obtaining shape UUID from ROS-parameters for the given shape object. More...
 

Protected Member Functions

bool checkConsistency ()
 Checks that shape is consistent for further operation. More...
 

Protected Attributes

nav2_msgs::msg::PolygonObject::SharedPtr params_
 Input polygon parameters (could be in any frame)
 
geometry_msgs::msg::Polygon::SharedPtr polygon_
 Polygon in the map's frame.
 
- Protected Attributes inherited from nav2_map_server::Shape
ShapeType type_
 Type of shape.
 
nav2::LifecycleNode::WeakPtr node_
 VectorObjectServer node.
 

Detailed Description

Polygon shape class.

Definition at line 167 of file vector_object_shapes.hpp.

Member Function Documentation

◆ checkConsistency()

bool nav2_map_server::Polygon::checkConsistency ( )
protected

Checks that shape is consistent for further operation.

Returns
False in case of inconsistent shape

Definition at line 278 of file vector_object_shapes.cpp.

References getUUID(), nav2_map_server::Shape::node_, and params_.

Referenced by setParams().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBoundaries()

void nav2_map_server::Polygon::getBoundaries ( double &  min_x,
double &  min_y,
double &  max_x,
double &  max_y 
)
virtual

Gets shape box-boundaries.

Parameters
min_xoutput min X-boundary of shape
min_youtput min Y-boundary of shape
max_xoutput max X-boundary of shape
max_youtput max Y-boundary of shape

Implements nav2_map_server::Shape.

Definition at line 225 of file vector_object_shapes.cpp.

References polygon_.

◆ getFrameID()

std::string nav2_map_server::Polygon::getFrameID ( ) const
virtual

Gets frame ID of the shape.

Returns
Frame ID where the shape is

Implements nav2_map_server::Shape.

Definition at line 96 of file vector_object_shapes.cpp.

References params_.

◆ getParams()

nav2_msgs::msg::PolygonObject::SharedPtr nav2_map_server::Polygon::getParams ( ) const

Gets Polygon parameters.

Returns
Polygon parameters

Definition at line 177 of file vector_object_shapes.cpp.

References params_.

◆ getUUID()

std::string nav2_map_server::Polygon::getUUID ( ) const
virtual

Gets UUID of the shape.

Returns
Shape UUID string

Implements nav2_map_server::Shape.

Definition at line 101 of file vector_object_shapes.cpp.

References params_.

Referenced by checkConsistency(), and putBorders().

Here is the caller graph for this function:

◆ getValue()

int8_t nav2_map_server::Polygon::getValue ( ) const
virtual

Gets the value of the shape.

Returns
OccupancyGrid value of the shape

Implements nav2_map_server::Shape.

Definition at line 91 of file vector_object_shapes.cpp.

References params_.

◆ isFill()

bool nav2_map_server::Polygon::isFill ( ) const
virtual

Whether the shape to be filled or only its borders to be put on map.

Returns
True if shape to be filled

Implements nav2_map_server::Shape.

Definition at line 111 of file vector_object_shapes.cpp.

References params_.

◆ isPointInside()

bool nav2_map_server::Polygon::isPointInside ( const double  px,
const double  py 
) const
virtual

Is the point inside the shape.

Parameters
pxX-coordinate of the given point to check
pyY-coordinate of the given point to check
Returns
True if given point inside the shape

Implements nav2_map_server::Shape.

Definition at line 240 of file vector_object_shapes.cpp.

References polygon_.

◆ isUUID()

bool nav2_map_server::Polygon::isUUID ( const unsigned char *  uuid) const
virtual

Checks whether the shape is equal to a given UUID.

Parameters
uuidGiven UUID to check with
Returns
True if the shape has the same as given UUID, otherwise false

Implements nav2_map_server::Shape.

Definition at line 106 of file vector_object_shapes.cpp.

References params_.

◆ obtainParams()

bool nav2_map_server::Polygon::obtainParams ( const std::string &  shape_name)
virtual

Supporting routine obtaining ROS-parameters for the given vector object.

Parameters
shape_nameName of the shape
Returns
True if all parameters were obtained or false in failure case

Implements nav2_map_server::Shape.

Definition at line 116 of file vector_object_shapes.cpp.

References nav2_map_server::Shape::node_, nav2_map_server::Shape::obtainShapeUUID(), params_, and polygon_.

Here is the call graph for this function:

◆ putBorders()

void nav2_map_server::Polygon::putBorders ( nav_msgs::msg::OccupancyGrid::SharedPtr  map,
const OverlayType  overlay_type 
)
virtual

Puts shape borders on map.

Parameters
mapOutput map pointer
overlay_typeOverlay type

Implements nav2_map_server::Shape.

Definition at line 245 of file vector_object_shapes.cpp.

References getUUID(), nav2_map_server::Shape::node_, params_, and polygon_.

Here is the call graph for this function:

◆ setParams()

bool nav2_map_server::Polygon::setParams ( const nav2_msgs::msg::PolygonObject::SharedPtr  params)

Tries to update Polygon parameters.

Returns
False in case of inconsistent shape

Definition at line 182 of file vector_object_shapes.cpp.

References checkConsistency(), params_, and polygon_.

Here is the call graph for this function:

◆ toFrame()

bool nav2_map_server::Polygon::toFrame ( const std::string &  to_frame,
const std::shared_ptr< tf2_ros::Buffer >  tf_buffer,
const double  transform_tolerance 
)
virtual

Transforms shape coordinates to a new frame.

Parameters
to_frameFrame ID to transform to
tf_bufferTF buffer to use for the transformation
transform_toleranceTransform tolerance
Returns
Whether it was transformed successfully

Implements nav2_map_server::Shape.

Definition at line 199 of file vector_object_shapes.cpp.

References params_, and polygon_.


The documentation for this class was generated from the following files: