From 8a9961f50f23f3fab625f5bb35c043333d255bf3 Mon Sep 17 00:00:00 2001 From: Chad Rockey Date: Mon, 11 Feb 2013 23:19:45 -0800 Subject: [PATCH 1/6] Create namespace.rst Proposed informational REP on driver namespaces. --- namespace.rst | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 namespace.rst diff --git a/namespace.rst b/namespace.rst new file mode 100644 index 000000000..b49211957 --- /dev/null +++ b/namespace.rst @@ -0,0 +1,114 @@ +REP: XXXX +Title: Driver Namespace Practices +Author: Chad Rockey +Status: Draft +Type: Informational +Content-Type: text/x-rst +Created: 11-Feb-2013 +Post-History: XX-Feb-2013 + + +Abstract +======== + +This REP aims to define the best practices for drivers handling namespaces. The best practice is to avoid drivers pushing themselves into a namespace. + +Specification +============= + +When launching a node from rosrun, the best practice is to: + + ROS_NAMESPACE=my_namespace rosrun my_package my_node + +When launching a node from a roslaunch file, the best practice is to: + + + + + + + +Drivers should not add a configurable namespace to all of their topics for the purposes of grouping the topics. + +For example, it is not appropriate to advertise the following if the node was launched in the global namespace ('/'): + + /camera/image_raw + + /camera/camera_info + +Instead, a driver should publish the following and warn that the driver was launched in the global namespace: + + image_raw + + camera_info + +If a driver publishes many topics, it is still appropriate to push these into local namespaces for grouping. One example is where a device contains multiple cameras such as a stereo pair or an OpenNI camera. For example, OpenNI publishes: + + depth/image_raw + + depth/camera_info + + rgb/image_raw + + rgb/camera_info + + depth_registered/image_raw + + depth_registered/camera_info + + ir/image_raw + + ir/camera_info + + projector/camera_info + +Rationale +========= + +Traditionally, some drivers, specifically cameras, have had friendlier usage for rosrun where their topics were grouped into a namespace. This had the advantage of avoiding collisions if two similar drivers were run manually. However, this led to issues when scaling to more complicated drivers or when composing simple launch files. Since it often required both topic remapping and namespace remapping, it wasn't always clear which took precedent - commonly resulting in duplicated or missing namespaces. + +Where nodes push all of their topics into a namespace, tools like 'rosnode list' will report the driver in the top level namespace, which could make it confusing as to which node is publishing in which namespaces. (For example 'camera_rgb' node publishes into 'top_camera' and 'camera_mono' publishes into 'side_camera'). + +This also affects parameters as they are usually in the node's private namespace. It is not immediately obvious which topic streams would be affected by 'camera_rgb/~exposure' if the namespace is independent from the driver. + +Backwards Compatibility +======================= + +All existing drivers should continue their current usage and it is up to the maintainer to determine if and when to drop support for automatic namespaces. + +It is possible to perform a tick-tock migration and warn users when the usage seems incorrect through code like the following: + + if (ros::names::remap("camera") != "camera") + { + + ROS_WARN("Remapping 'camera' has no effect! Start my_node in the " + "correct namespace instead.\nExample command-line usage:\n" + "\t$ ROS_NAMESPACE=%s rosrun my_package my_node", + ros::names::remap("camera").c_str()); + + } + if (ros::this_node::getNamespace() == "/") + { + + ROS_WARN("Started in the global namespace! This is probably wrong. my_node should be started" + "in a namespace.\nExample command-line usage:\n" + "\t$ ROS_NAMESPACE=my_namespace rosrun my_package my_node"); + + } + + +Copyright +========= + +This document has been placed in the public domain. + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: + From 73e6379d453910dfb8117ef0a2f3bc813e54882b Mon Sep 17 00:00:00 2001 From: Chad Rockey Date: Wed, 20 Feb 2013 16:03:43 -0800 Subject: [PATCH 2/6] Renamed to be REP 135 --- namespace.rst => rep-0135.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename namespace.rst => rep-0135.rst (100%) diff --git a/namespace.rst b/rep-0135.rst similarity index 100% rename from namespace.rst rename to rep-0135.rst From 224641fae882df7b8ca75e32e3b2529daa6ef03d Mon Sep 17 00:00:00 2001 From: Chad Rockey Date: Wed, 20 Feb 2013 16:09:01 -0800 Subject: [PATCH 3/6] Posting to ROS users on 20/Feb/2013 --- rep-0135.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rep-0135.rst b/rep-0135.rst index b49211957..14da6ec07 100644 --- a/rep-0135.rst +++ b/rep-0135.rst @@ -5,7 +5,7 @@ Status: Draft Type: Informational Content-Type: text/x-rst Created: 11-Feb-2013 -Post-History: XX-Feb-2013 +Post-History: 20-Feb-2013 Abstract From 150e045c04985911b5e5e455e9e324977b77629c Mon Sep 17 00:00:00 2001 From: Chad Rockey Date: Mon, 25 Feb 2013 13:41:28 -0800 Subject: [PATCH 4/6] Forgot to change REP number inside text. --- rep-0135.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rep-0135.rst b/rep-0135.rst index 14da6ec07..f8957eb91 100644 --- a/rep-0135.rst +++ b/rep-0135.rst @@ -1,4 +1,4 @@ -REP: XXXX +REP: 135 Title: Driver Namespace Practices Author: Chad Rockey Status: Draft From b8f4fa238775155263cf495b865d02eb4af169bc Mon Sep 17 00:00:00 2001 From: Chad Rockey Date: Tue, 12 Mar 2013 16:28:56 -0700 Subject: [PATCH 5/6] Added references to discussion for REP 135. --- rep-0135.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rep-0135.rst b/rep-0135.rst index f8957eb91..c73311a17 100644 --- a/rep-0135.rst +++ b/rep-0135.rst @@ -96,6 +96,15 @@ It is possible to perform a tick-tock migration and warn users when the usage se } +References +========== + +.. [1] ros-users discussion + (https://code.ros.org/lurker/message/20130221.001546.b8861935.en.html) + +.. [2] Github discussion + (https://github.com/ros-infrastructure/rep/pull/22) + Copyright ========= From 7df0bc2827ec18bcaf959dd1350c6db7ba2e895f Mon Sep 17 00:00:00 2001 From: Chad Rockey Date: Wed, 13 Mar 2013 16:23:53 -0700 Subject: [PATCH 6/6] Making REP 135 active. --- rep-0135.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rep-0135.rst b/rep-0135.rst index c73311a17..bb197ea3a 100644 --- a/rep-0135.rst +++ b/rep-0135.rst @@ -1,7 +1,7 @@ REP: 135 Title: Driver Namespace Practices Author: Chad Rockey -Status: Draft +Status: Active Type: Informational Content-Type: text/x-rst Created: 11-Feb-2013