00001 /* +---------------------------------------------------------------------------+ 00002 | Mobile Robot Programming Toolkit (MRPT) | 00003 | http://www.mrpt.org/ | 00004 | | 00005 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file | 00006 | See: http://www.mrpt.org/Authors - All rights reserved. | 00007 | Released under BSD License. See details in http://www.mrpt.org/License | 00008 +---------------------------------------------------------------------------+ */ 00009 00010 #pragma once 00011 00012 #include "mrpt_graphslam_2d/CConnectionManager.h" 00013 #include "mrpt_graphslam_2d/TNeighborAgentMapProps.h" 00014 #include "mrpt_graphslam_2d/misc/common.h" 00015 00016 #include <ros/ros.h> 00017 #include <nav_msgs/OccupancyGrid.h> 00018 #include <nav_msgs/Path.h> 00019 #include <mrpt_msgs/GraphSlamAgents.h> 00020 #include <mrpt/maps/COccupancyGridMap2D.h> 00021 #include <mrpt/maps/CSimplePointsMap.h> 00022 #include <mrpt/slam/CGridMapAligner.h> 00023 #include <mrpt_bridge/map.h> 00024 #include <mrpt/system/filesystem.h> 00025 #include <mrpt/system/os.h> 00026 #include <mrpt/math/utils.h> 00027 #include <mrpt/graphslam/misc/CWindowManager.h> 00028 #include <mrpt/opengl/CAxis.h> 00029 #include <mrpt/opengl/CGridPlaneXY.h> 00030 #include <mrpt/opengl/CSetOfLines.h> 00031 00032 #include <mrpt/version.h> 00033 #if MRPT_VERSION>=0x199 00034 #include <mrpt/system/COutputLogger.h> 00035 #include <mrpt/img/TColorManager.h> 00036 using namespace mrpt::system; 00037 using namespace mrpt::img; 00038 #else 00039 #include <mrpt/utils/COutputLogger.h> 00040 #include <mrpt/utils/TColorManager.h> 00041 using namespace mrpt::utils; 00042 #endif 00043 00044 00045 00046 #include <iterator> 00047 00048 const mrpt::poses::CPose3D EMPTY_POSE; 00049 00050 namespace mrpt { namespace graphslam { 00051 00058 class CMapMerger 00059 { 00060 public: 00061 typedef std::map<TNeighborAgentMapProps*, COccupancyGridMap2D::Ptr> maps_t; 00062 typedef std::map<TNeighborAgentMapProps*, bool> neighbor_to_is_used_t; 00063 typedef std::map<TNeighborAgentMapProps*, mrpt::poses::CPose2D> neighbor_to_rel_pose_t; 00064 00066 typedef std::map< 00067 TNeighborAgentMapProps*, 00068 mrpt::opengl::CSetOfLines::Ptr> trajectories_t; 00069 typedef std::vector<TNeighborAgentMapProps*> neighbors_t; 00070 CMapMerger( 00071 mrpt::utils::COutputLogger* logger_in, 00072 ros::NodeHandle* nh_in); 00073 ~CMapMerger(); 00074 void mergeMaps(); 00079 bool updateState(); 00080 private: 00084 void monitorKeystrokes(mrpt::graphslam::CWindowObserver* win_observer); 00085 void initWindowVisuals(mrpt::graphslam::CWindowManager* win_manager); 00086 mrpt::graphslam::CWindowManager* initWindowVisuals(); 00087 00091 neighbors_t m_neighbors; 00092 std::map<TNeighborAgentMapProps*, CWindowManager*> m_neighbors_to_windows; 00093 mrpt::utils::COutputLogger* m_logger; 00094 ros::NodeHandle* m_nh; 00095 mrpt::graphslam::detail::CConnectionManager m_conn_manager; 00096 00099 std::string m_global_ns; 00103 std::string m_options_ns; 00104 std::string m_feedback_ns; 00105 size_t m_queue_size; 00106 mrpt::slam::CGridMapAligner::TConfigParams m_alignment_options; 00107 00108 std::string quit_keypress1; 00109 std::string quit_keypress2; 00110 std::string map_merge_keypress; 00111 00112 bool save_map_merging_results; 00113 00114 mrpt::graphslam::CWindowManager* m_fused_map_win_manager; 00115 00116 }; // end of CMapMerger 00117 00118 } } // end of namespaces 00119