Skip to content

Node::get_effective_namespace returns invalid namespace if sub-namespace is empty #1656

@devrite

Description

@devrite

Hi everyone

I tested this on foxy but as you can see from:

RCLCPP_LOCAL
std::string
create_effective_namespace(const std::string & node_namespace, const std::string & sub_namespace)
{
// Assumption is that both the node_namespace and sub_namespace are conforming
// and do not need trimming of `/` and other things, as they were validated
// in other functions already.
if (node_namespace.back() == '/') {
// this is the special case where node_namespace is just `/`
return node_namespace + sub_namespace;
} else {
return node_namespace + "/" + sub_namespace;
}
}

it returns an namespace with a slash at the end in both cases. rclcpp::expand_topic_or_service_name will then throw an exception it represents an invalid namespace format (e.g., '/' at the end are not allowed).

Is this still the case? Or rclcpp behaving wrong in this case. But since we usually specify namespaces without slashes almost everywhere I can recall using it I think even if it were permitted we should return the namespace without the slash.

BR, Markus

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions