|
|
@ -13,14 +13,27 @@ |
|
|
|
@{ |
|
|
|
@{ |
|
|
|
from packaging import version |
|
|
|
from packaging import version |
|
|
|
import genmsg.msgs |
|
|
|
import genmsg.msgs |
|
|
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
from px_generate_uorb_topic_helper import * # this is in Tools/ |
|
|
|
from px_generate_uorb_topic_helper import * # this is in Tools/ |
|
|
|
|
|
|
|
|
|
|
|
topic = alias if alias else spec.short_name |
|
|
|
topic = alias if alias else spec.short_name |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
ros2_distro = ros2_distro.decode("utf-8") |
|
|
|
ros2_distro = ros2_distro.decode("utf-8") |
|
|
|
except AttributeError: |
|
|
|
except AttributeError: |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topic_name = topic |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# For ROS, use the topic pattern convention defined in |
|
|
|
|
|
|
|
# http://wiki.ros.org/ROS/Patterns/Conventions |
|
|
|
|
|
|
|
if ros2_distro: |
|
|
|
|
|
|
|
topic_name_split = re.sub( r"([A-Z])", r" \1", topic).split() |
|
|
|
|
|
|
|
topic_name = topic_name_split[0] |
|
|
|
|
|
|
|
for w in topic_name_split[1:]: |
|
|
|
|
|
|
|
topic_name += "_" + w |
|
|
|
|
|
|
|
topic_name = topic_name.lower() |
|
|
|
}@ |
|
|
|
}@ |
|
|
|
/**************************************************************************** |
|
|
|
/**************************************************************************** |
|
|
|
* |
|
|
|
* |
|
|
@ -87,7 +100,7 @@ using SharedMemTransportDescriptor = eprosima::fastdds::rtps::SharedMemTransport |
|
|
|
Domain::removeParticipant(mp_participant); |
|
|
|
Domain::removeParticipant(mp_participant); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool @(topic)_Publisher::init(const std::string &ns) |
|
|
|
bool @(topic)_Publisher::init(const std::string &ns, std::string topic_name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Create RTPSParticipant |
|
|
|
// Create RTPSParticipant |
|
|
|
ParticipantAttributes PParam; |
|
|
|
ParticipantAttributes PParam; |
|
|
@ -156,21 +169,17 @@ bool @(topic)_Publisher::init(const std::string &ns) |
|
|
|
@[ if ros2_distro == "ardent"]@ |
|
|
|
@[ if ros2_distro == "ardent"]@ |
|
|
|
Wparam.qos.m_partition.push_back("rt"); |
|
|
|
Wparam.qos.m_partition.push_back("rt"); |
|
|
|
std::string topicName = ns; |
|
|
|
std::string topicName = ns; |
|
|
|
topicName.append("@(topic)_PubSubTopic"); |
|
|
|
|
|
|
|
Wparam.topic.topicName = topicName; |
|
|
|
|
|
|
|
@[ else]@ |
|
|
|
@[ else]@ |
|
|
|
std::string topicName = "rt/"; |
|
|
|
std::string topicName = "rt/"; |
|
|
|
topicName.append(ns); |
|
|
|
topicName.append(ns); |
|
|
|
topicName.append("@(topic)_PubSubTopic"); |
|
|
|
|
|
|
|
Wparam.topic.topicName = topicName; |
|
|
|
|
|
|
|
@[ end if]@ |
|
|
|
@[ end if]@ |
|
|
|
// ROS2 default publish mode QoS policy |
|
|
|
// ROS2 default publish mode QoS policy |
|
|
|
Wparam.qos.m_publishMode.kind = ASYNCHRONOUS_PUBLISH_MODE; |
|
|
|
Wparam.qos.m_publishMode.kind = ASYNCHRONOUS_PUBLISH_MODE; |
|
|
|
@[else]@ |
|
|
|
@[else]@ |
|
|
|
std::string topicName = ns; |
|
|
|
std::string topicName = ns; |
|
|
|
topicName.append("@(topic)PubSubTopic"); |
|
|
|
|
|
|
|
Wparam.topic.topicName = topicName; |
|
|
|
|
|
|
|
@[end if]@ |
|
|
|
@[end if]@ |
|
|
|
|
|
|
|
topic_name.empty() ? topicName.append("fmu/@(topic_name)/out") : topicName.append(topic_name); |
|
|
|
|
|
|
|
Wparam.topic.topicName = topicName; |
|
|
|
mp_publisher = Domain::createPublisher(mp_participant, Wparam, static_cast<PublisherListener *>(&m_listener)); |
|
|
|
mp_publisher = Domain::createPublisher(mp_participant, Wparam, static_cast<PublisherListener *>(&m_listener)); |
|
|
|
|
|
|
|
|
|
|
|
if (mp_publisher == nullptr) { |
|
|
|
if (mp_publisher == nullptr) { |
|
|
|