Understanding Graph Resource Names

asked 2019-04-03 13:54:06 -0500

bakerhillpins gravatar image

I'm new to ROS and working through the tutorials using the ROS on Windows distribution but at this point it's all just ROS concepts. For whatever reason I'm having a hard time reconciling Graph Resource Names as they are described in the Wiki and how it is actually playing out while I am running the UsingRqtconsoleRoslaunch tutorial.

As, I've run the tutorial verbatim I'm not going to copy and paste in the snippets from the linked page but the questions I have stem from sections 2.3 - 2.5.

In this tutorial specifically we created a Launch file that spins up 2 turtlesim nodes into 2 different namespaces. The result of running the launch file is this:

C:\opt\ros\melodic\x64\share\turtlesim>rosnode list
/mimic
/rosout
/rostopic_7280_1554293486664
/rqt_gui_py_node_5744
/rqt_gui_py_node_632
/rqt_gui_py_node_8244
/turtlesim1/sim
/turtlesim2/sim

Noting the 2 nodes called /turtlesim1/sim and /turtlesim2/sim which are expected based upon the name given in the .launch file. The concept of running the same code in 2 different nodes is clear and makes sense. However, I am getting confused with respect to the mimic node connections to the topics. The Pub/Sub connections are made to/from turtlesim1/turtle1 and turtlesim2/turtle1, yet I would have expected turtlesim1/sim/turtle1 and turtlesim2/sim/turtle1 since reading the Wiki lead me to believe that I need to qualify the Turtle1 service with the node name.

So I've examined one of the 2 nodes: (I've trimmed the output to what I feel is necessary)

C:\opt\ros\melodic\x64\share\turtlesim>rosnode info /turtlesim1/sim
--------------------------------------------------------------------------------
Node [/turtlesim1/sim]
Publications:
 * /rosout [rosgraph_msgs/Log]
 * /turtlesim1/turtle1/color_sensor [turtlesim/Color]
 * /turtlesim1/turtle1/pose [turtlesim/Pose]

Subscriptions:
 * /turtlesim1/turtle1/cmd_vel [geometry_msgs/Twist]

Services:
 * /turtlesim1/clear
 * /turtlesim1/kill
 * /turtlesim1/reset
 * /turtlesim1/sim/get_loggers
 * /turtlesim1/sim/set_logger_level
 * /turtlesim1/spawn
 * /turtlesim1/turtle1/set_pen
 * /turtlesim1/turtle1/teleport_absolute
 * /turtlesim1/turtle1/teleport_relative

The output reinforces the Mimic connection but it's unexpected. As I mentioned I thought that since the Turtle1 Service is running within the /turtlesim1/sim node that they would be namespace qualified to the node and result in something like:

 * /turtlesim1/sim/turtle1/set_pen
 * /turtlesim1/sim/turtle1/teleport_absolute

I guess the confusion is that the namespace resolution seems to derive from the group element's namespace given in the .launch file and not the actual Name of the node. So I couldn't just look at node names from the output of the rosnode list command and figure out the resolution to services on a Node. Is that correct? The Wiki is using the term Name though.

By default, resolution is done relative to the node's namespace. For example, the node /wg/node1 has the namespace /wg, so the name node2 will resolve to /wg/node2.

Seems like that would make it harder to visualize the topology of a network, no? Hope that I'm making sense here.

edit retag flag offensive close merge delete

Comments

After spending more time in ROS it seems to me that the reason the node name is left out of the Resource Name is because this would tie a resource to a particular Node and make it difficult to make generic connections. I.e. If the node name changed from 'sim' to 'simNext'. However, doesn't that problem exist at the next layer down, the namespace of turtlesim1/2? I guess I'm missing something with respect to how services and pub/sub connections are resolved across namespaces and I'll need to review that again.

bakerhillpins gravatar imagebakerhillpins ( 2019-04-17 08:41:21 -0500 )edit