|
|
|
@ -115,11 +115,17 @@ bool @(topic)_Subscriber::init(uint8_t topic_ID, std::condition_variable *t_send
@@ -115,11 +115,17 @@ bool @(topic)_Subscriber::init(uint8_t topic_ID, std::condition_variable *t_send
|
|
|
|
|
nodeName.append("@(topic)_subscriber"); |
|
|
|
|
PParam.rtps.setName(nodeName.c_str()); |
|
|
|
|
|
|
|
|
|
@[if ros2_distro]@ |
|
|
|
|
// Check if ROS_LOCALHOST_ONLY is set. This means that one wants to use only |
|
|
|
|
// the localhost network for data sharing. If FastRTPS/DDS >= 2.0 and |
|
|
|
|
// RMW_IMPLEMENTATION is FastDDS then the Shared Memory transport is used |
|
|
|
|
const char* localhost_only = std::getenv("ROS_LOCALHOST_ONLY"); |
|
|
|
|
if (localhost_only && strcmp(localhost_only, "1") == 0) { |
|
|
|
|
const char* rmw_implementation = std::getenv("RMW_IMPLEMENTATION"); |
|
|
|
|
const char* ros_distro = std::getenv("ROS_DISTRO"); |
|
|
|
|
if (localhost_only && strcmp(localhost_only, "1") == 0 |
|
|
|
|
&& ((rmw_implementation && ((strcmp(rmw_implementation, "rmw_fastrtps_cpp") == 0) |
|
|
|
|
|| (strcmp(rmw_implementation, "rmw_fastrtps_dynamic_cpp") == 0))) |
|
|
|
|
|| (!rmw_implementation && ros_distro && strcmp(ros_distro, "foxy") == 0))) { |
|
|
|
|
// Create a custom network UDPv4 transport descriptor |
|
|
|
|
// to whitelist the localhost |
|
|
|
|
auto localhostUdpTransport = std::make_shared<UDPv4TransportDescriptor>(); |
|
|
|
@ -132,16 +138,12 @@ bool @(topic)_Subscriber::init(uint8_t topic_ID, std::condition_variable *t_send
@@ -132,16 +138,12 @@ bool @(topic)_Subscriber::init(uint8_t topic_ID, std::condition_variable *t_send
|
|
|
|
|
PParam.rtps.userTransports.push_back(localhostUdpTransport); |
|
|
|
|
|
|
|
|
|
@[ if version.parse(fastrtps_version) >= version.parse('2.0')]@ |
|
|
|
|
const char* rmw_implementation = std::getenv("RMW_IMPLEMENTATION"); |
|
|
|
|
const char* ros_distro = std::getenv("RMW_IMPLEMENTATION"); |
|
|
|
|
if (((rmw_implementation && (strcmp(rmw_implementation, "rmw_fastrtps_cpp") == 0)) || (strcmp(rmw_implementation, "rmw_fastrtps_dynamic_cpp") == 0)) || |
|
|
|
|
(!rmw_implementation && strcmp(ros_distro, "foxy") == 0)) { |
|
|
|
|
// Add shared memory transport when available |
|
|
|
|
auto shmTransport = std::make_shared<SharedMemTransportDescriptor>(); |
|
|
|
|
PParam.rtps.userTransports.push_back(shmTransport); |
|
|
|
|
} |
|
|
|
|
@[ end if]@ |
|
|
|
|
} |
|
|
|
|
@[end if]@ |
|
|
|
|
|
|
|
|
|
mp_participant = Domain::createParticipant(PParam); |
|
|
|
|
|
|
|
|
|