map_merge_node.h
Go to the documentation of this file.
1 #ifndef MAP_MERGE_MAP_MERGE_NODE_H_
2 #define MAP_MERGE_MAP_MERGE_NODE_H_
3 
4 #include <atomic>
5 #include <forward_list>
6 #include <mutex>
7 #include <thread>
8 #include <unordered_map>
9 
10 #include <ros/ros.h>
12 
14 #include <map_merge_3d/typedefs.h>
15 
16 namespace map_merge_3d
17 {
33 {
34 private:
35  struct MapSubscription {
36  // protects map
37  std::mutex mutex;
40  };
41 
43 
44  /* node parameters */
48  std::string robot_map_topic_;
49  std::string robot_namespace_;
50  std::string world_frame_;
51  // compositing & estimation parameters
53 
54  // publishing
56  // periodical callbacks
60  // transforms for tf
61  std::vector<geometry_msgs::TransformStamped> tf_transforms_;
63  std::thread tf_thread_; // tf needs it own thread
64  std::atomic_flag tf_current_flag_; // whether tf_transforms_ are up to date
65  // with transforms_
66 
67  // maps robots namespaces to maps. does not own
68  std::unordered_map<std::string, MapSubscription*> robots_;
69  // owns maps -- iterator safe
70  std::forward_list<MapSubscription> subscriptions_;
73  // estimated transforms between maps
74  std::vector<Eigen::Matrix4f> transforms_;
75  std::mutex transforms_mutex_;
76 
77  std::string robotNameFromTopic(const std::string& topic);
78  bool isRobotMapTopic(const ros::master::TopicInfo& topic);
79  void mapUpdate(const PointCloud::ConstPtr& msg,
80  MapSubscription& subscription);
81  void publishTF();
82 
83 public:
84  MapMerge3d();
85 
91  void discovery();
92 
98  void mapCompositing();
99 
104  void transformsEstimation();
105 
111  std::vector<PointCloudConstPtr> getMaps();
112 
120  std::vector<Eigen::Matrix4f> getTransforms();
121 };
122 
124 
125 } // namespace map_merge_3d
126 
127 #endif // MAP_MERGE_MAP_MERGE_NODE_H_
std::unordered_map< std::string, MapSubscription * > robots_
void discovery()
Initiates discovery of new robots (maps) under current ROS core.
std::atomic_flag tf_current_flag_
std::vector< geometry_msgs::TransformStamped > tf_transforms_
void mapCompositing()
Composes and publishes the global map based on estimated transformations.
std::forward_list< MapSubscription > subscriptions_
std::string robotNameFromTopic(const std::string &topic)
Parameters for map merging high-level interface.
Definition: map_merging.h:28
ros::Publisher merged_map_publisher_
bool isRobotMapTopic(const ros::master::TopicInfo &topic)
void mapUpdate(const PointCloud::ConstPtr &msg, MapSubscription &subscription)
void transformsEstimation()
Estimates transformations between maps.
tf2_ros::TransformBroadcaster tf_publisher_
std::vector< Eigen::Matrix4f > transforms_
MapMergingParams map_merge_params_
std::vector< PointCloudConstPtr > getMaps()
Get currently stored maps.
pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr
Definition: typedefs.h:18
std::vector< Eigen::Matrix4f > getTransforms()
Get currently stored transforms. For each map there should be a transform between map and global refe...


map_merge_3d
Author(s): Jiri Horner
autogenerated on Mon Feb 28 2022 22:47:17