map_accessibility_analysis_server.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 #ifndef MAP_ACCESSIBILITY_ANALYSIS_H
19 #define MAP_ACCESSIBILITY_ANALYSIS_H
20 
21 #include <iostream>
22 #include <sstream>
23 #include <string>
24 #include <vector>
25 #include <math.h>
26 
27 #include <ros/ros.h>
28 #include <XmlRpc.h>
29 
30 #include <nav_msgs/OccupancyGrid.h>
31 #include <geometry_msgs/Point.h>
32 #include <geometry_msgs/Pose2D.h>
33 #include <nav_msgs/GridCells.h>
34 
36 
41 
42 #include <tf/transform_listener.h>
43 
44 #include <cob_map_accessibility_analysis/CheckPointAccessibility.h>
45 #include <cob_map_accessibility_analysis/CheckPerimeterAccessibility.h>
46 #include <cob_3d_mapping_msgs/GetApproachPoseForPolygon.h>
47 
48 // opencv
49 #include <opencv2/opencv.hpp>
50 #include <cv_bridge/cv_bridge.h>
52 
53 #include <pcl/conversions.h>
54 #include <pcl/point_types.h>
55 
56 #include <boost/thread/mutex.hpp>
57 #include <boost/shared_ptr.hpp>
58 #include <boost/tokenizer.hpp>
59 #include <boost/foreach.hpp>
60 #include <boost/algorithm/string.hpp>
61 
63 
65 {
66 public:
69 
70 protected:
71 
72  // reads out the robot footprint from a string or array
73  // returns the polygonal footprint of the robot in [m]
74  std::vector<geometry_msgs::Point> loadRobotFootprint(XmlRpc::XmlRpcValue& footprint_list);
75 
76  // original map initializer
77  void mapInit(ros::NodeHandle& nh_map);
78 
79  // dynamic obstacles map initializer using obstacles and inflated obstacles topics
81 
82  // dynamic obstacles map initializer using obstacles and robot radius
84 
85  // map data call-back function to get the original map and also to write original inflated map for the obstacles
86  void mapDataCallback(const nav_msgs::OccupancyGrid::ConstPtr& map_msg_data);
87 
88  // to create dynamic obstacles map from obstacles and inflated obstacles topics
89  void inflatedObstacleDataCallback(const nav_msgs::GridCells::ConstPtr& obstacles_data,
90  const nav_msgs::GridCells::ConstPtr& inflated_obstacles_data);
91 
92  // to create dynamic obstacles map from obstacles topic and robot radius
93  void obstacleDataCallback(const nav_msgs::GridCells::ConstPtr& obstacles_data);
94 
95  // callback for service checking the accessibility of a vector of points
96  bool checkPose2DArrayCallback(cob_map_accessibility_analysis::CheckPointAccessibility::Request& req,
97  cob_map_accessibility_analysis::CheckPointAccessibility::Response& res);
98 
99  // callback for service checking the accessibility of a perimeter around a center point
100  bool checkPerimeterCallback(cob_map_accessibility_analysis::CheckPerimeterAccessibility::Request& req,
101  cob_map_accessibility_analysis::CheckPerimeterAccessibility::Response& res);
102 
103  // callback for service checking the accessibility of a perimeter around a polygon
104  bool checkPolygonCallback(cob_3d_mapping_msgs::GetApproachPoseForPolygon::Request& req,
105  cob_3d_mapping_msgs::GetApproachPoseForPolygon::Response& res);
106 
107  // reads the robot coordinates from tf
109 
111 
112  ros::Subscriber map_msg_sub_; // subscriber to the map topic
113  bool map_data_recieved_; // flag whether the map has already been received by the node
114 
124  double obstacle_topic_update_rate_; // defines how often this topic should be updated (set to a low rate to save
125  // ressources of your computing system)
126  ros::Duration obstacle_topic_update_delay_; // the inverse of the update rate
127  ros::Time last_update_time_obstacles_; // time of last update from the obstacle topic
128 
130 
131  ros::ServiceServer map_points_accessibility_check_server_; // server handling requests for checking the accessibility
132  // of a set of points
133  ros::ServiceServer map_perimeter_accessibility_check_server_; // server handling requests for checking the
134  // accessibility of any point on the perimeter of a
135  // given position
136  ros::ServiceServer map_polygon_accessibility_check_server_; // server handling requests for checking the
137  // accessibility of any point around a given polygon
138  // (obeying the safety margin around the polygon)
139 
140  // maps
141  cv::Mat original_map_;
142  cv::Mat inflated_original_map_; // contains only the inflated static obstacles
143  cv::Mat inflated_map_; // contains inflated static and dynamic obstacles
144 
145  boost::mutex mutex_inflated_map_; // mutex for access on inflated_map
146 
147  // map properties
148  double map_resolution_; // in [m/cell]
149  double inverse_map_resolution_; // in [cell/m]
150  cv::Point2d map_origin_; // in [m,m,rad]
151  std::string map_link_name_;
152 
153  // robot
154  double robot_radius_; // in [m]
156  bool approach_path_accessibility_check_; // if true, the path to a goal position must be accessible as well
157 };
158 
159 #endif // MAP_ACCESSIBILITY_ANALYSIS_H
bool checkPolygonCallback(cob_3d_mapping_msgs::GetApproachPoseForPolygon::Request &req, cob_3d_mapping_msgs::GetApproachPoseForPolygon::Response &res)
boost::shared_ptr< message_filters::Synchronizer< InflatedObstaclesSyncPolicy > > inflated_obstacles_sub_sync_
void inflatedObstacleDataCallback(const nav_msgs::GridCells::ConstPtr &obstacles_data, const nav_msgs::GridCells::ConstPtr &inflated_obstacles_data)
bool checkPerimeterCallback(cob_map_accessibility_analysis::CheckPerimeterAccessibility::Request &req, cob_map_accessibility_analysis::CheckPerimeterAccessibility::Response &res)
bool checkPose2DArrayCallback(cob_map_accessibility_analysis::CheckPointAccessibility::Request &req, cob_map_accessibility_analysis::CheckPointAccessibility::Response &res)
message_filters::sync_policies::ApproximateTime< nav_msgs::GridCells, nav_msgs::GridCells > InflatedObstaclesSyncPolicy
message_filters::Subscriber< nav_msgs::GridCells > inflated_obstacles_sub_
void obstacleDataCallback(const nav_msgs::GridCells::ConstPtr &obstacles_data)
void mapDataCallback(const nav_msgs::OccupancyGrid::ConstPtr &map_msg_data)
std::vector< geometry_msgs::Point > loadRobotFootprint(XmlRpc::XmlRpcValue &footprint_list)
message_filters::Subscriber< nav_msgs::GridCells > obstacles_sub_


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