35 #include <boost/algorithm/string.hpp> 46 static std::string
getROSIP(std::string network_interface)
48 if (network_interface.empty())
49 network_interface =
"eth0";
51 typedef std::map< std::string, std::vector<std::string> > Map_IP;
52 Map_IP map_ip =
static_cast<Map_IP
>(qi::os::hostIPAddrs());
53 if ( map_ip.find(network_interface) == map_ip.end() ) {
54 std::cerr <<
"Could not find network interface named " << network_interface <<
", possible interfaces are ... ";
55 for (Map_IP::iterator it=map_ip.begin(); it!=map_ip.end(); ++it) std::cerr << it->first <<
" ";
56 std::cerr << std::endl;
60 static const std::string ip = map_ip[network_interface][0];
69 std::cout <<
"set prefix successfully to " << prefix << std::endl;
77 static void setMasterURI(
const std::string& uri,
const std::string& network_interface )
81 std::cout <<
"stopping ros init" << std::endl;
85 setenv(
"ROS_MASTER_URI", uri.c_str(), 1);
87 std::string my_master =
"__master="+uri;
88 std::map< std::string, std::string >
remap;
89 remap[
"__master"] = uri;
92 const char* ns_env = std::getenv(
"ROS_NAMESPACE");
102 return getenv(
"ROS_MASTER_URI");
ROSCPP_DECL const std::string & getURI()
static std::string getPrefix()
ROSCPP_DECL bool isInitialized()
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
static std::string prefix
ROSCPP_DECL std::string remap(const std::string &name)
static void setPrefix(std::string s)
static std::string getMasterURI()
static void setMasterURI(const std::string &uri, const std::string &network_interface)
static std::string getROSIP(std::string network_interface)
ROSCPP_DECL void shutdown()