Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Add default ROS_MASTER_URI#961

Closed
jspricke wants to merge 1 commit intoros:kinetic-develfrom
jspricke:default_master_uri
Closed

Add default ROS_MASTER_URI#961
jspricke wants to merge 1 commit intoros:kinetic-develfrom
jspricke:default_master_uri

Conversation

@jspricke
Copy link
Copy Markdown
Member

No description provided.

raise ValueError("__master remapping argument '%s' improperly specified"%arg)
return val
return env[ROS_MASTER_URI]
if ROS_MASTER_URI in env:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use a one-liner instead:
env.get(ROS_MASTER_URI, 'http://localhost:11311')

@mikepurvis
Copy link
Copy Markdown
Member

I have no objection to this change, but I'm curious the motivation— are you trying to eliminate the need for any env setup at all in some baseline installed-into-/usr scenario?

@jspricke
Copy link
Copy Markdown
Member Author

Exactly, it's required by the Debian policy (and implemented in the packages in Debian already).

@mikepurvis
Copy link
Copy Markdown
Member

IMO, the only risk here is possible confusion for a user who tries to directly run a roscpp binary without sourcing the environment in a situation where they should have, and get a partially functional system rather than this error message which explicitly tells them what is wrong and how to fix it.

LGTM +1

raise ValueError("__master remapping argument '%s' improperly specified"%arg)
return val
return env[ROS_MASTER_URI]
env.get(ROS_MASTER_URI, 'http://localhost:11311')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this missing a return statement? I think it should be:

        return env.get(ROS_MASTER_URI, 'http://localhost:11311')

@jspricke
Copy link
Copy Markdown
Member Author

Oups, thx @evenator!

@mikepurvis
Copy link
Copy Markdown
Member

Since we're eliminating a potentially helpful user prompt here, I'd appreciate commentary from @tfoote or @dirk-thomas. Then again, my experience is that it's typically much more important to have explicitly set ROS_IP/ROS_HOSTNAME than ROS_MASTER_URI, so maybe this prompt is not really that important.

A middle ground might be to leave a non-fatal warning? Not sure if that's really complying with the spirit of the policy. Particularly since the message will be emitted once per node starting up, so it will get worse and worse the more of them are started.

@dirk-thomas
Copy link
Copy Markdown
Member

In order to consider using a default value for ROS_MASTER_URI if it is not set I think it would be crucial to define a constant in Python as well as C++ which every code can use. Otherwise the actual default value will be spread throughout the code base.

@ros/ros_team Please comment on the idea of having a default if ROS_MASTER_URI is not set.

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Jan 26, 2017

I'm fine with a default, as there is a reasonable default for ROS_MASTER_URI.

As @dirk-thomas said, this default should be replicated in as few places as possible. Also the documentation needs to be updated, for example: http://wiki.ros.org/ROS/EnvironmentVariables#ROS_MASTER_URI

It would be great to preserve the behavior for people installing to /opt or to a local folder since running without sourcing the setup file is almost always not what you meant to do, but I guess it's more trouble than it's worth.

@dirk-thomas
Copy link
Copy Markdown
Member

Sounds good. @jspricke Can you please update the PR accordingly. And check for other locations which use the environment variable and need to be updated to use the new default.

@jspricke
Copy link
Copy Markdown
Member Author

jspricke commented Jan 26, 2017 via email

@jspricke
Copy link
Copy Markdown
Member Author

I did a grep through all my ROS packages, and this is all I came up with. As we have an API to get the URI, I think it doesn't make sense to put it somewhere else.

@dirk-thomas
Copy link
Copy Markdown
Member

The API (e.g. the init() function) already wrap some logic around the retrieval of the environment variable (e.g. remapping). A global constant would therefore be good to have that any other code can use it as is (e.g. to show the default value for a command line interface in the help string). Does that make sense?

@jspricke
Copy link
Copy Markdown
Member Author

superseeded by #1666.

@jspricke jspricke closed this Mar 31, 2019
@jspricke jspricke deleted the default_master_uri branch March 31, 2019 08:08
dirk-thomas added a commit that referenced this pull request Feb 20, 2020
* Add default ROS_MASTER_URI

* roscpp: added getDefaultMasterUri()

* moved DEFAULT_MASTER_PORT and DEFAULT_MASTER_URI from rospy to rosgraph to make them usable in get_master_uri

* removed not needed try-catch-block in get_master_uri

* style of touched lines

* style of touched lines

* style of touched lines

Co-authored-by: Jochen Sprickerhof <github@jochen.sprickerhof.de>
Co-authored-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants