Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
footprint_collision_checker.hpp
1 // Copyright (c) 2019 Intel Corporation
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 // Modified by: Shivang Patel (shivaang14@gmail.com)
16 
17 #ifndef NAV2_COSTMAP_2D__FOOTPRINT_COLLISION_CHECKER_HPP_
18 #define NAV2_COSTMAP_2D__FOOTPRINT_COLLISION_CHECKER_HPP_
19 
20 #include <string>
21 #include <vector>
22 #include <memory>
23 #include <algorithm>
24 
25 #include "geometry_msgs/msg/pose_stamped.hpp"
26 #include "geometry_msgs/msg/pose.hpp"
27 #include "nav2_costmap_2d/costmap_2d.hpp"
28 #include "nav2_util/robot_utils.hpp"
29 
30 namespace nav2_costmap_2d
31 {
32 typedef std::vector<geometry_msgs::msg::Point> Footprint;
33 
38 template<typename CostmapT>
40 {
41 public:
49  explicit FootprintCollisionChecker(CostmapT costmap);
53  double footprintCost(const Footprint & footprint);
57  double footprintCostAtPose(double x, double y, double theta, const Footprint & footprint);
61  double lineCost(int x0, int x1, int y0, int y1) const;
65  bool worldToMap(double wx, double wy, unsigned int & mx, unsigned int & my);
69  double pointCost(int x, int y) const;
73  void setCostmap(CostmapT costmap);
77  CostmapT getCostmap()
78  {
79  return costmap_;
80  }
81 
82 protected:
83  CostmapT costmap_;
84 };
85 
86 } // namespace nav2_costmap_2d
87 
88 #endif // NAV2_COSTMAP_2D__FOOTPRINT_COLLISION_CHECKER_HPP_
Checker for collision with a footprint on a costmap.
double lineCost(int x0, int x1, int y0, int y1) const
Get the cost for a line segment.
CostmapT getCostmap()
Get the current costmap object.
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my)
Get the map coordinates from a world point.
double footprintCostAtPose(double x, double y, double theta, const Footprint &footprint)
Find the footprint cost a a post with an unoriented footprint.
double footprintCost(const Footprint &footprint)
Find the footprint cost in oriented footprint.
void setCostmap(CostmapT costmap)
Set the current costmap object to use for collision detection.
double pointCost(int x, int y) const
Get the cost of a point.