map_accessibility_analysis.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #pragma once
19 
20 #include <vector>
21 
22 #include <opencv2/opencv.hpp>
23 
25 {
26 public:
27 
28  struct Pose
29  {
30  float x;
31  float y;
32  float orientation; // usually in [rad]
33 
34  Pose()
35  {
36  x = 0;
37  y = 0;
38  orientation = 0;
39  }
40 
41  Pose(float x_, float y_, float orientation_)
42  {
43  x = x_;
44  y = y_;
45  orientation = orientation_;
46  }
47  };
48 
49 
52 
58  void inflateMap(const cv::Mat& original_map, cv::Mat& inflated_map, const int robot_radius_pixel);
59 
69  void checkPoses(const std::vector<cv::Point>& points_to_check, std::vector<bool>& accessibility_flags,
70  const cv::Mat& inflated_map, const bool approach_path_accessibility_check, const cv::Point& robot_location);
71 
83  void checkPerimeter(std::vector<Pose>& accessible_poses_on_perimeter,
84  const Pose& center, const double radius, const double rotational_sampling_step,
85  const cv::Mat& inflated_map, const bool approach_path_accessibility_check, const cv::Point& robot_location);
86 
87  template<class T>
88  T convertFromMeterToPixelCoordinates(const Pose& pose, const cv::Point2d& map_origin, const double inverse_map_resolution)
89  {
90  T val;
91  val.x = (pose.x - map_origin.x) * inverse_map_resolution;
92  val.y = (pose.y - map_origin.y) * inverse_map_resolution;
93  return val;
94  }
95 
96  template<class T>
97  T convertFromPixelCoordinatesToMeter(const Pose& pose, const cv::Point2d& map_origin, const double map_resolution)
98  {
99  T val;
100  val.x = map_resolution * pose.x + map_origin.x;
101  val.y = map_resolution * pose.y + map_origin.y;
102  return val;
103  }
104 
105 protected:
106 
107  /*
108  * This function computes whether a given point (potentialApproachPose) is accessible by the robot at location robotLocation
109  */
110  bool isApproachPositionAccessible(const cv::Point& robotLocation,
111  const cv::Point& potentialApproachPose,
112  std::vector<std::vector<cv::Point> > contours);
113 
114  /*
115  * pose_p and closest_point_on_polygon in pixel coordinates!
116  */
117  void computeClosestPointOnPolygon(const cv::Mat& map_with_polygon,
118  const Pose& pose_p, Pose& closest_point_on_polygon);
119 
120 };
121 
Pose(float x_, float y_, float orientation_)
void checkPoses(const std::vector< cv::Point > &points_to_check, std::vector< bool > &accessibility_flags, const cv::Mat &inflated_map, const bool approach_path_accessibility_check, const cv::Point &robot_location)
void computeClosestPointOnPolygon(const cv::Mat &map_with_polygon, const Pose &pose_p, Pose &closest_point_on_polygon)
T convertFromPixelCoordinatesToMeter(const Pose &pose, const cv::Point2d &map_origin, const double map_resolution)
T convertFromMeterToPixelCoordinates(const Pose &pose, const cv::Point2d &map_origin, const double inverse_map_resolution)
bool isApproachPositionAccessible(const cv::Point &robotLocation, const cv::Point &potentialApproachPose, std::vector< std::vector< cv::Point > > contours)
void checkPerimeter(std::vector< Pose > &accessible_poses_on_perimeter, const Pose &center, const double radius, const double rotational_sampling_step, const cv::Mat &inflated_map, const bool approach_path_accessibility_check, const cv::Point &robot_location)
void inflateMap(const cv::Mat &original_map, cv::Mat &inflated_map, const int robot_radius_pixel)


cob_map_accessibility_analysis
Author(s): Richard Bormann
autogenerated on Sat Oct 24 2020 03:50:48