Class Circle

Inheritance Relationships

Base Type

Class Documentation

class Circle : public nav2_collision_monitor::Polygon

Circle shape implementaiton. For STOP/SLOWDOWN/LIMIT model it represents zone around the robot while for APPROACH model it represents robot footprint.

Public Functions

Circle(const nav2_util::LifecycleNode::WeakPtr &node, const std::string &polygon_name, const std::shared_ptr<tf2_ros::Buffer> tf_buffer, const std::string &base_frame_id, const tf2::Duration &transform_tolerance)

Circle class constructor.

Parameters:
  • node – Collision Monitor node pointer

  • polygon_name – Name of circle

  • tf_buffer – Shared pointer to a TF buffer

  • base_frame_id – Robot base frame ID

  • transform_tolerance – Transform tolerance

~Circle()

Circle class destructor.

virtual void getPolygon(std::vector<Point> &poly) const override

Gets polygon points, approximated to the circle. To be used in visualization purposes.

Parameters:

poly – Output polygon points (vertices)

virtual int getPointsInside(const std::vector<Point> &points) const override

Gets number of points inside circle.

Parameters:

points – Input array of points to be checked

Returns:

Number of points inside circle. If there are no points, returns zero value.

virtual bool isShapeSet() override

Returns true if circle radius is set. Otherwise, prints a warning and returns false.

Protected Functions

virtual bool getParameters(std::string &polygon_sub_topic, std::string &polygon_pub_topic, std::string &footprint_topic) override

Supporting routine obtaining polygon-specific ROS-parameters.

Parameters:
  • polygon_sub_topic – Input name of polygon subscription topic

  • polygon_pub_topic – Output name of polygon or radius publishing topic

  • footprint_topic – Output name of footprint topic. For Circle returns empty string, there is no footprint subscription in this class.

Returns:

True if all parameters were obtained or false in failure case

virtual void createSubscription(std::string &polygon_sub_topic) override

Creates polygon or radius topic subscription.

Parameters:

polygon_sub_topic – Output name of polygon or radius subscription topic. Empty, if no polygon subscription.

void updatePolygon(double radius)

Updates polygon from radius value.

Parameters:

radius – New circle radius to update polygon

void radiusCallback(std_msgs::msg::Float32::ConstSharedPtr msg)

Dynamic circle radius callback.

Parameters:

msg – Shared pointer to the radius value message

Protected Attributes

double radius_

Radius of the circle.

double radius_squared_ = -1.0

(radius * radius) value. Stored for optimization.

rclcpp::Subscription<std_msgs::msg::Float32>::SharedPtr radius_sub_

Radius subscription.