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

Circle shape class. More...

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

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

Public Member Functions

 Circle (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::CircleObject::SharedPtr getParams () const
 Gets Circle parameters. More...
 
bool setParams (const nav2_msgs::msg::CircleObject::SharedPtr params)
 Tries to update Circle 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...
 
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 conventional nav2_util::worldToMap() approach. More...
 
void putPoint (unsigned int mx, unsigned int my, nav_msgs::msg::OccupancyGrid::SharedPtr map, const OverlayType overlay_type)
 Put Circle's point on map. More...
 

Protected Attributes

nav2_msgs::msg::CircleObject::SharedPtr params_
 Input circle parameters (could be in any frame)
 
geometry_msgs::msg::Point32::SharedPtr center_
 Circle center 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

Circle shape class.

Definition at line 277 of file vector_object_shapes.hpp.

Member Function Documentation

◆ centerToMap()

bool nav2_map_server::Circle::centerToMap ( nav_msgs::msg::OccupancyGrid::ConstSharedPtr  map,
unsigned int &  mcx,
unsigned int &  mcy 
)
protected

Converts circle center to map coordinates considering FP-accuracy losing on small values when using conventional nav2_util::worldToMap() approach.

Parameters
mapMap pointer
mcxOutput X-coordinate of associated circle center on map
mcyOutput Y-coordinate of associated circle center on map
Returns
True if the conversion was successful

Definition at line 516 of file vector_object_shapes.cpp.

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

Referenced by putBorders().

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

◆ checkConsistency()

bool nav2_map_server::Circle::checkConsistency ( )
protected

Checks that shape is consistent for further operation.

Returns
False in case of inconsistent shape

Definition at line 499 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::Circle::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 436 of file vector_object_shapes.cpp.

References center_, and params_.

◆ getFrameID()

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

Gets frame ID of the shape.

Returns
Frame ID where the shape is

Implements nav2_map_server::Shape.

Definition at line 310 of file vector_object_shapes.cpp.

References params_.

◆ getParams()

nav2_msgs::msg::CircleObject::SharedPtr nav2_map_server::Circle::getParams ( ) const

Gets Circle parameters.

Returns
Circle parameters

Definition at line 390 of file vector_object_shapes.cpp.

References params_.

◆ getUUID()

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

Gets UUID of the shape.

Returns
Shape UUID string

Implements nav2_map_server::Shape.

Definition at line 315 of file vector_object_shapes.cpp.

References params_.

Referenced by centerToMap(), and checkConsistency().

Here is the caller graph for this function:

◆ getValue()

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

Gets the value of the shape.

Returns
OccupancyGrid value of the shape

Implements nav2_map_server::Shape.

Definition at line 305 of file vector_object_shapes.cpp.

References params_.

◆ isFill()

bool nav2_map_server::Circle::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 325 of file vector_object_shapes.cpp.

References params_.

◆ isPointInside()

bool nav2_map_server::Circle::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 444 of file vector_object_shapes.cpp.

References center_, and params_.

◆ isUUID()

bool nav2_map_server::Circle::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 320 of file vector_object_shapes.cpp.

References params_.

◆ obtainParams()

bool nav2_map_server::Circle::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 330 of file vector_object_shapes.cpp.

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

Here is the call graph for this function:

◆ putBorders()

void nav2_map_server::Circle::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 450 of file vector_object_shapes.cpp.

References centerToMap(), params_, and putPoint().

Here is the call graph for this function:

◆ putPoint()

void nav2_map_server::Circle::putPoint ( unsigned int  mx,
unsigned int  my,
nav_msgs::msg::OccupancyGrid::SharedPtr  map,
const OverlayType  overlay_type 
)
inlineprotected

Put Circle's point on map.

Parameters
mxX-coordinate of given point
myY-coordinate of given point
mapOutput map pointer
overlay_typeOverlay type

Definition at line 551 of file vector_object_shapes.cpp.

References params_.

Referenced by putBorders().

Here is the caller graph for this function:

◆ setParams()

bool nav2_map_server::Circle::setParams ( const nav2_msgs::msg::CircleObject::SharedPtr  params)

Tries to update Circle parameters.

Returns
False in case of inconsistent shape

Definition at line 395 of file vector_object_shapes.cpp.

References center_, checkConsistency(), and params_.

Here is the call graph for this function:

◆ toFrame()

bool nav2_map_server::Circle::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 412 of file vector_object_shapes.cpp.

References center_, and params_.


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