CConnectionManager.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <ros/ros.h>
13 #include <multimaster_msgs_fkie/DiscoverMasters.h>
14 #include <mrpt_msgs/GraphSlamAgent.h>
15 #include <mrpt_msgs/GraphSlamAgents.h>
17 
19 #include <mrpt/system/datetime.h>
20 #include <mrpt/system/os.h>
22 #include <mrpt/math/utils.h>
23 
24 #include <algorithm>
25 #include <iterator>
26 #include <iostream>
27 #include <string>
28 #include <vector>
29 
30 #include <cstdlib>
31 
32 namespace mrpt { namespace graphslam { namespace detail {
33 
38 {
39 public:
40  //typedef std::vector<mrpt_msgs::GraphSlamAgent>::iterator agents_it;
41  //typedef std::vector<mrpt_msgs::GraphSlamAgent>::const_iterator agents_cit;
42  typedef mrpt_msgs::GraphSlamAgents::_list_type::iterator agents_it;
43  typedef mrpt_msgs::GraphSlamAgents::_list_type::const_iterator agents_cit;
44 
47  mrpt::utils::COutputLogger* logger,
48  ros::NodeHandle* nh_in);
60  void getNearbySlamAgents(mrpt_msgs::GraphSlamAgents* agents_vec,
61  bool ignore_self=true);
64  const mrpt_msgs::GraphSlamAgents& getNearbySlamAgents();
69  const mrpt_msgs::GraphSlamAgents& getNearbySlamAgentsCached() const;
70 
77  void setupComm();
79  const std::string& getTrimmedNs() const;
80 
81 private:
85  std::string own_ns;
98  void setupSubs();
99  void setupPubs();
100  void setupSrvs();
114  static bool convert(
115  const multimaster_msgs_fkie::ROSMaster& ros_master,
116  mrpt_msgs::GraphSlamAgent* slam_agent);
118  static void convert(
119  const mrpt_msgs::GraphSlamAgent& slam_agent,
120  multimaster_msgs_fkie::ROSMaster* ros_master);
126  static std::string extractHostnameOrIP(const std::string& str,
127  unsigned short* agent_port=NULL);
128 
130  mrpt::utils::COutputLogger* m_logger;
133 
140  mrpt_msgs::GraphSlamAgents m_nearby_slam_agents;
141 
143 
144 };
145 
146 } } } // end of namespaces
147 
152 bool operator==(
153  const multimaster_msgs_fkie::ROSMaster& master1,
154  const multimaster_msgs_fkie::ROSMaster& master2);
155 bool operator!=(
156  const multimaster_msgs_fkie::ROSMaster& master1,
157  const multimaster_msgs_fkie::ROSMaster& master2);
164 bool operator==(
165  const mrpt_msgs::GraphSlamAgent& agent1,
166  const mrpt_msgs::GraphSlamAgent& agent2);
167 bool operator!=(
168  const mrpt_msgs::GraphSlamAgent& agent1,
169  const mrpt_msgs::GraphSlamAgent& agent2);
170 bool operator<(
171  const mrpt_msgs::GraphSlamAgent& agent1,
172  const mrpt_msgs::GraphSlamAgent& agent2);
179 bool operator==(
180  const multimaster_msgs_fkie::ROSMaster& master,
181  const mrpt_msgs::GraphSlamAgent& agent);
182 bool operator==(
183  const mrpt_msgs::GraphSlamAgent& agent,
184  const multimaster_msgs_fkie::ROSMaster& master);
185 bool operator!=(
186  const multimaster_msgs_fkie::ROSMaster& master,
187  const mrpt_msgs::GraphSlamAgent& agent);
188 bool operator!=(
189  const mrpt_msgs::GraphSlamAgent& agent,
190  const multimaster_msgs_fkie::ROSMaster& master);
191 
const mrpt_msgs::GraphSlamAgents & getNearbySlamAgentsCached() const
Read-only method for accessing list of nearby agents. This doesn&#39;t update the internal list of GraphS...
bool operator!=(const multimaster_msgs_fkie::ROSMaster &master1, const multimaster_msgs_fkie::ROSMaster &master2)
void setupComm()
Wrapper method around the private setup* class methods.
const mrpt_msgs::GraphSlamAgents & getNearbySlamAgents()
Read-only method for accessing list of nearby agents.
bool operator==(const multimaster_msgs_fkie::ROSMaster &master1, const multimaster_msgs_fkie::ROSMaster &master2)
ROSMaster instances are considered the same if the "uri" field is the same.
void updateNearbySlamAgents()
Update the internal list of nearby SLAM agents.
mrpt_msgs::GraphSlamAgents::_list_type::const_iterator agents_cit
mrpt_msgs::GraphSlamAgents::_list_type::iterator agents_it
std::string own_ns
Namespace under which we are running. Corresponds to the agent_ID_str with which the nodes are going ...
ros::NodeHandle * m_nh
Pointer to the Ros NodeHanle instance.
mrpt_msgs::GraphSlamAgents m_nearby_slam_agents
List of slam agents in the current agent&#39;s neighborhood.
bool operator<(const mrpt_msgs::GraphSlamAgent &agent1, const mrpt_msgs::GraphSlamAgent &agent2)
const std::string & getTrimmedNs() const
Get the agent ROS namespace.
CConnectionManager(mrpt::utils::COutputLogger *logger, ros::NodeHandle *nh_in)
Constructor.
mrpt::utils::COutputLogger * m_logger
Pointer to the logging instance.
static std::string extractHostnameOrIP(const std::string &str, unsigned short *agent_port=NULL)
Remove http:// prefix and port suffix from the string and return result.
static bool convert(const multimaster_msgs_fkie::ROSMaster &ros_master, mrpt_msgs::GraphSlamAgent *slam_agent)
ROSMaster ==> mrpt_msgs::GraphSlamAgent.
Class responsible of handling the network communication between SLAM agents in the Multi-Robot graphS...


mrpt_graphslam_2d
Author(s): Nikos Koukis
autogenerated on Sat May 2 2020 03:44:17