<launch>
  <node pkg="rostopic" type="rostopic" name="rostopic_pub" 
        args="pub -r 20 input std_msgs/String chatter"/>

  <!-- Automatic output name -->
  <node pkg="topic_tools" type="throttle" name="throttle"
        args="messages input 5"/>
  <test test-name="throttle_hztest" pkg="rostest" type="hztest">
    <param name="topic" value="input_throttle"/>
    <param name="hz" value="5.0"/>
    <param name="hzerror" value="1.0"/>
    <param name="test_duration" value="2.0" />
  </test>

  <!-- Explicit output name -->
  <node pkg="topic_tools" type="throttle" name="throttle_explicit"
        args="messages input 5 output"/>
  <test test-name="throttle_hztest_explicit" pkg="rostest" type="hztest">
    <param name="topic" value="output"/>
    <param name="hz" value="5.0"/>
    <param name="hzerror" value="1.0"/>
    <param name="test_duration" value="2.0" />
  </test>

  <!-- Test byte-based throttling.  Note that the desired rate for the
  hztest is a function of both the requested bytes/second and the length of
  the string being published:
    10 msg/sec = 110 B/sec / 11 B/msg 
  (11 = 4-byte length + 7 characters in "chatter")
  It would be more direct to test the bandwidth directly, but hztest 
  doesn't do that.  -->
  <node pkg="topic_tools" type="throttle" name="throttle_bytes"
        args="bytes input 110 1 output_bytes"/>
  <test test-name="throttle_hztest_bytes" pkg="rostest" type="hztest">
    <param name="topic" value="output_bytes"/>
    <param name="hz" value="10.0"/>
    <!-- Wider tolerance because we're seeing occasional under-minimum failures -->
    <param name="hzerror" value="1.5"/>
    <param name="test_duration" value="4.0" />
  </test>

</launch>
