52 M_string::const_iterator it = remappings.find(
"__master");
53 if (it != remappings.end())
60 char *master_uri_env = NULL;
62 _dupenv_s(&master_uri_env, NULL,
"ROS_MASTER_URI");
64 master_uri_env = getenv(
"ROS_MASTER_URI");
69 g_uri = master_uri_env;
85 ROS_FATAL(
"Couldn't parse the master URI [%s] into a host:port pair.", g_uri.c_str());
109 ROS_FATAL(
"retry timeout must not be negative.");
112 g_retry_timeout = timeout;
119 return execute(
"getPid", args, result, payload,
false);
128 if (!
execute(
"getPublishedTopics", args, result, payload,
true))
134 for (
int i = 0; i < payload.
size(); i++)
136 topics.push_back(
TopicInfo(std::string(payload[i][0]), std::string(payload[i][1])));
147 if (!
execute(
"getSystemState", args, result, payload,
true))
153 for (
int i = 0; i < payload.
size(); ++i)
155 for (
int j = 0; j < payload[i].
size(); ++j)
158 for (
int k = 0; k < val.
size(); ++k)
160 std::string name = payload[i][j][1][k];
161 node_set.insert(name);
166 nodes.insert(nodes.end(), node_set.begin(), node_set.end());
171 #if defined(__APPLE__) 172 boost::mutex g_xmlrpc_call_mutex;
179 std::string master_host =
getHost();
180 uint32_t master_port =
getPort();
182 bool printed =
false;
189 #if defined(__APPLE__) 190 boost::mutex::scoped_lock lock(g_xmlrpc_call_mutex);
193 b = c->
execute(method.c_str(), request, response);
200 if (!printed && wait_for_master)
202 ROS_ERROR(
"[%s] Failed to contact master at [%s:%d]. %s", method.c_str(), master_host.c_str(), master_port, wait_for_master ?
"Retrying..." :
"");
206 if (!wait_for_master)
214 ROS_ERROR(
"[%s] Timed out trying to connect to the master after [%f] seconds", method.c_str(), g_retry_timeout.
toSec());
239 ROS_INFO(
"Connected to master at [%s:%d]", master_host.c_str(), master_port);
ROSCPP_DECL uint32_t getPort()
Get the port where the master runs.
ROSCPP_DECL void setRetryTimeout(ros::WallDuration timeout)
Set the max time this node should spend looping trying to connect to the master.
ROSCPP_DECL const std::string & getURI()
Get the full URI to the master (eg. http://host:port/)
ROSCPP_DECL bool check()
Check whether the master is up.
std::set< std::string > S_string
void init(const M_string &remappings)
ROSCPP_DECL bool splitURI(const std::string &uri, std::string &host, uint32_t &port)
ROSCPP_DECL const std::string & getName()
Returns the name of the current node.
ROSCPP_DECL bool getTopics(V_TopicInfo &topics)
Get the list of topics that are being published by all nodes.
std::vector< TopicInfo > V_TopicInfo
std::map< std::string, std::string > M_string
std::vector< std::string > V_string
ROSCPP_DECL bool ok()
Check whether it's time to exit.
ROSCPP_DECL bool execute(const std::string &method, const XmlRpc::XmlRpcValue &request, XmlRpc::XmlRpcValue &response, XmlRpc::XmlRpcValue &payload, bool wait_for_master)
Execute an XMLRPC call on the master.
ROSCPP_DECL bool isShuttingDown()
Returns whether or not ros::shutdown() has been (or is being) called.
ROSCPP_DECL const std::string & getHost()
Get the hostname where the master runs.
ROSCPP_DECL const std::string & getDefaultMasterURI()
returns the default master uri that is used if no other is specified, e.g. by defining ROS_MASTER_URI...
ros::WallDuration g_retry_timeout
bool execute(const char *method, XmlRpcValue const ¶ms, XmlRpcValue &result)
static const XMLRPCManagerPtr & instance()
ROSCPP_DECL bool getNodes(V_string &nodes)
Retreives the currently-known list of nodes from the master.
Contains information retrieved from the master about a topic.