In addition to using rxconsole or manually using ros::this_node::getName(), there's an accidentally undocumented feature in cturtle that lets you specify an environment variable format string, e.g.:

export ROSCONSOLE_FORMAT='[${severity}] [${time}]: ${message}'

This is the default if unspecified.  You can use ${node} to add the node name, e.g.:

export ROSCONSOLE_FORMAT='[${severity}] [${time}] ${node}: ${message}'

I'm documenting this on the rosconsole page now, but the current possible formatting options are:
severity
message
time
thread
logger
file
line
function
node

Josh

On Thu, Sep 9, 2010 at 10:22 AM, Ivan Dryanovski <ivan.dryanovski@gmail.com> wrote:
Hi,

Can I access the name of a node from inside a cpp program? I know that
one of the argv** arguments passed through the program is
"__name:=FOO". Is there an easier way to access that, without having
to parse through the argv values?

What I am eventually interested in is having the name of the node
prepended to ROS_INFO statements. I was going to do it manually by
finding the name of the node and doing

ROS_INFO("%s: Some message here.", nodeName_);

Which would result in

FOO: Some message here.

If someone has a suggestion for a cleaner way to do this, let me know please!

Thanks,
Ivan Dryanovski
_______________________________________________
ros-users mailing list
ros-users@code.ros.org
https://code.ros.org/mailman/listinfo/ros-users