15 #include "nav2_collision_monitor/circle.hpp"
21 #include "nav2_util/node_utils.hpp"
23 namespace nav2_collision_monitor
27 const nav2_util::LifecycleNode::WeakPtr & node,
28 const std::string & polygon_name,
29 const std::shared_ptr<tf2_ros::Buffer> tf_buffer,
30 const std::string & base_frame_id,
31 const tf2::Duration & transform_tolerance)
32 :
Polygon::
Polygon(node, polygon_name, tf_buffer, base_frame_id, transform_tolerance)
45 const double polygon_edges = 16;
47 double angle_increment = 2 * M_PI / polygon_edges;
54 for (
double angle = 0.0; angle < 2 * M_PI; angle += angle_increment) {
55 p.x =
radius_ * std::cos(angle);
56 p.y =
radius_ * std::sin(angle);
64 for (
Point point : points) {
75 auto node =
node_.lock();
77 throw std::runtime_error{
"Failed to lock node"};
85 footprint_topic.clear();
89 nav2_util::declare_parameter_if_not_declared(
93 }
catch (
const std::exception & ex) {
96 "[%s]: Error while getting circle parameters: %s",
int getPointsInside(const std::vector< Point > &points) const override
Gets number of points inside circle.
void getPolygon(std::vector< Point > &poly) const override
Gets polygon points, approximated to the circle. To be used in visualization purposes.
double radius_squared_
(radius * radius) value. Stored for optimization.
bool getParameters(std::string &polygon_pub_topic, std::string &footprint_topic) override
Supporting routine obtaining polygon-specific ROS-parameters.
~Circle()
Circle class destructor.
double radius_
Radius of the circle.
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.
Basic polygon shape class. For STOP/SLOWDOWN model it represents zone around the robot while for APPR...
nav2_util::LifecycleNode::WeakPtr node_
Collision Monitor node.
bool getCommonParameters(std::string &polygon_pub_topic)
Supporting routine obtaining ROS-parameters common for all shapes.
rclcpp::Logger logger_
Collision monitor node logger stored for further usage.
std::string polygon_name_
Name of polygon.