-
Notifications
You must be signed in to change notification settings - Fork 914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable rosout.log by using environment variable #1425
Conversation
Rather than blocking startup of the node, can we do something like check on each message received until either we get an answer or 10s have elapsed, and then stop checking? |
That may leave a rosout.log file on the disk. When the first message arrives the master must have been online, I guess? What about opening the file upon the first received message? Another idea is to make it runtime parameter, so we check the paramter every time when we are going to log a message. What do you think? I don't like environment variable solution because, when roslaunch spawns rosout process, it seems not to use the environment variables defined in the launch file. |
Using environment variable will be a clean change though |
The parameter server may not be available at the time rosout is starting.
The test failure seems unrelated? |
tools/rosout/rosout.cpp
Outdated
|
||
if (!disable_file_logging) | ||
const char* disable_file_logging = getenv("ROSOUT_DISABLE_FILE_LOGGING"); | ||
if (!disable_file_logging || !boost::iequals(disable_file_logging, "true")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new to me. Other than the allocation, is there any advantage to this over just instantiating a throwaway std::string
and comparing that directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string
cannot be constructed with nullptr
. So anyway, checking for null
is required. I first tried std::string
and got an exception complaining about nullptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case insensitive comparison to true
seems to be rather restrictive. I would suggest the opposite and if the string is empty or 0
(maybe "false", "off"?) consider the value to be false
, otherwise true
.
LGTM, but you'll need to add the boost dependency to this package's package.xml: https://github.com/ros/ros_comm/blob/melodic-devel/tools/rosout/package.xml#L15-L19 IMO a good opportunity to consolidate the build/run deps and switch this one to The wiki page describing the parameter will need to be updated to describe the envvar, once this is merged: http://wiki.ros.org/rosout#rosout.log Will wait on @dirk-thomas for any final thoughts. |
Thanks. Updated the |
The wiki page has been updated. Ping @dirk-thomas |
You may need to add Boost to CMake as well:
You could also avoid needing to pull in the Boost dependency altogether by doing something like the following (and let's avoid the nasty
|
Thanks for the suggestions.
This is not needed for boost I could use Opinions? |
Added |
The test failure is not related. |
Just as a note: this patch revert the logic added in #1381. It also looks like that the documentation has already been updated to reflect the proposed change: http://wiki.ros.org/action/info/rosout?action=diff&rev2=53&rev1=52 Please do not update the wiki with not yet merged changes since that feature is not yet usable by users. |
Yes, lesson learned. Will do the change. |
tools/rosout/rosout.cpp
Outdated
|| strcmp(disable_file_logging, "0") == 0 | ||
|| boost::iequals(disable_file_logging, "false") | ||
|| boost::iequals(disable_file_logging, "off") | ||
|| boost::iequals(disable_file_logging, "no")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am just wondering if the case insensitive comparison if worth the boost dependency? Each condition could be duplicates to check for lower case as well as upper case (not allowing mixed case)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need boost for case-insensitivity. Just convert the input value to lower case before comparing:
Thank you for the patch and for iterating on it. |
Thanks for the cleanup! |
rosout is usually started together with roscore. There may be race condition so that it cannot connect to the master during initialization. This change lets rosout wait at most 1 second for the master to be online, so that it can read the ROS parameter.