Re: [ros-users] Access to node name (cpp)

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Ruben Smits
Date:  
To: ros-users
Subject: Re: [ros-users] Access to node name (cpp)
On Thursday 09 September 2010 20:24:20 Tully Foote wrote:
> Ivan,
> The node name is actually embedded in the ROS_INFO output, although it does
> not display to the console.
>
> If you are debugging several nodes at once I suggest you try the tool
> rxconsole. http://www.ros.org/wiki/rxconsole It displays the debugging
> info, line number, and more. And its output can be filtered using regexs.
> It's display can be paused and scrolled back, refiltered etc.
>
> This also will work for multiple machines and terminals, so you don't have
> to worry about launching everything together to get debugging interleaved.
>
> To your question, I don't actually know how to print the name. Good design
> principles would suggest that you don't need to know the name within the
> node because all names can be remapped, and if they are then they would be
> fragile if the name was coded inside.


I think in roscpp
<code>
ros::this_node.getName()
</code>
should do the trick. See
http://www.ros.org/doc/api/roscpp/html/namespaceros_1_1this__node.html
for more details.

Ruben

> Tully
>
> On Thu, Sep 9, 2010 at 10:22 AM, Ivan Dryanovski
> <<mailto: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
> <mailto:ros-users@code.ros.org>
> https://code.ros.org/mailman/listinfo/ros-users
>
>
>
> --
> Tully Foote
> Systems Engineer
> Willow Garage, Inc.
> <mailto:tfoote@willowgarage.com>
> (650) 475-2827