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

`ROS_INFO_STREAM_NAMED(name, msg)` isn't streaming to the appropriate name

asked 2015-12-17 22:42:57 -0600

C-Dog gravatar image

updated 2015-12-18 09:29:17 -0600

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.

edit retag flag offensive close merge delete

Comments

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).

gvdhoorn gravatar image gvdhoorn  ( 2015-12-18 02:13:45 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2015-12-18 09:43:07 -0600

C-Dog gravatar image

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

edit flag offensive delete link more
3

answered 2015-12-18 09:04:01 -0600

mgruhler gravatar image

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.

edit flag offensive delete link more

Comments

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?

C-Dog gravatar image C-Dog  ( 2015-12-18 09:33:32 -0600 )edit

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...

mgruhler gravatar image mgruhler  ( 2015-12-18 09:37:46 -0600 )edit

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

C-Dog gravatar image C-Dog  ( 2015-12-18 09:44:21 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-12-17 22:41:33 -0600

Seen: 1,069 times

Last updated: Dec 18 '15