Clean up topic namespace prefixes (#76)
Signed-off-by: Dan Rose <dan@digilabs.io>
This commit is contained in:
parent
b322f478de
commit
9b264c6480
4 changed files with 14 additions and 68 deletions
|
@ -49,7 +49,6 @@ ament_export_dependencies(rosidl_typesupport_introspection_c)
|
|||
ament_export_dependencies(rosidl_typesupport_introspection_cpp)
|
||||
|
||||
add_library(rmw_cyclonedds_cpp
|
||||
src/namespace_prefix.cpp
|
||||
src/rmw_node.cpp
|
||||
src/serdata.cpp
|
||||
src/serdes.cpp
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "namespace_prefix.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// static for internal linkage
|
||||
const char * const ros_topic_prefix = "rt";
|
||||
const char * const ros_service_requester_prefix = "rq";
|
||||
const char * const ros_service_response_prefix = "rr";
|
||||
|
||||
const std::vector<std::string> _ros_prefixes =
|
||||
{ros_topic_prefix, ros_service_requester_prefix, ros_service_response_prefix};
|
||||
} // extern "C"
|
||||
|
||||
/// Return the ROS specific prefix if it exists, otherwise "".
|
||||
std::string
|
||||
_get_ros_prefix_if_exists(const std::string & topic_name)
|
||||
{
|
||||
for (auto prefix : _ros_prefixes) {
|
||||
if (topic_name.rfind(std::string(prefix) + "/", 0) == 0) {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
||||
// Copyright 2019 ADLINK Technology Limited.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -15,20 +15,8 @@
|
|||
#ifndef NAMESPACE_PREFIX_HPP_
|
||||
#define NAMESPACE_PREFIX_HPP_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern const char * const ros_topic_prefix;
|
||||
extern const char * const ros_service_requester_prefix;
|
||||
extern const char * const ros_service_response_prefix;
|
||||
|
||||
extern const std::vector<std::string> _ros_prefixes;
|
||||
} // extern "C"
|
||||
|
||||
/// Return the ROS specific prefix if it exists, otherwise "".
|
||||
std::string
|
||||
_get_ros_prefix_if_exists(const std::string & topic_name);
|
||||
static const char ROS_TOPIC_PREFIX[] = "rt";
|
||||
static const char ROS_SERVICE_REQUESTER_PREFIX[] = "rq";
|
||||
static const char ROS_SERVICE_RESPONSE_PREFIX[] = "rr";
|
||||
|
||||
#endif // NAMESPACE_PREFIX_HPP_
|
||||
|
|
|
@ -1210,7 +1210,7 @@ static CddsPublisher * create_cdds_publisher(
|
|||
dds_entity_t topic;
|
||||
dds_qos_t * qos;
|
||||
|
||||
std::string fqtopic_name = make_fqtopic(ros_topic_prefix, topic_name, "", qos_policies);
|
||||
std::string fqtopic_name = make_fqtopic(ROS_TOPIC_PREFIX, topic_name, "", qos_policies);
|
||||
|
||||
auto sertopic = create_sertopic(
|
||||
fqtopic_name.c_str(), type_support->typesupport_identifier,
|
||||
|
@ -1432,7 +1432,7 @@ static CddsSubscription * create_cdds_subscription(
|
|||
dds_entity_t topic;
|
||||
dds_qos_t * qos;
|
||||
|
||||
std::string fqtopic_name = make_fqtopic(ros_topic_prefix, topic_name, "", qos_policies);
|
||||
std::string fqtopic_name = make_fqtopic(ROS_TOPIC_PREFIX, topic_name, "", qos_policies);
|
||||
|
||||
auto sertopic = create_sertopic(
|
||||
fqtopic_name.c_str(), type_support->typesupport_identifier,
|
||||
|
@ -2333,8 +2333,8 @@ static rmw_ret_t rmw_init_cs(
|
|||
pub_type_support = create_response_type_support(type_support->data,
|
||||
type_support->typesupport_identifier);
|
||||
subtopic_name =
|
||||
make_fqtopic(ros_service_requester_prefix, service_name, "Request", qos_policies);
|
||||
pubtopic_name = make_fqtopic(ros_service_response_prefix, service_name, "Reply", qos_policies);
|
||||
make_fqtopic(ROS_SERVICE_REQUESTER_PREFIX, service_name, "Request", qos_policies);
|
||||
pubtopic_name = make_fqtopic(ROS_SERVICE_RESPONSE_PREFIX, service_name, "Reply", qos_policies);
|
||||
} else {
|
||||
std::tie(pub_msg_ts, sub_msg_ts) =
|
||||
rmw_cyclonedds_cpp::make_request_response_value_types(type_supports);
|
||||
|
@ -2344,8 +2344,8 @@ static rmw_ret_t rmw_init_cs(
|
|||
sub_type_support = create_response_type_support(type_support->data,
|
||||
type_support->typesupport_identifier);
|
||||
pubtopic_name =
|
||||
make_fqtopic(ros_service_requester_prefix, service_name, "Request", qos_policies);
|
||||
subtopic_name = make_fqtopic(ros_service_response_prefix, service_name, "Reply", qos_policies);
|
||||
make_fqtopic(ROS_SERVICE_REQUESTER_PREFIX, service_name, "Request", qos_policies);
|
||||
subtopic_name = make_fqtopic(ROS_SERVICE_RESPONSE_PREFIX, service_name, "Reply", qos_policies);
|
||||
}
|
||||
|
||||
RCUTILS_LOG_DEBUG_NAMED("rmw_cyclonedds_cpp", "************ %s Details *********",
|
||||
|
@ -2781,7 +2781,7 @@ static rmw_ret_t get_endpoint_names_and_types_by_node(
|
|||
return ret;
|
||||
}
|
||||
const auto re_tp =
|
||||
std::regex("^" + std::string(ros_topic_prefix) + "(/.*)", std::regex::extended);
|
||||
std::regex("^" + std::string(ROS_TOPIC_PREFIX) + "(/.*)", std::regex::extended);
|
||||
const auto re_typ = std::regex("^(.*::)dds_::(.*)_$", std::regex::extended);
|
||||
const auto filter_and_map =
|
||||
[re_tp, re_typ, guids, node_name, no_demangle](const dds_builtintopic_endpoint_t & sample,
|
||||
|
@ -2872,8 +2872,8 @@ static rmw_ret_t get_cs_names_and_types_by_node(
|
|||
return ret;
|
||||
}
|
||||
const auto re_tp = std::regex(
|
||||
"^(" + std::string(ros_service_requester_prefix) + "|" +
|
||||
std::string(ros_service_response_prefix) + ")(/.*)(Request|Reply)$",
|
||||
"^(" + std::string(ROS_SERVICE_REQUESTER_PREFIX) + "|" +
|
||||
std::string(ROS_SERVICE_RESPONSE_PREFIX) + ")(/.*)(Request|Reply)$",
|
||||
std::regex::extended);
|
||||
const auto re_typ = std::regex("^(.*::)dds_::(.*)_(Response|Request)_$", std::regex::extended);
|
||||
const auto filter_and_map = [re_tp, re_typ, guids, node_name, looking_for_services](
|
||||
|
@ -2966,7 +2966,7 @@ static rmw_ret_t rmw_count_pubs_or_subs(
|
|||
RET_WRONG_IMPLID(node);
|
||||
auto node_impl = static_cast<CddsNode *>(node->data);
|
||||
|
||||
std::string fqtopic_name = make_fqtopic(ros_topic_prefix, topic_name, "", false);
|
||||
std::string fqtopic_name = make_fqtopic(ROS_TOPIC_PREFIX, topic_name, "", false);
|
||||
dds_entity_t rd;
|
||||
if ((rd = dds_create_reader(node_impl->pp, builtin_topic, NULL, NULL)) < 0) {
|
||||
RMW_SET_ERROR_MSG("rmw_count_pubs_or_subs failed to create reader");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue