From 8c0537444b1a55b39638bd4a63e11335d8170ffc Mon Sep 17 00:00:00 2001 From: Nobuhiko Miyamoto Date: Wed, 2 Feb 2022 16:05:57 +0900 Subject: [PATCH 1/6] [incompat] Factory object can set Property. --- OpenRTM_aist/GlobalFactory.py | 31 ++++++++++++++++++++++++++++--- OpenRTM_aist/InPortBase.py | 30 ++++++++++++++++++++++++++++++ OpenRTM_aist/OutPortBase.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/OpenRTM_aist/GlobalFactory.py b/OpenRTM_aist/GlobalFactory.py index 45b14876..8c6e3e47 100644 --- a/OpenRTM_aist/GlobalFactory.py +++ b/OpenRTM_aist/GlobalFactory.py @@ -51,14 +51,14 @@ def getIdentifiers(self): # ReturnCode addFactory(const Identifier& id, # Creator creator) - def addFactory(self, id, creator): + def addFactory(self, id, creator, prop=None): if not creator: return self.INVALID_ARG if id in self._creators: return self.ALREADY_EXISTS - self._creators[id] = creator + self._creators[id] = FactoryEntry(id, creator, prop) return self.FACTORY_OK # ReturnCode removeFactory(const Identifier& id) @@ -76,9 +76,34 @@ def createObject(self, id): if not id in self._creators: print("Factory.createObject return None id: ", id) return None - obj_ = self._creators[id]() + obj_ = self._creators[id].creator() return obj_ + def getProperties(self, id): + if not id in self._creators: + print("Factory.getProperties return None id: ", id) + return None + return self._creators[id].prop + + +class FactoryEntry: + def __init__(self, id, creator, prop=None): + self._id = id + self._creator = creator + self._prop = prop + + @property + def id(self): + return self._id + + @property + def creator(self): + return self._creator + + @property + def prop(self): + return self._prop + gfactory = None diff --git a/OpenRTM_aist/InPortBase.py b/OpenRTM_aist/InPortBase.py index d98425aa..aac4ed40 100644 --- a/OpenRTM_aist/InPortBase.py +++ b/OpenRTM_aist/InPortBase.py @@ -1175,10 +1175,25 @@ def initProviders(self): # InPortProvider supports "push" dataflow type if provider_types: + prop_options = OpenRTM_aist.Properties() self._rtcout.RTC_DEBUG("dataflow_type push is supported") self.appendProperty("dataport.dataflow_type", "push") for provider_type in provider_types: self.appendProperty("dataport.interface_type", provider_type) + prop_if = factory.getProperties(provider_type) + if prop_if is None: + prop_if = OpenRTM_aist.Properties() + + prop_node = prop_options.getNode(provider_type) + prop_node.mergeProperties(prop_if) + + prop = OpenRTM_aist.Properties() + OpenRTM_aist.NVUtil.copyToProperties( + prop, self._profile.properties) + prop_dataport = prop.getNode("dataport.interface_type") + prop_dataport.mergeProperties(prop_options) + OpenRTM_aist.NVUtil.copyFromProperties( + self._profile.properties, prop) self._providerTypes = provider_types return @@ -1219,10 +1234,25 @@ def initConsumers(self): # OutPortConsumer supports "pull" dataflow type if consumer_types: + prop_options = OpenRTM_aist.Properties() self._rtcout.RTC_PARANOID("dataflow_type pull is supported") self.appendProperty("dataport.dataflow_type", "pull") for consumer_type in consumer_types: self.appendProperty("dataport.interface_type", consumer_type) + prop_if = factory.getProperties(consumer_type) + if prop_if is None: + prop_if = OpenRTM_aist.Properties() + + prop_node = prop_options.getNode(consumer_type) + prop_node.mergeProperties(prop_if) + + prop = OpenRTM_aist.Properties() + OpenRTM_aist.NVUtil.copyToProperties( + prop, self._profile.properties) + prop_dataport = prop.getNode("dataport.interface_type") + prop_dataport.mergeProperties(prop_options) + OpenRTM_aist.NVUtil.copyFromProperties( + self._profile.properties, prop) self._consumerTypes = consumer_types return diff --git a/OpenRTM_aist/OutPortBase.py b/OpenRTM_aist/OutPortBase.py index 7f9e45b4..3c792a17 100644 --- a/OpenRTM_aist/OutPortBase.py +++ b/OpenRTM_aist/OutPortBase.py @@ -1188,11 +1188,27 @@ def initProviders(self): provider_types = provider_types + list(set_ptypes) # OutPortProvider supports "pull" dataflow type + if provider_types: + prop_options = OpenRTM_aist.Properties() self._rtcout.RTC_DEBUG("dataflow_type pull is supported") self.appendProperty("dataport.dataflow_type", "pull") for provider_type in provider_types: self.appendProperty("dataport.interface_type", provider_type) + prop_if = factory.getProperties(provider_type) + if prop_if is None: + prop_if = OpenRTM_aist.Properties() + + prop_node = prop_options.getNode(provider_type) + prop_node.mergeProperties(prop_if) + + prop = OpenRTM_aist.Properties() + OpenRTM_aist.NVUtil.copyToProperties( + prop, self._profile.properties) + prop_dataport = prop.getNode("dataport.interface_type") + prop_dataport.mergeProperties(prop_options) + OpenRTM_aist.NVUtil.copyFromProperties( + self._profile.properties, prop) self._providerTypes = provider_types @@ -1232,10 +1248,25 @@ def initConsumers(self): # InPortConsumer supports "push" dataflow type if consumer_types: + prop_options = OpenRTM_aist.Properties() self._rtcout.RTC_PARANOID("dataflow_type push is supported") self.appendProperty("dataport.dataflow_type", "push") for consumer_type in consumer_types: self.appendProperty("dataport.interface_type", consumer_type) + prop_if = factory.getProperties(consumer_type) + if prop_if is None: + prop_if = OpenRTM_aist.Properties() + + prop_node = prop_options.getNode(consumer_type) + prop_node.mergeProperties(prop_if) + + prop = OpenRTM_aist.Properties() + OpenRTM_aist.NVUtil.copyToProperties( + prop, self._profile.properties) + prop_dataport = prop.getNode("dataport.interface_type") + prop_dataport.mergeProperties(prop_options) + OpenRTM_aist.NVUtil.copyFromProperties( + self._profile.properties, prop) self._consumerTypes = consumer_types From 6cefac82a1edc768798252c4ebaaf4a7d1c44aea Mon Sep 17 00:00:00 2001 From: Nobuhiko Miyamoto Date: Mon, 7 Feb 2022 06:56:55 +0900 Subject: [PATCH 2/6] [compat] fixed parameter name. --- OpenRTM_aist/InPortBase.py | 4 ++-- OpenRTM_aist/OutPortBase.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRTM_aist/InPortBase.py b/OpenRTM_aist/InPortBase.py index aac4ed40..4d3e71e4 100644 --- a/OpenRTM_aist/InPortBase.py +++ b/OpenRTM_aist/InPortBase.py @@ -1190,7 +1190,7 @@ def initProviders(self): prop = OpenRTM_aist.Properties() OpenRTM_aist.NVUtil.copyToProperties( prop, self._profile.properties) - prop_dataport = prop.getNode("dataport.interface_type") + prop_dataport = prop.getNode("dataport.interface_option") prop_dataport.mergeProperties(prop_options) OpenRTM_aist.NVUtil.copyFromProperties( self._profile.properties, prop) @@ -1249,7 +1249,7 @@ def initConsumers(self): prop = OpenRTM_aist.Properties() OpenRTM_aist.NVUtil.copyToProperties( prop, self._profile.properties) - prop_dataport = prop.getNode("dataport.interface_type") + prop_dataport = prop.getNode("dataport.interface_option") prop_dataport.mergeProperties(prop_options) OpenRTM_aist.NVUtil.copyFromProperties( self._profile.properties, prop) diff --git a/OpenRTM_aist/OutPortBase.py b/OpenRTM_aist/OutPortBase.py index 3c792a17..48c9761e 100644 --- a/OpenRTM_aist/OutPortBase.py +++ b/OpenRTM_aist/OutPortBase.py @@ -1205,7 +1205,7 @@ def initProviders(self): prop = OpenRTM_aist.Properties() OpenRTM_aist.NVUtil.copyToProperties( prop, self._profile.properties) - prop_dataport = prop.getNode("dataport.interface_type") + prop_dataport = prop.getNode("dataport.interface_option") prop_dataport.mergeProperties(prop_options) OpenRTM_aist.NVUtil.copyFromProperties( self._profile.properties, prop) @@ -1263,7 +1263,7 @@ def initConsumers(self): prop = OpenRTM_aist.Properties() OpenRTM_aist.NVUtil.copyToProperties( prop, self._profile.properties) - prop_dataport = prop.getNode("dataport.interface_type") + prop_dataport = prop.getNode("dataport.interface_option") prop_dataport.mergeProperties(prop_options) OpenRTM_aist.NVUtil.copyFromProperties( self._profile.properties, prop) From 3e30211de950f667b4912f30b3ba63ff930d098c Mon Sep 17 00:00:00 2001 From: Nobuhiko Miyamoto Date: Mon, 7 Mar 2022 09:17:41 +0900 Subject: [PATCH 3/6] [incompat] support ros2 parameter. --- .../ext/transport/ROS2Transport/ROS2InPort.py | 78 +++++-- .../transport/ROS2Transport/ROS2OutPort.py | 77 ++++++- .../ROS2Transport/ROS2TopicManager.py | 214 +++++++++++------- .../transport/ROS2Transport/ROS2Transport.py | 32 ++- .../ext/transport/ROS2Transport/rtc.conf | 2 +- 5 files changed, 293 insertions(+), 110 deletions(-) diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py index 4d645ed5..e4c55294 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py @@ -39,6 +39,7 @@ class ROS2InPort(OpenRTM_aist.InPortProvider): """ """ + ddstype = "fast-rtps" ## # @if jp @@ -67,7 +68,7 @@ def __init__(self): OpenRTM_aist.InPortProvider.__init__(self) # PortProfile setting - self.setInterfaceType("ros2") + self.setInterfaceType(self.ddstype) self._profile = None self._listeners = None @@ -144,12 +145,11 @@ def init(self, prop): self._properties = prop - args = [] - self._topicmgr = ROS2TopicManager.instance(args) + self._topicmgr = ROS2TopicManager.instance() self._messageType = prop.getProperty( "marshaling_type", "ros2:std_msgs/Float32") - self._topic = prop.getProperty("ros2.topic", "chatter") + self._topic = prop.getProperty(self.ddstype+".topic", "chatter") self._rtcout.RTC_VERBOSE("message type: %s", self._messageType) self._rtcout.RTC_VERBOSE("topic name: %s", self._topic) @@ -159,18 +159,23 @@ def init(self, prop): info_type = info.datatype() - qos = ROS2TopicManager.get_qosprofile(prop.getNode("ros2.subscriber.qos")) + ddsprop = prop.getNode(self.ddstype) + + qos = ROS2TopicManager.get_qosprofile(ddsprop.getNode("reader_qos")) self._rtcout.RTC_VERBOSE("history policy: %s", qos.history) self._rtcout.RTC_VERBOSE("depth: %d", qos.depth) self._rtcout.RTC_VERBOSE("reliability policy: %s", qos.reliability) self._rtcout.RTC_VERBOSE("durability policy: %s", qos.durability) - self._rtcout.RTC_VERBOSE("lifespan: %d [nsec]", qos.lifespan.nanoseconds) - self._rtcout.RTC_VERBOSE("deadline: %d [nsec]", qos.deadline.nanoseconds) + self._rtcout.RTC_VERBOSE( + "lifespan: %d [nsec]", qos.lifespan.nanoseconds) + self._rtcout.RTC_VERBOSE( + "deadline: %d [nsec]", qos.deadline.nanoseconds) self._rtcout.RTC_VERBOSE("liveliness policy: %s", qos.liveliness) - self._rtcout.RTC_VERBOSE("liveliness lease duration: %d [nsec]", qos.liveliness_lease_duration.nanoseconds) - self._rtcout.RTC_VERBOSE("avoid ros namespace conventions: %s", qos.avoid_ros_namespace_conventions) - + self._rtcout.RTC_VERBOSE( + "liveliness lease duration: %d [nsec]", qos.liveliness_lease_duration.nanoseconds) + self._rtcout.RTC_VERBOSE( + "avoid ros namespace conventions: %s", qos.avoid_ros_namespace_conventions) self._subscriber = self._topicmgr.createSubscriber( info_type, self._topic, self.ros2_callback, qos) @@ -353,6 +358,48 @@ def onReceiverError(self, data): return data +ros2_sub_option = [ + "topic.__value__", "chatter", + "topic.__widget__", "text", + "topic.__constraint__", "none", + "reader_qos.durability.kind.__value__", "TRANSIENT_DURABILITY_QOS", + "reader_qos.durability.kind.__widget__", "radio", + "reader_qos.durability.kind.__constraint__", "(VOLATILE_DURABILITY_QOS, TRANSIENT_LOCAL_DURABILITY_QOS, SYSTEM_DEFAULT_QOS)", + "reader_qos.deadline.period.sec.__value__", "0", + "reader_qos.deadline.period.sec.__widget__", "spin", + "reader_qos.deadline.period.sec.__constraint__", "0 <= x <= 2147483647", + "reader_qos.deadline.period.nanosec.__value__", "0", + "reader_qos.deadline.period.nanosec.__widget__", "text", + "reader_qos.deadline.period.nanosec.__constraint__", "0 <= x <= 2147483647", + "reader_qos.liveliness.kind.__value__", "AUTOMATIC_LIVELINESS_QOS", + "reader_qos.liveliness.kind.__widget__", "radio", + "reader_qos.liveliness.kind.__constraint__", "(AUTOMATIC_LIVELINESS_QOS, MANUAL_BY_TOPIC_LIVELINESS_QOS, SYSTEM_DEFAULT_LIVELINESS_QOS)", + "reader_qos.liveliness.lease_duration.sec.__value__", "0", + "reader_qos.liveliness.lease_duration.sec.__widget__", "spin", + "reader_qos.liveliness.lease_duration.sec.__constraint__", "0 <= x <= 2147483647", + "reader_qos.liveliness.lease_duration.nanosec.__value__", "0", + "reader_qos.liveliness.lease_duration.nanosec.__widget__", "spin", + "reader_qos.liveliness.lease_duration.nanosec.__constraint__", "0 <= x <= 2147483647", + "reader_qos.reliability.kind.__value__", "RELIABLE_RELIABILITY_QOS", + "reader_qos.reliability.kind.__widget__", "radio", + "reader_qos.reliability.kind.__constraint__", "(BEST_EFFORT_RELIABILITY_QOS, RELIABLE_RELIABILITY_QOS, SYSTEM_DEFAULT_RELIABILITY_QOS)", + "reader_qos.history.kind.__value__", "KEEP_LAST_HISTORY_QOS", + "reader_qos.history.kind.__widget__", "radio", + "reader_qos.history.kind.__constraint__", "(KEEP_LAST_HISTORY_QOS, KEEP_ALL_HISTORY_QOS, SYSTEM_DEFAULT_HISTORY_QOS)", + "reader_qos.history.depth.__value__", "1", + "reader_qos.history.depth.__widget__", "spin", + "reader_qos.history.depth.__constraint__", "0 <= x <= 2147483647", + "reader_qos.lifespan.duration.sec.__value__", "10000", + "reader_qos.lifespan.duration.sec.__widget__", "spin", + "reader_qos.lifespan.duration.sec.__constraint__", "0 <= x <= 2147483647", + "reader_qos.lifespan.duration.nanosec.__value__", "2147483647", + "reader_qos.lifespan.duration.nanosec.__widget__", "spin", + "reader_qos.lifespan.duration.nanosec.__constraint__", "0 <= x <= 2147483647", + "reader_qos.avoid_ros_namespace_conventions.__value__", "YES", + "reader_qos.avoid_ros_namespace_conventions.__widget__", "radio", + "reader_qos.avoid_ros_namespace_conventions.__constraint__", "(YES, NO)", + ""] + ## # @if jp # @brief モジュール登録関数 @@ -364,7 +411,12 @@ def onReceiverError(self, data): # # @endif # -def ROS2InPortInit(): + + +def ROS2InPortInit(ddstype="fast-rtps"): + prop = OpenRTM_aist.Properties(defaults_str=ros2_sub_option) factory = OpenRTM_aist.InPortProviderFactory.instance() - factory.addFactory("ros2", - ROS2InPort) + factory.addFactory(ddstype, + ROS2InPort, + prop) + ROS2InPort.ddstype = ddstype diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py index 96f0e3e4..a949cec5 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py @@ -38,6 +38,7 @@ class ROS2OutPort(OpenRTM_aist.InPortConsumer): """ """ + ddstype = "fast-rtps" ## # @if jp @@ -114,12 +115,11 @@ def init(self, prop): self._properties = prop - args = [] - self._topicmgr = ROS2TopicManager.instance(args) + self._topicmgr = ROS2TopicManager.instance() self._messageType = prop.getProperty( "marshaling_type", "ros2:std_msgs/Float32") - self._topic = prop.getProperty("ros2.topic", "chatter") + self._topic = prop.getProperty(self.ddstype+".topic", "chatter") self._rtcout.RTC_VERBOSE("message type: %s", self._messageType) self._rtcout.RTC_VERBOSE("topic name: %s", self._topic) @@ -129,19 +129,25 @@ def init(self, prop): info_type = info.datatype() - qos = ROS2TopicManager.get_qosprofile(prop.getNode("ros2.publisher.qos")) + ddsprop = prop.getNode(self.ddstype) + + qos = ROS2TopicManager.get_qosprofile( + ddsprop.getNode("writer_qos")) self._rtcout.RTC_VERBOSE("history policy: %s", qos.history) self._rtcout.RTC_VERBOSE("depth: %d", qos.depth) self._rtcout.RTC_VERBOSE("reliability policy: %s", qos.reliability) self._rtcout.RTC_VERBOSE("durability policy: %s", qos.durability) - self._rtcout.RTC_VERBOSE("lifespan: %d [nsec]", qos.lifespan.nanoseconds) - self._rtcout.RTC_VERBOSE("deadline: %d [nsec]", qos.deadline.nanoseconds) + self._rtcout.RTC_VERBOSE( + "lifespan: %d [nsec]", qos.lifespan.nanoseconds) + self._rtcout.RTC_VERBOSE( + "deadline: %d [nsec]", qos.deadline.nanoseconds) self._rtcout.RTC_VERBOSE("liveliness policy: %s", qos.liveliness) - self._rtcout.RTC_VERBOSE("liveliness lease duration: %d [nsec]", qos.liveliness_lease_duration.nanoseconds) - self._rtcout.RTC_VERBOSE("avoid ros namespace conventions: %s", qos.avoid_ros_namespace_conventions) + self._rtcout.RTC_VERBOSE( + "liveliness lease duration: %d [nsec]", qos.liveliness_lease_duration.nanoseconds) + self._rtcout.RTC_VERBOSE( + "avoid ros namespace conventions: %s", qos.avoid_ros_namespace_conventions) - self._publisher = self._topicmgr.createPublisher( info_type, self._topic, qos) @@ -268,6 +274,48 @@ def unsubscribeInterface(self, properties): pass +ros2_pub_option = [ + "topic.__value__", "chatter", + "topic.__widget__", "text", + "topic.__constraint__", "none", + "writer_qos.durability.kind.__value__", "TRANSIENT_DURABILITY_QOS", + "writer_qos.durability.kind.__widget__", "radio", + "writer_qos.durability.kind.__constraint__", "(VOLATILE_DURABILITY_QOS, TRANSIENT_LOCAL_DURABILITY_QOS, SYSTEM_DEFAULT_QOS)", + "writer_qos.deadline.period.sec.__value__", "10000", + "writer_qos.deadline.period.sec.__widget__", "spin", + "writer_qos.deadline.period.sec.__constraint__", "0 <= x <= 2147483647", + "writer_qos.deadline.period.nanosec.__value__", "2147483647", + "writer_qos.deadline.period.nanosec.__widget__", "text", + "writer_qos.deadline.period.nanosec.__constraint__", "0 <= x <= 2147483647", + "writer_qos.liveliness.kind.__value__", "AUTOMATIC_LIVELINESS_QOS", + "writer_qos.liveliness.kind.__widget__", "radio", + "writer_qos.liveliness.kind.__constraint__", "(AUTOMATIC_LIVELINESS_QOS, MANUAL_BY_TOPIC_LIVELINESS_QOS, SYSTEM_DEFAULT_LIVELINESS_QOS)", + "writer_qos.liveliness.lease_duration.sec.__value__", "0", + "writer_qos.liveliness.lease_duration.sec.__widget__", "spin", + "writer_qos.liveliness.lease_duration.sec.__constraint__", "0 <= x <= 2147483647", + "writer_qos.liveliness.lease_duration.nanosec.__value__", "0", + "writer_qos.liveliness.lease_duration.nanosec.__widget__", "spin", + "writer_qos.liveliness.lease_duration.nanosec.__constraint__", "0 <= x <= 2147483647", + "writer_qos.reliability.kind.__value__", "RELIABLE_RELIABILITY_QOS", + "writer_qos.reliability.kind.__widget__", "radio", + "writer_qos.reliability.kind.__constraint__", "(BEST_EFFORT_RELIABILITY_QOS, RELIABLE_RELIABILITY_QOS, SYSTEM_DEFAULT_RELIABILITY_QOS)", + "writer_qos.history.kind.__value__", "KEEP_LAST_HISTORY_QOS", + "writer_qos.history.kind.__widget__", "radio", + "writer_qos.history.kind.__constraint__", "(KEEP_LAST_HISTORY_QOS, KEEP_ALL_HISTORY_QOS, SYSTEM_DEFAULT_HISTORY_QOS)", + "writer_qos.history.depth.__value__", "1", + "writer_qos.history.depth.__widget__", "spin", + "writer_qos.history.depth.__constraint__", "0 <= x <= 2147483647", + "writer_qos.lifespan.duration.sec.__value__", "0", + "writer_qos.lifespan.duration.sec.__widget__", "spin", + "writer_qos.lifespan.duration.sec.__constraint__", "0 <= x <= 2147483647", + "writer_qos.lifespan.duration.nanosec.__value__", "0", + "writer_qos.lifespan.duration.nanosec.__widget__", "spin", + "writer_qos.lifespan.duration.nanosec.__constraint__", "0 <= x <= 2147483647", + "writer_qos.avoid_ros_namespace_conventions.__value__", "YES", + "writer_qos.avoid_ros_namespace_conventions.__widget__", "radio", + "writer_qos.avoid_ros_namespace_conventions.__constraint__", "(YES, NO)", + ""] + ## # @if jp # @brief モジュール登録関数 @@ -279,7 +327,12 @@ def unsubscribeInterface(self, properties): # # @endif # -def ROS2OutPortInit(): + + +def ROS2OutPortInit(ddstype="fast-rtps"): + prop = OpenRTM_aist.Properties(defaults_str=ros2_pub_option) factory = OpenRTM_aist.InPortConsumerFactory.instance() - factory.addFactory("ros2", - ROS2OutPort) + factory.addFactory(ddstype, + ROS2OutPort, + prop) + ROS2OutPort.ddstype = ddstype diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2TopicManager.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2TopicManager.py index 9eaff5fa..b108b0c8 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2TopicManager.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2TopicManager.py @@ -20,6 +20,7 @@ import OpenRTM_aist import ROS2MessageInfo import rclpy +import rclpy.qos from rclpy.node import Node from rclpy.qos import QoSProfile @@ -151,7 +152,7 @@ def shutdown(self): # @param self # @param msgtype # @param topic - # @param qos + # @param qos # @return # # @endif @@ -184,7 +185,7 @@ def createPublisher(self, msgtype, topic, qos=None): # @param msgtype # @param topic # @param listener - # @param qos + # @param qos # @return # # @endif @@ -203,6 +204,29 @@ def deletePublisher(self, pub): def deleteSubscriber(self, sub): pass + ## + # @if jp + # @brief 初期化 + # + # + # @else + # + # @brief + # + # + # @endif + + def init(args=[]): + global manager + global mutex + + guard = OpenRTM_aist.ScopedLock(mutex) + if manager is None: + manager = ROS2TopicManager() + manager.start(args) + + init = staticmethod(init) + ## # @if jp # @brief インスタンス取得 @@ -217,14 +241,14 @@ def deleteSubscriber(self, sub): # # @endif - def instance(args=[]): + def instance(): global manager global mutex guard = OpenRTM_aist.ScopedLock(mutex) if manager is None: manager = ROS2TopicManager() - manager.start(args) + manager.start() return manager @@ -254,7 +278,6 @@ def shutdown_global(): shutdown_global = staticmethod(shutdown_global) - ## # @if jp # @brief プロパティからQoSProfileを設定する @@ -268,6 +291,7 @@ def shutdown_global(): # @return QoSProfile # # @endif + def get_qosprofile(prop): if hasattr(rclpy.qos, "HistoryPolicy"): @@ -295,90 +319,116 @@ def get_qosprofile(prop): else: LivelinessPolicy = rclpy.qos.QoSLivelinessPolicy - history = HistoryPolicy.KEEP_LAST - history_type = prop.getProperty("history", "KEEP_LAST") - - if history_type == "SYSTEM_DEFAULT": - history = HistoryPolicy.SYSTEM_DEFAULT - elif history_type == "KEEP_ALL": - history = HistoryPolicy.KEEP_ALL - else: - history = HistoryPolicy.KEEP_LAST - - - depth = 10 - depth_value_str = prop.getProperty("depth", "10") + durability_kind = DurabilityPolicy.SYSTEM_DEFAULT + durability_kind_str = prop.getProperty( + "durability.kind") + if durability_kind_str == "VOLATILE_DURABILITY_QOS": + durability_kind = DurabilityPolicy.VOLATILE + elif durability_kind_str == "TRANSIENT_LOCAL_DURABILITY_QOS": + durability_kind = DurabilityPolicy.TRANSIENT_LOCAL + elif durability_kind_str == "SYSTEM_DEFAULT_QOS": + durability_kind = DurabilityPolicy.SYSTEM_DEFAULT + + deadline_period = ROS2TopicManager.getDuration( + prop.getNode("deadline.period"), Duration) + + if deadline_period is None: + deadline_period = Duration( + seconds=0, nanoseconds=0) + + liveliness_kind = LivelinessPolicy.SYSTEM_DEFAULT + liveliness_kind_str = prop.getProperty( + "liveliness.kind") + if liveliness_kind_str == "AUTOMATIC_LIVELINESS_QOS": + liveliness_kind = LivelinessPolicy.AUTOMATIC + elif liveliness_kind_str == "MANUAL_BY_TOPIC_LIVELINESS_QOS": + liveliness_kind = LivelinessPolicy.MANUAL_BY_TOPIC + elif liveliness_kind_str == "SYSTEM_DEFAULT_LIVELINESS_QOS": + liveliness_kind = LivelinessPolicy.SYSTEM_DEFAULT + + liveliness_lease_duration_time = ROS2TopicManager.getDuration( + prop.getNode("liveliness.lease_duration"), Duration) + + if liveliness_lease_duration_time is None: + liveliness_lease_duration_time = Duration( + seconds=0, nanoseconds=0) + + reliability_kind = ReliabilityPolicy.SYSTEM_DEFAULT + reliability_kind_str = prop.getProperty( + "reliability.kind") + if reliability_kind_str == "BEST_EFFORT_RELIABILITY_QOS": + reliability_kind = ReliabilityPolicy.BEST_EFFORT + elif reliability_kind_str == "RELIABLE_RELIABILITY_QOS": + reliability_kind = ReliabilityPolicy.RELIABLE + elif reliability_kind_str == "SYSTEM_DEFAULT_RELIABILITY_QOS": + reliability_kind = ReliabilityPolicy.SYSTEM_DEFAULT + + history_qos_policy_kind = HistoryPolicy.SYSTEM_DEFAULT + history_qos_policy_kind_str = prop.getProperty( + "history.kind") + if history_qos_policy_kind_str == "KEEP_ALL_HISTORY_QOS": + history_qos_policy_kind = HistoryPolicy.KEEP_ALL + elif history_qos_policy_kind_str == "KEEP_LAST_HISTORY_QOS": + history_qos_policy_kind = HistoryPolicy.KEEP_LAST + elif history_qos_policy_kind_str == "SYSTEM_DEFAULT_HISTORY_QOS": + history_qos_policy_kind = HistoryPolicy.SYSTEM_DEFAULT + + history_depth = 1 try: - depth = int(depth_value_str) - except ValueError: + history_depth = int(prop.getProperty( + "history.depth")) + except ValueError as error: pass + # self._rtcout.RTC_ERROR(error) - reliability = ReliabilityPolicy.RELIABLE - reliability_type = prop.getProperty("reliability", "RELIABLE") - if reliability_type == "SYSTEM_DEFAULT": - reliability = ReliabilityPolicy.SYSTEM_DEFAULT - elif reliability_type == "BEST_EFFORT": - reliability = ReliabilityPolicy.BEST_EFFORT - else: - reliability = ReliabilityPolicy.RELIABLE - - durability = DurabilityPolicy.VOLATILE - durability_type = prop.getProperty("durability", "VOLATILE") - if durability_type == "SYSTEM_DEFAULT": - durability = DurabilityPolicy.SYSTEM_DEFAULT - elif durability_type == "TRANSIENT_LOCAL": - durability = DurabilityPolicy.TRANSIENT_LOCAL - else: - durability = DurabilityPolicy.VOLATILE - - lifespan = Duration(seconds=0, nanoseconds=0) - lifespan_value_str = prop.getProperty("lifespan", "0") - try: - lifespan_value = int(lifespan_value_str) - lifespan = Duration(nanoseconds=lifespan_value) - except ValueError: - pass - - deadline = Duration(seconds=0, nanoseconds=0) - deadline_value_str = prop.getProperty("deadline", "0") - try: - deadline_value = int(deadline_value_str) - deadline = Duration(nanoseconds=deadline_value) - except ValueError: - pass + lifespan_duration = ROS2TopicManager.getDuration( + prop.getNode("lifespan.duration"), Duration) - liveliness = LivelinessPolicy.SYSTEM_DEFAULT - liveliness_type = prop.getProperty("liveliness", "SYSTEM_DEFAULT") - if liveliness_type == "AUTOMATIC": - liveliness = LivelinessPolicy.AUTOMATIC - elif liveliness_type == "MANUAL_BY_NODE": - liveliness = LivelinessPolicy.MANUAL_BY_NODE - elif liveliness_type == "MANUAL_BY_TOPIC": - liveliness = LivelinessPolicy.MANUAL_BY_TOPIC - else: - liveliness = LivelinessPolicy.SYSTEM_DEFAULT - - liveliness_lease_duration = Duration(seconds=0, nanoseconds=0) - liveliness_lease_duration_value_str = prop.getProperty("liveliness_lease_duration", "0") - try: - liveliness_lease_duration_value = int(liveliness_lease_duration_value_str) - liveliness_lease_duration = Duration(nanoseconds=liveliness_lease_duration_value) - except ValueError: - pass + if lifespan_duration is None: + lifespan_duration = Duration( + seconds=10000, nanoseconds=2147483647) - avoid_ros_namespace_conventions = False - if OpenRTM_aist.toBool(prop.getProperty( - "avoid_ros_namespace_conventions"), "YES", "NO", False): - avoid_ros_namespace_conventions = True - else: - avoid_ros_namespace_conventions = False - + avoid_ros_namespace_conventions = OpenRTM_aist.toBool(prop.getProperty( + "avoid_ros_namespace_conventions"), "YES", "NO", False) - qos = QoSProfile(history=history, depth=depth, reliability=reliability, durability=durability, - lifespan=lifespan, deadline=deadline, liveliness=liveliness, - liveliness_lease_duration=liveliness_lease_duration, - avoid_ros_namespace_conventions=avoid_ros_namespace_conventions) + qos = QoSProfile(history=history_qos_policy_kind, depth=history_depth, + reliability=reliability_kind, + durability=durability_kind, + lifespan=lifespan_duration, + deadline=deadline_period, + liveliness=liveliness_kind, + liveliness_lease_duration=liveliness_lease_duration_time, + avoid_ros_namespace_conventions=avoid_ros_namespace_conventions) return qos get_qosprofile = staticmethod(get_qosprofile) + + ## + # @if jp + # @brief プロパティからDDS::Durationを設定して取得する + # + # @param self + # @param prop プロパティ(sec、nanosecの要素に値を格納する) + # @return DDS::Duration + # + # @else + # + # @brief + # + # @param self + # @param prop + # @return + # + # @endif + def getDuration(prop, DDSDuration): + try: + sec = int(prop.getProperty("sec")) + nanosec = int(prop.getProperty("nanosec")) + return DDSDuration(seconds=sec, nanoseconds=nanosec) + except ValueError as error: + return None + # self._rtcout.RTC_ERROR(error) + return None + + getDuration = staticmethod(getDuration) diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2Transport.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2Transport.py index d172d8d0..b98f51e5 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2Transport.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2Transport.py @@ -17,6 +17,7 @@ # $Id$ # +import os import OpenRTM_aist import ROS2InPort import ROS2OutPort @@ -89,8 +90,35 @@ def postReinit(self): # @endif # def ROS2TransportInit(mgr): - ROS2InPort.ROS2InPortInit() - ROS2OutPort.ROS2OutPortInit() + ddstype_env = os.getenv("RMW_IMPLEMENTATION") + ddstype = "fast-rtps" + if ddstype_env == "rmw_fastrtps_cpp" or ddstype_env == "rmw_fastrtps_dynamic_cpp": + ddstype = "fast-rtps" + elif ddstype_env == "rmw_connext_cpp" or ddstype_env == "rti_connext_cpp" or ddstype_env == "rmw_connextdds": + ddstype = "rti-connext-dds" + elif ddstype_env == "rmw_opensplice_cpp": + ddstype = "opensplice" + elif ddstype_env == "rmw_iceoryx_cpp": + ddstype = "iceoryx" + elif ddstype_env == "rmw_connextddsmicro": + ddstype = "rti-connext-dds-micro" + elif ddstype_env == "rmw_cyclonedds_cpp": + ddstype = "cyclone-dds" + + ROS2OutPort.ROS2OutPortInit(ddstype) + ROS2InPort.ROS2InPortInit(ddstype) + ROS2Serializer.ROS2SerializerInit() + tmp_args = mgr.getConfig().getProperty("ros2.args").split("\"") + args = [] + for i, tmp_arg in enumerate(tmp_args): + if i % 2 == 0: + args.extend(tmp_arg.strip().split(" ")) + else: + args.append(tmp_arg) + + args.insert(0, "manager") + ROS2TopicManager.init(args) + mgr.addManagerActionListener(ManagerActionListener()) diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/rtc.conf b/OpenRTM_aist/ext/transport/ROS2Transport/rtc.conf index 8d31c18c..f055ca1a 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/rtc.conf +++ b/OpenRTM_aist/ext/transport/ROS2Transport/rtc.conf @@ -6,5 +6,5 @@ manager.modules.load_path: . #manager.components.precreate: ConsoleOut #manager.components.preconnect: ConsoleOut0.in?port=ConsoleIn0.out manager.modules.preload: ROS2Transport.py -manager.components.preconnect: ConsoleOut0.in?interface_type=ros2&marshaling_type=ROS2Float32, ConsoleIn0.out?interface_type=ros2&marshaling_type=ROS2Float32 manager.components.preactivation: ConsoleOut0, ConsoleIn0 +manager.components.preconnect: ConsoleOut0.in?interface_type=fast-rtps&marshaling_type=ros2:std_msgs/Float32, ConsoleIn0.out?interface_type=fast-rtps&marshaling_type=ros2:std_msgs/Float32 From 1b740008986de409f0af5c95ae5c7b3b41fffe89 Mon Sep 17 00:00:00 2001 From: Nobuhiko Miyamoto Date: Tue, 8 Mar 2022 14:12:22 +0900 Subject: [PATCH 4/6] [compat] ros2 parameter. --- .../ext/transport/ROS2Transport/ROS2InPort.py | 4 +-- .../transport/ROS2Transport/ROS2OutPort.py | 4 +-- .../ROS2Transport/ROS2TopicManager.py | 26 ++++++++++++++----- .../transport/ROS2Transport/ROS2Transport.py | 11 +------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py index e4c55294..157ef903 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py @@ -389,10 +389,10 @@ def onReceiverError(self, data): "reader_qos.history.depth.__value__", "1", "reader_qos.history.depth.__widget__", "spin", "reader_qos.history.depth.__constraint__", "0 <= x <= 2147483647", - "reader_qos.lifespan.duration.sec.__value__", "10000", + "reader_qos.lifespan.duration.sec.__value__", "0", "reader_qos.lifespan.duration.sec.__widget__", "spin", "reader_qos.lifespan.duration.sec.__constraint__", "0 <= x <= 2147483647", - "reader_qos.lifespan.duration.nanosec.__value__", "2147483647", + "reader_qos.lifespan.duration.nanosec.__value__", "0", "reader_qos.lifespan.duration.nanosec.__widget__", "spin", "reader_qos.lifespan.duration.nanosec.__constraint__", "0 <= x <= 2147483647", "reader_qos.avoid_ros_namespace_conventions.__value__", "YES", diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py index a949cec5..de8313ae 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py @@ -281,10 +281,10 @@ def unsubscribeInterface(self, properties): "writer_qos.durability.kind.__value__", "TRANSIENT_DURABILITY_QOS", "writer_qos.durability.kind.__widget__", "radio", "writer_qos.durability.kind.__constraint__", "(VOLATILE_DURABILITY_QOS, TRANSIENT_LOCAL_DURABILITY_QOS, SYSTEM_DEFAULT_QOS)", - "writer_qos.deadline.period.sec.__value__", "10000", + "writer_qos.deadline.period.sec.__value__", "0", "writer_qos.deadline.period.sec.__widget__", "spin", "writer_qos.deadline.period.sec.__constraint__", "0 <= x <= 2147483647", - "writer_qos.deadline.period.nanosec.__value__", "2147483647", + "writer_qos.deadline.period.nanosec.__value__", "0", "writer_qos.deadline.period.nanosec.__widget__", "text", "writer_qos.deadline.period.nanosec.__constraint__", "0 <= x <= 2147483647", "writer_qos.liveliness.kind.__value__", "AUTOMATIC_LIVELINESS_QOS", diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2TopicManager.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2TopicManager.py index b108b0c8..7ed87650 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2TopicManager.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2TopicManager.py @@ -102,9 +102,21 @@ def __del__(self): # # @endif - def start(self, args=[]): + def start(self, prop): + + tmp_args = prop.getProperty("args").split("\"") + args = [] + for i, tmp_arg in enumerate(tmp_args): + if i % 2 == 0: + args.extend(tmp_arg.strip().split(" ")) + else: + args.append(tmp_arg) + + args.insert(0, "manager") + rclpy.init(args=args) - self._node = Node("openrtm") + + self._node = Node(prop.getProperty("node.name", "openrtm")) def spin(): while self._loop: @@ -216,14 +228,14 @@ def deleteSubscriber(self, sub): # # @endif - def init(args=[]): + def init(prop): global manager global mutex guard = OpenRTM_aist.ScopedLock(mutex) if manager is None: manager = ROS2TopicManager() - manager.start(args) + manager.start(prop) init = staticmethod(init) @@ -422,9 +434,11 @@ def get_qosprofile(prop): # # @endif def getDuration(prop, DDSDuration): + sec_str = prop.getProperty("sec") + nanosec_str = prop.getProperty("nanosec") try: - sec = int(prop.getProperty("sec")) - nanosec = int(prop.getProperty("nanosec")) + sec = int(sec_str) + nanosec = int(nanosec_str) return DDSDuration(seconds=sec, nanoseconds=nanosec) except ValueError as error: return None diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2Transport.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2Transport.py index b98f51e5..3e1601b3 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2Transport.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2Transport.py @@ -110,15 +110,6 @@ def ROS2TransportInit(mgr): ROS2Serializer.ROS2SerializerInit() - tmp_args = mgr.getConfig().getProperty("ros2.args").split("\"") - args = [] - for i, tmp_arg in enumerate(tmp_args): - if i % 2 == 0: - args.extend(tmp_arg.strip().split(" ")) - else: - args.append(tmp_arg) - - args.insert(0, "manager") - ROS2TopicManager.init(args) + ROS2TopicManager.init(mgr.getConfig().getNode("ros2")) mgr.addManagerActionListener(ManagerActionListener()) From 05c64797fc430ee2256f1e923139a83a051b65fd Mon Sep 17 00:00:00 2001 From: Nobuhiko Miyamoto Date: Fri, 11 Mar 2022 09:19:04 +0900 Subject: [PATCH 5/6] [compat] fixed raise exeption. --- OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py | 3 +++ OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py index 157ef903..67797b1c 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py @@ -180,6 +180,9 @@ def init(self, prop): self._subscriber = self._topicmgr.createSubscriber( info_type, self._topic, self.ros2_callback, qos) + if self._subscriber is None: + raise MemoryError("Subscriber creation failed") + # virtual void setBuffer(BufferBase* buffer); def setBuffer(self, buffer): diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py index de8313ae..edf6653c 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py @@ -151,6 +151,9 @@ def init(self, prop): self._publisher = self._topicmgr.createPublisher( info_type, self._topic, qos) + if self._publisher is None: + raise MemoryError("Publisher creation failed") + ## # @if jp # @brief 接続先へのデータ送信 From 93121dad706b3b33641baac67484bdb4bc1b5052 Mon Sep 17 00:00:00 2001 From: Nobuhiko Miyamoto Date: Fri, 11 Mar 2022 16:10:48 +0900 Subject: [PATCH 6/6] [compat] fixed interfece type name. --- .../ext/transport/ROS2Transport/ROS2InPort.py | 28 +++++++++++++++++-- .../transport/ROS2Transport/ROS2OutPort.py | 28 +++++++++++++++++-- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py index 67797b1c..cad287c5 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2InPort.py @@ -149,7 +149,10 @@ def init(self, prop): self._messageType = prop.getProperty( "marshaling_type", "ros2:std_msgs/Float32") - self._topic = prop.getProperty(self.ddstype+".topic", "chatter") + + ddsprop = prop.getNode(self.ddstype) + + self._topic = ddsprop.getProperty("topic", "chatter") self._rtcout.RTC_VERBOSE("message type: %s", self._messageType) self._rtcout.RTC_VERBOSE("topic name: %s", self._topic) @@ -159,8 +162,6 @@ def init(self, prop): info_type = info.datatype() - ddsprop = prop.getNode(self.ddstype) - qos = ROS2TopicManager.get_qosprofile(ddsprop.getNode("reader_qos")) self._rtcout.RTC_VERBOSE("history policy: %s", qos.history) @@ -361,6 +362,24 @@ def onReceiverError(self, data): return data +## +# @if jp +# @class ROS2InPortB +# @brief ROS2Transportのインターフェース型ros2とDDS実装(fast-rtps or rti-connext-dds etc.) +# の2つで登録するために、ROS2InPortのインターフェース型名をros2に設定したオブジェクト +# +# @else +# @class ROS2InPortB +# @brief +# +# +# @endif +class ROS2InPortB(ROS2InPort): + def __init__(self): + self.ddstype = "ros2" + ROS2InPort.__init__(self) + + ros2_sub_option = [ "topic.__value__", "chatter", "topic.__widget__", "text", @@ -422,4 +441,7 @@ def ROS2InPortInit(ddstype="fast-rtps"): factory.addFactory(ddstype, ROS2InPort, prop) + factory.addFactory("ros2", + ROS2InPortB, + prop) ROS2InPort.ddstype = ddstype diff --git a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py index edf6653c..d65fcdf2 100644 --- a/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py +++ b/OpenRTM_aist/ext/transport/ROS2Transport/ROS2OutPort.py @@ -119,7 +119,10 @@ def init(self, prop): self._messageType = prop.getProperty( "marshaling_type", "ros2:std_msgs/Float32") - self._topic = prop.getProperty(self.ddstype+".topic", "chatter") + + ddsprop = prop.getNode(self.ddstype) + + self._topic = ddsprop.getProperty("topic", "chatter") self._rtcout.RTC_VERBOSE("message type: %s", self._messageType) self._rtcout.RTC_VERBOSE("topic name: %s", self._topic) @@ -129,8 +132,6 @@ def init(self, prop): info_type = info.datatype() - ddsprop = prop.getNode(self.ddstype) - qos = ROS2TopicManager.get_qosprofile( ddsprop.getNode("writer_qos")) @@ -277,6 +278,24 @@ def unsubscribeInterface(self, properties): pass +## +# @if jp +# @class ROS2OutPortB +# @brief ROS2Transportのインターフェース型ros2とDDS実装(fast-rtps or rti-connext-dds etc.) +# の2つで登録するために、ROS2OutPortのインターフェース型名をros2に設定したオブジェクト +# +# @else +# @class ROS2OutPortB +# @brief +# +# +# @endif +class ROS2OutPortB(ROS2OutPort): + def __init__(self): + self.ddstype = "ros2" + ROS2OutPort.__init__(self) + + ros2_pub_option = [ "topic.__value__", "chatter", "topic.__widget__", "text", @@ -338,4 +357,7 @@ def ROS2OutPortInit(ddstype="fast-rtps"): factory.addFactory(ddstype, ROS2OutPort, prop) + factory.addFactory("ros2", + ROS2OutPortB, + prop) ROS2OutPort.ddstype = ddstype