File tree Expand file tree Collapse file tree 2 files changed +37
-26
lines changed Expand file tree Collapse file tree 2 files changed +37
-26
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ extern "C"
2727#include "rcl/node.h"
2828#include "rcutils/logging_macros.h"
2929#include "rcutils/macros.h"
30+ #include "rcutils/strdup.h"
3031#include "rcl/time.h"
3132#include "rmw/time.h"
3233#include "rmw/error_handling.h"
@@ -80,20 +81,25 @@ rcl_publisher_init(
8081
8182 // Expand and remap the given topic name.
8283 char * remapped_topic_name = NULL ;
83- rcl_ret_t ret = rcl_node_resolve_name (
84- node ,
85- topic_name ,
86- * allocator ,
87- false,
88- false,
89- & remapped_topic_name );
90- if (ret != RCL_RET_OK ) {
91- if (ret == RCL_RET_TOPIC_NAME_INVALID || ret == RCL_RET_UNKNOWN_SUBSTITUTION ) {
92- ret = RCL_RET_TOPIC_NAME_INVALID ;
93- } else if (ret != RCL_RET_BAD_ALLOC ) {
94- ret = RCL_RET_ERROR ;
84+ rcl_ret_t ret ;
85+ if (!options -> qos .avoid_ros_namespace_conventions ) {
86+ ret = rcl_node_resolve_name (
87+ node ,
88+ topic_name ,
89+ * allocator ,
90+ false,
91+ false,
92+ & remapped_topic_name );
93+ if (ret != RCL_RET_OK ) {
94+ if (ret == RCL_RET_TOPIC_NAME_INVALID || ret == RCL_RET_UNKNOWN_SUBSTITUTION ) {
95+ ret = RCL_RET_TOPIC_NAME_INVALID ;
96+ } else if (ret != RCL_RET_BAD_ALLOC ) {
97+ ret = RCL_RET_ERROR ;
98+ }
99+ goto cleanup ;
95100 }
96- goto cleanup ;
101+ } else {
102+ remapped_topic_name = rcutils_strdup (topic_name , * allocator );
97103 }
98104 RCUTILS_LOG_DEBUG_NAMED (
99105 ROS_PACKAGE_NAME , "Expanded and remapped topic name '%s'" , remapped_topic_name );
Original file line number Diff line number Diff line change @@ -72,20 +72,25 @@ rcl_subscription_init(
7272
7373 // Expand and remap the given topic name.
7474 char * remapped_topic_name = NULL ;
75- rcl_ret_t ret = rcl_node_resolve_name (
76- node ,
77- topic_name ,
78- * allocator ,
79- false,
80- false,
81- & remapped_topic_name );
82- if (ret != RCL_RET_OK ) {
83- if (ret == RCL_RET_TOPIC_NAME_INVALID || ret == RCL_RET_UNKNOWN_SUBSTITUTION ) {
84- ret = RCL_RET_TOPIC_NAME_INVALID ;
85- } else if (ret != RCL_RET_BAD_ALLOC ) {
86- ret = RCL_RET_ERROR ;
75+ rcl_ret_t ret ;
76+ if (!options -> qos .avoid_ros_namespace_conventions ) {
77+ ret = rcl_node_resolve_name (
78+ node ,
79+ topic_name ,
80+ * allocator ,
81+ false,
82+ false,
83+ & remapped_topic_name );
84+ if (ret != RCL_RET_OK ) {
85+ if (ret == RCL_RET_TOPIC_NAME_INVALID || ret == RCL_RET_UNKNOWN_SUBSTITUTION ) {
86+ ret = RCL_RET_TOPIC_NAME_INVALID ;
87+ } else if (ret != RCL_RET_BAD_ALLOC ) {
88+ ret = RCL_RET_ERROR ;
89+ }
90+ goto cleanup ;
8791 }
88- goto cleanup ;
92+ } else {
93+ remapped_topic_name = rcutils_strdup (topic_name , * allocator );
8994 }
9095 RCUTILS_LOG_DEBUG_NAMED (
9196 ROS_PACKAGE_NAME , "Expanded and remapped topic name '%s'" , remapped_topic_name );
You can’t perform that action at this time.
0 commit comments