Skip to content

Commit

Permalink
Apply PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
luisrg-rti committed Oct 23, 2024
1 parent 4a56501 commit d1f1729
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,7 @@
and DataReader created in the example code.
A QoS profile groups a set of related QoS.
-->
<qos_profile name="waitset_status_cond_py_Profile" base_name="BuiltinQosLibExp::Generic.StrictReliable" is_default_qos="true">
<!-- QoS used to configure the data writer created in the example code -->
<datawriter_qos>
<reliability>
<kind>RELIABLE_RELIABILITY_QOS</kind>
</reliability>

<history>
<kind>KEEP_ALL_HISTORY_QOS</kind>
</history>
</datawriter_qos>

<!-- QoS used to configure the data reader created in the example code -->
<datareader_qos>
<reliability>
<kind>RELIABLE_RELIABILITY_QOS</kind>
</reliability>

<history>
<kind>KEEP_ALL_HISTORY_QOS</kind>
</history>
</datareader_qos>
<qos_profile name="waitset_status_cond_py_Profile" base_name="BuiltinQosLib::Generic.StrictReliable" is_default_qos="true">

<domain_participant_qos>
<!-- The participant name, if it is set, will be displayed in the RTI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# any incidental or consequential damages arising out of the use or inability
# to use the software.

import time
import argparse

import rti.connextdds as dds
Expand All @@ -32,20 +31,10 @@ def publisher_main(domain_id, sample_count):
# Enable statuses configuration for the Status Condition
status_condition.enabled_statuses = dds.StatusMask.PUBLICATION_MATCHED

# This enables start sending samples when we know there's a match
send_samples = False

# Define a handler for the Status Condition
def status_handler(_):
nonlocal send_samples
status_mask = writer.status_changes
st = writer.publication_matched_status

if dds.StatusMask.PUBLICATION_MATCHED in status_mask:
if st.current_count > 0:
send_samples = True
else:
send_samples = False
print(f"Publication matched changed => Matched readers = {st.current_count}")

status_condition.set_handler(status_handler)

Expand All @@ -65,12 +54,10 @@ def status_handler(_):
# WaitSet conditions when they activate
waitset.dispatch(dds.Duration(1, 0)) # Wait up to 1s each time

if send_samples:
print(f"Writing Foo, count = {samples_sent}")
sample.x = samples_sent
writer.write(sample)

samples_sent += 1
print(f"Writing Foo, count = {samples_sent}")
sample.x = samples_sent
writer.write(sample)
samples_sent += 1
except KeyboardInterrupt:
break

Expand Down

0 comments on commit d1f1729

Please sign in to comment.