0
$\begingroup$

Rosanswers logo

Lets say I have these names: "A", "B", "C"

There is a weird case where I use ROS_INFO_STREAM_NAMED(name, msg) and it streams the message to "A", even though the variable name is "B" or "C". However, when I hard code the name in: if (name == "B") ROS_INFO_STREAM_NAMED(name, msg) or ROS_INFO_STREAM_NAMED("B", msg) then it works.

I am callling ROS_INFO_STREAM_NAMED(name, msg) in my own log function which is located in a c++ interface. Classes A, B, and C all extends said interface and thus has access to log. Every ros spin cycle I would call on A's read function which calls on B's read function, which calls on C's read function. in each of these read functions, they would just log("reading"). But when I try to filter them out by name using rqt_logger_level, ros.<my package>.A would control the levels for what is suppose to be B and C's messages.


Originally posted by C-Dog on ROS Answers with karma: 36 on 2015-12-17

Post score: 0


Original comments

Comment by gvdhoorn on 2015-12-18:
I think it would help if you included the sources you are referring to. Could you edit your question and add some snippets (be sure to format them using the Preformatted text button).

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

First, I assume you are using a ROS_INFO_STREAM_NAMED, right? Otherwise, the question would make no sense.

Have a look at the documentation on the ROS wiki. Especiallly this part:

Do not use a variable with changing value as the name

Each named logger is stored in a static variable which is initialized on the use of the macro. Either use a string or a variable which string value is not going to change for future invocations since they won't be affecting the logger anymore.


Originally posted by mgruhler with karma: 12390 on 2015-12-18

This answer was NOT ACCEPTED on the original site

Post score: 3


Original comments

Comment by C-Dog on 2015-12-18:
So if I were to use a variable as the name, would I have to make it a constant string? As 8n the example before, can I have a const string in each class (A, B, C) that can be referenced later to log to the appropriate name?

Comment by mgruhler on 2015-12-18:
Sorry, I'm not quite sure I understand you correctly. However, as I understand the documentation, the variable you pass to the macro should be const, if this is what you are asking...

Comment by C-Dog on 2015-12-18:
You are right, but I was just trying to think of a way to achieve what this person was trying to make:https://github.com/ros/ros_comm/issues/561

$\endgroup$
0
$\begingroup$

Rosanswers logo

Actually I found the answer to my question here: https://github.com/ros/ros_comm/issues/561


Originally posted by C-Dog with karma: 36 on 2015-12-18

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.