|
27 | 27 | #include <tf2/LinearMath/Transform.h> |
28 | 28 | #include <tf2/transform_datatypes.h> |
29 | 29 |
|
30 | | -namespace mh_amcl { |
31 | | - |
32 | | -/** |
33 | | - * @brief Struct containing a transform and its associated weight |
34 | | - */ |
35 | | -typedef struct { |
36 | | - float weight; |
37 | | - tf2::Transform transform; |
38 | | -} TransformWeighted; |
39 | | - |
40 | | -/** |
41 | | - * @brief Overload of the operator '<' to be able to compare TransformWeighted |
42 | | - * structs |
43 | | - */ |
44 | | -bool operator<(const TransformWeighted &tw1, const TransformWeighted &tw2); |
45 | | - |
46 | | -/** |
47 | | - * MapMatcher class |
48 | | - * |
49 | | - * Performs the multi-resolution map matching process. It receives an occupancy |
50 | | - * grid map and laser scan data to find transformations (poses) that align the |
51 | | - * scan data with the map. It weights all potential transformations to select |
52 | | - * the higher quality candidates. |
53 | | - */ |
54 | | -class MapMatcher { |
55 | | -public: |
56 | | - explicit MapMatcher(std::shared_ptr<const nav_msgs::msg::OccupancyGrid> map); |
| 30 | +namespace mh_amcl |
| 31 | +{ |
57 | 32 |
|
58 | 33 | /** |
59 | | - * @brief Get the candidate transformations from the laser information and the |
60 | | - * map |
| 34 | + * @brief Struct containing a transform and its associated weight |
61 | 35 | */ |
62 | | - std::list<TransformWeighted> |
63 | | - get_matches(const sensor_msgs::msg::LaserScan &scan); |
| 36 | + typedef struct |
| 37 | + { |
| 38 | + float weight; |
| 39 | + tf2::Transform transform; |
| 40 | + } TransformWeighted; |
64 | 41 |
|
65 | | -protected: |
66 | | - static const int NUM_LEVEL_SCALE_COSTMAP = 4; |
| 42 | + /** |
| 43 | + * @brief Overload of the operator '<' to be able to compare TransformWeighted |
| 44 | + * structs |
| 45 | + */ |
| 46 | + bool operator<(const TransformWeighted &tw1, const TransformWeighted &tw2); |
67 | 47 |
|
68 | 48 | /** |
69 | | - * @brief Reduce the resolution of the map to half to perform the |
70 | | - * multi-resolution map-matching |
| 49 | + * MapMatcher class |
| 50 | + * |
| 51 | + * Performs the multi-resolution map matching process. It receives an occupancy |
| 52 | + * grid map and laser scan data to find transformations (poses) that align the |
| 53 | + * scan data with the map. It weights all potential transformations to select |
| 54 | + * the higher quality candidates. |
71 | 55 | */ |
72 | | - std::shared_ptr<beluga_ros::OccupancyGrid> |
73 | | - half_scale(std::shared_ptr<beluga_ros::OccupancyGrid> costmap_in); |
| 56 | + class MapMatcher |
| 57 | + { |
| 58 | + public: |
| 59 | + explicit MapMatcher(std::shared_ptr<const nav_msgs::msg::OccupancyGrid> map); |
| 60 | + |
| 61 | + /** |
| 62 | + * @brief Get the candidate transformations from the laser information and the |
| 63 | + * map |
| 64 | + */ |
| 65 | + std::list<TransformWeighted> |
| 66 | + get_matches(const sensor_msgs::msg::LaserScan &scan); |
| 67 | + |
| 68 | + protected: |
| 69 | + static const int NUM_LEVEL_SCALE_COSTMAP = 4; |
| 70 | + |
| 71 | + /** |
| 72 | + * @brief Reduce the resolution of the map to half to perform the |
| 73 | + * multi-resolution map-matching |
| 74 | + */ |
| 75 | + std::shared_ptr<beluga_ros::OccupancyGrid> |
| 76 | + half_scale(std::shared_ptr<beluga_ros::OccupancyGrid> costmap_in); |
| 77 | + |
| 78 | + /** |
| 79 | + * @brief Transform the LaserScan message in a vector of 3D points |
| 80 | + */ |
| 81 | + std::vector<tf2::Vector3> |
| 82 | + laser2points(const sensor_msgs::msg::LaserScan &scan); |
| 83 | + |
| 84 | + // Auxiliary methods to get the matches between the laser data and the map |
| 85 | + std::list<TransformWeighted> |
| 86 | + get_matches(int scale, const std::vector<tf2::Vector3> &scan, float min_x, |
| 87 | + float min_y, float max_y, float max_x); |
| 88 | + float match(int scale, std::shared_ptr<beluga_ros::OccupancyGrid> costmap, |
| 89 | + const std::vector<tf2::Vector3> &scan, tf2::Transform &transform); |
| 90 | + |
| 91 | + // Current costmaps |
| 92 | + std::vector<std::shared_ptr<beluga_ros::OccupancyGrid>> costmaps_; |
| 93 | + }; |
74 | 94 |
|
75 | 95 | /** |
76 | | - * @brief Transform the LaserScan message in a vector of 3D points |
| 96 | + * @brief wrapper to transform the costmap to ROS Occupancy grid message |
77 | 97 | */ |
78 | | - std::vector<tf2::Vector3> |
79 | | - laser2points(const sensor_msgs::msg::LaserScan &scan); |
80 | | - |
81 | | - // Auxiliary methods to get the matches between the laser data and the map |
82 | | - std::list<TransformWeighted> |
83 | | - get_matches(int scale, const std::vector<tf2::Vector3> &scan, float min_x, |
84 | | - float min_y, float max_y, float max_x); |
85 | | - float match(int scale, std::shared_ptr<beluga_ros::OccupancyGrid> costmap, |
86 | | - const std::vector<tf2::Vector3> &scan, tf2::Transform &transform); |
87 | | - |
88 | | - // Current costmaps |
89 | | - std::vector<std::shared_ptr<beluga_ros::OccupancyGrid>> costmaps_; |
90 | | -}; |
91 | | - |
92 | | -/** |
93 | | - * @brief wrapper to transform the costmap to ROS Occupancy grid message |
94 | | - */ |
95 | | -nav_msgs::msg::OccupancyGrid |
96 | | -toMsg(std::shared_ptr<beluga_ros::OccupancyGrid> costmap); |
| 98 | + nav_msgs::msg::OccupancyGrid |
| 99 | + toMsg(std::shared_ptr<beluga_ros::OccupancyGrid> costmap); |
97 | 100 |
|
98 | 101 | } // namespace mh_amcl |
99 | 102 |
|
|
0 commit comments