示例#1
0
 def createReader(self, topic, listener):
     global mutex
     guard = OpenRTM_aist.ScopedLock(mutex)
     if self._qosProfile:
         return self._subscriber.create_datareader(
             topic, self._qosProfile.get_reader_qos(), listener)
     else:
         reader_qos = dds.Qos([
             dds.DurabilityQosPolicy(dds.DDSDurabilityKind.TRANSIENT),
             dds.DeadlineQosPolicy(dds.DDSDuration(500)),
             dds.LatencyBudgetQosPolicy(dds.DDSDuration(3000)),
             dds.LivelinessQosPolicy(
                 dds.DDSLivelinessKind.MANUAL_BY_PARTICIPANT),
             dds.ReliabilityQosPolicy(dds.DDSReliabilityKind.RELIABLE,
                                      dds.DDSDuration.infinity()),
             dds.DestinationOrderQosPolicy(
                 dds.DDSDestinationOrderKind.BY_SOURCE_TIMESTAMP),
             dds.HistoryQosPolicy(dds.DDSHistoryKind.KEEP_ALL),
             dds.ResourceLimitsQosPolicy(10, 10, 10),
             dds.OwnershipQosPolicy(dds.DDSOwnershipKind.EXCLUSIVE),
             dds.TimeBasedFilterQosPolicy(dds.DDSDuration(2, 500)),
             dds.ReaderDataLifecycleQosPolicy(dds.DDSDuration(3),
                                              dds.DDSDuration(5))
         ])
         return self._subscriber.create_datareader(topic, reader_qos,
                                                   listener)
示例#2
0
 def createWriter(self, topic):
     global mutex
     guard = OpenRTM_aist.ScopedLock(mutex)
     if self._qosProfile:
         return self._publisher.create_datawriter(
             topic, self._qosProfile.get_writer_qos())
     else:
         writer_qos = dds.Qos([
             dds.DurabilityQosPolicy(dds.DDSDurabilityKind.TRANSIENT),
             dds.DeadlineQosPolicy(dds.DDSDuration(500)),
             dds.LatencyBudgetQosPolicy(dds.DDSDuration(3000)),
             dds.LivelinessQosPolicy(
                 dds.DDSLivelinessKind.MANUAL_BY_PARTICIPANT),
             dds.ReliabilityQosPolicy(dds.DDSReliabilityKind.RELIABLE,
                                      dds.DDSDuration.infinity()),
             dds.DestinationOrderQosPolicy(
                 dds.DDSDestinationOrderKind.BY_SOURCE_TIMESTAMP),
             dds.HistoryQosPolicy(dds.DDSHistoryKind.KEEP_ALL),
             dds.ResourceLimitsQosPolicy(10, 10, 10),
             dds.TransportPriorityQosPolicy(700),
             dds.LifespanQosPolicy(dds.DDSDuration(10, 500)),
             dds.OwnershipQosPolicy(dds.DDSOwnershipKind.EXCLUSIVE),
             dds.OwnershipStrengthQosPolicy(100),
             dds.WriterDataLifecycleQosPolicy(False)
         ])
         return self._publisher.create_datawriter(topic, writer_qos)
示例#3
0
    def testGroup_textData(self):
        myData = 'Pub Text Group Data'
        builtinTopicName = 'DCPSPublication'
        sawMyData = Event()

        class L(dds.Listener):
            def on_data_available(self, reader):
                nonlocal sawMyData
                while True:
                    r = reader.take(n=1)
                    if len(r) == 0:
                        break
                    elif r[0].status.valid_data:
                        try:
                            v = bytes(r[0].data.group_data.value).decode(
                                'ISO-8859-1')
                            if v == myData:
                                sawMyData.set()
                                break
                        except UnicodeError:
                            pass

        builtin_sub = self.dp.create_subscriber(
            qos=dds.Qos([dds.PartitionQosPolicy(['__BUILT-IN PARTITION__'])]))
        builtin_topic_info = ddsutil.find_and_register_topic(
            self.dp, builtinTopicName)
        builtin_reader = builtin_sub.create_datareader(
            builtin_topic_info.topic,
            qos=builtin_topic_info.topic.qos,
            listener=L())

        # Register a topic with a TopicdataQosPolicy
        p_qos = dds.Qos(policies=[dds.GroupdataQosPolicy(myData)])
        pub = self.dp.create_publisher(p_qos)

        info = ddsutil.get_dds_classes_from_idl('idl/Shapes.idl', "ShapeType")
        t = info.register_topic(self.dp, "T_testGroup_textData")
        self.assertIsNotNone(t, "Topic registration failed")

        dw = pub.create_datawriter(t)

        self.assertTrue(sawMyData.wait(10), 'Did not see expected data')
        builtin_reader.close()
        dw.close()
        pub.close()
示例#4
0
    def testParticipant_textData(self):
        myData = 'DP Text User Data'
        builtinTopicName = 'DCPSParticipant'
        sawMyData = Event()
        dp_qos_txt = dds.Qos(policies=[dds.UserdataQosPolicy(myData)])
        dp2 = dds.DomainParticipant(qos=dp_qos_txt)

        class L(dds.Listener):
            def on_data_available(self, reader):
                nonlocal sawMyData
                while True:
                    r = reader.take(n=1)
                    if len(r) == 0:
                        break
                    elif r[0].status.valid_data:
                        try:
                            v = bytes(
                                r[0].data.user_data.value).decode('ISO-8859-1')
                            if v == myData:
                                sawMyData.set()
                                break
                        except UnicodeError:
                            pass

        builtin_sub = self.dp.create_subscriber(
            qos=dds.Qos([dds.PartitionQosPolicy(['__BUILT-IN PARTITION__'])]))
        builtin_topic_info = ddsutil.find_and_register_topic(
            self.dp, builtinTopicName)

        builtin_reader = builtin_sub.create_datareader(
            builtin_topic_info.topic,
            qos=builtin_topic_info.topic.qos,
            listener=L())

        self.assertTrue(sawMyData.wait(10), 'Did not see expected data')
        builtin_reader.close()
        dp2.close()
 def createTopic(self, datatype, topicname):
     global mutex
     guard = OpenRTM_aist.ScopedLock(mutex)
     if topicname in self._topic:
         return self._topic[topicname]
     else:
         geninfo = self.genInfo(datatype)
         if geninfo:
             if self._qosProfile:
                 self._topic[topicname] = geninfo.register_topic(
                     self._domainParticipant, topicname, self._qosProfile.get_topic_qos())
             else:
                 topic_qos = dds.Qos([dds.DurabilityQosPolicy(dds.DDSDurabilityKind.TRANSIENT),
                                      dds.DurabilityServiceQosPolicy(dds.DDSDuration(
                                          2, 500), dds.DDSHistoryKind.KEEP_ALL, 2, 100, 100, 100),
                                      dds.DeadlineQosPolicy(
                                          dds.DDSDuration(500)),
                                      dds.LatencyBudgetQosPolicy(
                                          dds.DDSDuration(3000)),
                                      dds.LivelinessQosPolicy(
                     dds.DDSLivelinessKind.MANUAL_BY_PARTICIPANT),
                     dds.ReliabilityQosPolicy(
                     dds.DDSReliabilityKind.RELIABLE, dds.DDSDuration.infinity()),
                     dds.DestinationOrderQosPolicy(
                     dds.DDSDestinationOrderKind.BY_SOURCE_TIMESTAMP),
                     dds.HistoryQosPolicy(
                                          dds.DDSHistoryKind.KEEP_ALL),
                     dds.ResourceLimitsQosPolicy(
                                          10, 10, 10),
                     dds.TransportPriorityQosPolicy(700),
                     dds.LifespanQosPolicy(
                                          dds.DDSDuration(10, 500)),
                     dds.OwnershipQosPolicy(
                                          dds.DDSOwnershipKind.EXCLUSIVE)
                 ])
                 self._topic[topicname] = geninfo.register_topic(
                     self._domainParticipant, topicname, topic_qos)
             return self._topic[topicname]
         return None