From 2cf14f89231ff7d2c60e49bc8868447f74ed22e6 Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Fri, 14 Jul 2017 06:54:42 -0700 Subject: [PATCH 1/4] Clean the namespace to get rid of double or trailing forward slashes #1094 --- clients/roscpp/src/libros/this_node.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/roscpp/src/libros/this_node.cpp b/clients/roscpp/src/libros/this_node.cpp index 7f15d7355a..f3f52955f6 100644 --- a/clients/roscpp/src/libros/this_node.cpp +++ b/clients/roscpp/src/libros/this_node.cpp @@ -150,6 +150,7 @@ void ThisNode::init(const std::string& name, const M_string& remappings, uint32_ : ("/" + namespace_) ; + namespace_ = names::clean(namespace_); std::string error; if (!names::validate(namespace_, error)) From 2d22f97004ca224342a72bcde0449af8c4dd339d Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Fri, 14 Jul 2017 08:10:12 -0700 Subject: [PATCH 2/4] Get rid of extra slashes in namespace #1094 --- tools/roslaunch/src/roslaunch/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/roslaunch/src/roslaunch/core.py b/tools/roslaunch/src/roslaunch/core.py index a6d43e371e..86f9e979c3 100644 --- a/tools/roslaunch/src/roslaunch/core.py +++ b/tools/roslaunch/src/roslaunch/core.py @@ -39,6 +39,7 @@ import os import logging +import re import socket import sys try: @@ -456,6 +457,7 @@ def __init__(self, package, node_type, name=None, namespace='/', \ self.type = node_type self.name = name or None self.namespace = rosgraph.names.make_global_ns(namespace or '/') + self.namespace = re.sub("//+", "/", self.namespace) self.machine_name = machine_name or None self.respawn = respawn self.respawn_delay = respawn_delay From 3f3e3b58283430073ed51903ccdbad7d4926fd64 Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Sat, 15 Jul 2017 09:17:06 -0700 Subject: [PATCH 3/4] names::clean() will turn a '/' into '' (is that a bug or desired?), but also prefix a slash as needed, so accommodating that here. #1094 --- clients/roscpp/src/libros/this_node.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/clients/roscpp/src/libros/this_node.cpp b/clients/roscpp/src/libros/this_node.cpp index f3f52955f6..91f2759044 100644 --- a/clients/roscpp/src/libros/this_node.cpp +++ b/clients/roscpp/src/libros/this_node.cpp @@ -145,12 +145,9 @@ void ThisNode::init(const std::string& name, const M_string& remappings, uint32_ namespace_ = "/"; } - namespace_ = (namespace_ == "/") - ? std::string("/") - : ("/" + namespace_) - ; - namespace_ = names::clean(namespace_); + if (namespace_ == "") + namespace_ = "/"; std::string error; if (!names::validate(namespace_, error)) From 235b615e4e27c1773a9b9ee406a781aa25766053 Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Tue, 18 Jul 2017 06:58:02 -0700 Subject: [PATCH 4/4] Simplifying and fixing, now namespaces.xml test passes. #1094 --- clients/roscpp/src/libros/this_node.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clients/roscpp/src/libros/this_node.cpp b/clients/roscpp/src/libros/this_node.cpp index 91f2759044..d27e1adf52 100644 --- a/clients/roscpp/src/libros/this_node.cpp +++ b/clients/roscpp/src/libros/this_node.cpp @@ -140,15 +140,12 @@ void ThisNode::init(const std::string& name, const M_string& remappings, uint32_ namespace_ = it->second; } - if (namespace_.empty()) + namespace_ = names::clean(namespace_); + if (namespace_.empty() || (namespace_[0] != '/')) { - namespace_ = "/"; + namespace_ = "/" + namespace_; } - namespace_ = names::clean(namespace_); - if (namespace_ == "") - namespace_ = "/"; - std::string error; if (!names::validate(namespace_, error)) {