cyclonedds-python
cyclonedds-python copied to clipboard
TimeBasedFilter Policy Not Functional
trafficstars
cyclonedds version = 0.10.3 cyclonedds-python version = 0.10.2
Assuming I understand the use case for the TimeBasedFilter QoS, I have been unable to get the TimeBasedFilter QoS policy to work. I have not experimented with the base C implementation or the C++ binding.
For a sanity check, I altered examples/vehicle, but I uncovered the problem in my specific application.
Expected behavior: subscriber.py prints the topic at approximately 1 Hz.
Actual behavior: subscriber.py prints the topic at approximately 10 Hz.
# Removed specific Topic QoS, using default.
domain_participant = DomainParticipant(0)
topic = Topic(domain_participant, 'Vehicle', Vehicle)
publisher = Publisher(domain_participant)
writer = DataWriter(publisher, topic)
vehicle = Vehicle(name="Dallara IL-15", x=200, y=200)
while True:
vehicle.x += random.choice([-1, 0, 1])
vehicle.y += random.choice([-1, 0, 1])
writer.write(vehicle)
print(">> Wrote vehicle")
time.sleep(0.1) # Changed to achieve ~ 10 Hz publish rate
class MyListener(Listener):
def on_liveliness_changed(self, reader, status):
print(">> Liveliness event")
listener = MyListener()
# Removed specific Topic QoS, using default.
reader_qos = Qos(
Policy.TimeBasedFilter(duration(seconds=1))
)
domain_participant = DomainParticipant(0)
topic = Topic(domain_participant, 'Vehicle', Vehicle)
subscriber = Subscriber(domain_participant)
reader = DataReader(domain_participant, topic, reader_qos, listener=listener)
for sample in reader.take_iter(timeout=duration(seconds=2)):
print(sample, datetime.now())