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 )
79 if (ros::isInitialized() )
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;
96 std::cout <<
"using master ip: " << ros::master::getURI() << std::endl;
101 return getenv(
"ROS_MASTER_URI");
static std::string getPrefix()
Definition: ros_env.hpp:72
static std::string prefix
Definition: ros_env.hpp:64
static void setPrefix(std::string s)
Definition: ros_env.hpp:66
static std::string getMasterURI()
Definition: ros_env.hpp:99
static void setMasterURI(const std::string &uri, const std::string &network_interface)
Definition: ros_env.hpp:77
static std::string getROSIP(std::string network_interface)
Definition: ros_env.hpp:46