sub¶
- class cyclonedds.sub.Subscriber(domain_participant, qos=None, listener=None)[source]¶
Bases:
cyclonedds.core.Entity
- Parameters
domain_participant (cyclonedds.domain.DomainParticipant) –
qos (Optional[cyclonedds.qos.Qos]) –
listener (Optional[cyclonedds.core.Listener]) –
- class cyclonedds.sub.DataReader(subscriber_or_participant, topic, qos=None, listener=None)[source]¶
Bases:
cyclonedds.core.Entity
,Generic
[cyclonedds.sub._T
]Subscribe to a topic and read/take the data published to it.
All returned samples are annotated with the
sample.sample_info
attribute.- Parameters
subscriber_or_participant (Union[cyclonedds.sub.Subscriber, cyclonedds.domain.DomainParticipant]) –
topic (cyclonedds.topic.Topic[cyclonedds.sub._T]) –
qos (Optional[cyclonedds.qos.Qos]) –
listener (Optional[cyclonedds.core.Listener]) –
- property topic: cyclonedds.topic.Topic[cyclonedds.sub._T]¶
- read(N=1, condition=None, instance_handle=None)[source]¶
Read a maximum of N samples, non-blocking. Optionally use a read/query-condition to select which samples you are interested in.
Reading samples does not remove them from the
DataReader's
receive queue. So read methods may return the same sample in multiple calls.- Parameters
N (int) – The maximum number of samples to read.
condition (cyclonedds.core.ReadCondition, cyclonedds.core.QueryCondition, optional) – Only read samples that satisfy the supplied condition.
- Raises
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Return type
List[cyclonedds.sub._T]
- take(N=1, condition=None, instance_handle=None)[source]¶
Take a maximum of N samples, non-blocking. Optionally use a read/query-condition to select which samples you are interested in.
Taking samples removes them from the
DataReader's
receive queue. So take methods will not return the same sample more than once.- Parameters
N (int) – The maximum number of samples to read.
condition (cyclonedds.core.ReadCondition, cyclonedds.core.QueryCondition, optional) – Only take samples that satisfy the supplied condition.
- Raises
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Return type
List[cyclonedds.sub._T]
- read_next()[source]¶
Shortcut method to read exactly one sample or return None.
- Raises
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Return type
Optional[cyclonedds.sub._T]
- take_next()[source]¶
Shortcut method to take exactly one sample or return None.
- Raises
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Return type
Optional[cyclonedds.sub._T]
- read_iter(condition=None, timeout=None)[source]¶
Shortcut method to iterate reading samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.
- Raises
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Parameters
- Return type
Generator[cyclonedds.sub._T, None, None]
- read_one(condition=None, timeout=None)[source]¶
Shortcut method to block and take exactly one sample or raise a timeout
- take_iter(condition=None, timeout=None)[source]¶
Shortcut method to iterate taking samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.
- Raises
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Parameters
- Return type
Generator[cyclonedds.sub._T, None, None]
- take_one(condition=None, timeout=None)[source]¶
Shortcut method to block and take exactly one sample or raise a timeout
- async read_aiter(condition=None, timeout=None)[source]¶
Shortcut method to async iterate reading samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.
- Raises
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Parameters
- Return type
AsyncGenerator[cyclonedds.sub._T, None]
- async take_aiter(condition=None, timeout=None)[source]¶
Shortcut method to async iterate taking samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.
- Raises
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Parameters
- Return type
AsyncGenerator[cyclonedds.sub._T, None]