ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Is it somehow possible to change the master URI and recall ros init? [closed]

asked 2015-10-04 11:35:56 -0600

I want to programm a node which is running and trying to find the ros master. It has an external non ROS interface to change the masters address and should if the master address is changed deregister and shutdown all connections, set the new master URI and connect again.

Is that possible somehow?

I tried to run ros::init multiple times with calling putenv("ROS_MASTER_URI=...") before but it does not seem to change the master uri when checking it with ros::master::getURI. Unfortunately this doesn't work. It seems to keep the first master URI.

        test++;
        std::string hostname="localhost";
        std::stringstream ss;
        ss<<"ROS_MASTER_URI="<<"http://"<<hostname<<test<<":11311";
        putenv(strdup(ss.str().c_str()));
        ros::init(argc, argv, "node");

        ROS_INFO_STREAM("Master: "<<ros::master::getURI());
        if(ros::master::check()) master_up();

->in a while loop always returns Master: http://localhost1:11311

Can I reset the master uri on runtime somehow?

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by cyborg-x1
close date 2015-10-04 12:12:59.381800

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-04 12:12:29 -0600

updated 2015-10-04 12:12:45 -0600

ok seems to be not possible, I found another question about that: http://answers.ros.org/question/13154...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-10-04 11:35:56 -0600

Seen: 1,499 times

Last updated: Oct 04 '15