Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
collision_checker.hpp
1 // Copyright (c) 2022 Samsung Research America
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NAV2_REGULATED_PURE_PURSUIT_CONTROLLER__COLLISION_CHECKER_HPP_
16 #define NAV2_REGULATED_PURE_PURSUIT_CONTROLLER__COLLISION_CHECKER_HPP_
17 
18 #include <string>
19 #include <vector>
20 #include <memory>
21 #include <algorithm>
22 #include <mutex>
23 
24 #include "nav2_ros_common/lifecycle_node.hpp"
25 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
26 #include "nav2_costmap_2d/footprint_collision_checker.hpp"
27 #include "nav2_util/odometry_utils.hpp"
28 #include "geometry_msgs/msg/pose.hpp"
29 #include "nav2_regulated_pure_pursuit_controller/parameter_handler.hpp"
30 
31 #include "nav2_core/controller_exceptions.hpp"
32 #include "nav2_ros_common/node_utils.hpp"
33 #include "nav2_util/geometry_utils.hpp"
34 #include "nav2_costmap_2d/costmap_filters/filter_values.hpp"
35 
36 namespace nav2_regulated_pure_pursuit_controller
37 {
38 
44 {
45 public:
50  nav2::LifecycleNode::SharedPtr node,
51  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros, Parameters * params);
52 
56  ~CollisionChecker() = default;
57 
68  const geometry_msgs::msg::PoseStamped &,
69  const double &, const double &,
70  const double &);
71 
79  bool inCollision(
80  const double & x,
81  const double & y,
82  const double & theta);
83 
90  double costAtPose(const double & x, const double & y);
91 
92 protected:
93  rclcpp::Logger logger_ {rclcpp::get_logger("RPPCollisionChecker")};
94  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros_;
95  nav2_costmap_2d::Costmap2D * costmap_;
96  std::unique_ptr<nav2_costmap_2d::FootprintCollisionChecker<nav2_costmap_2d::Costmap2D *>>
97  footprint_collision_checker_;
98  Parameters * params_;
99  nav2::Publisher<nav_msgs::msg::Path>::SharedPtr carrot_arc_pub_;
100  rclcpp::Clock::SharedPtr clock_;
101 };
102 
103 } // namespace nav2_regulated_pure_pursuit_controller
104 
105 #endif // NAV2_REGULATED_PURE_PURSUIT_CONTROLLER__COLLISION_CHECKER_HPP_
A 2D costmap provides a mapping between points in the world and their associated "costs".
Definition: costmap_2d.hpp:69
Checks for collision based on a RPP control command.
bool inCollision(const double &x, const double &y, const double &theta)
checks for collision at projected pose
CollisionChecker(nav2::LifecycleNode::SharedPtr node, std::shared_ptr< nav2_costmap_2d::Costmap2DROS > costmap_ros, Parameters *params)
Constructor for nav2_regulated_pure_pursuit_controller::CollisionChecker.
bool isCollisionImminent(const geometry_msgs::msg::PoseStamped &, const double &, const double &, const double &)
Whether collision is imminent.
double costAtPose(const double &x, const double &y)
Cost at a point.
~CollisionChecker()=default
Destrructor for nav2_regulated_pure_pursuit_controller::CollisionChecker.