rosh overview: Roshlets | Basics | Messages | Parameters | Topics | Services | Nodes | Topic Tools | Packages | Bags | Bagys | roslaunch

Topic Tools

rosh has wrappers for the topic_tools nodes that allow you to add nodes that throttle and otherwise manipulate topic data.

Mux

The simplest version of using a mux is to simply assign one topic to another:

topics.chatter_muxed = topics.chatter

This creates a mux that will change based on future assignments.

If you wish to have more explicit control over a mux, you can call mux().

mux(input_topics, output_topic)

  • Create a new mux node that selects between the specified input_topics and publishes the selected topic to output_topic. The first input topic is selected by default.

mux_obj(input_topic), mux_obj.switch(input_topic)

  • Switch mux_obj to new input_topic. input_topic can be any topic.

mux_obj.kill(), kill(mux_obj)

  • Stop mux_obj node.

Example

In [1]: m = mux([topics.chatter, topics.chatter2], topics.chatter_mux)
In [2]: topics.chatter_mux[1]
Out[2]: data: hello world 1285199173.47
In [3]: m.topic_input[1]
Out[3]: data: hello world 1285199176.47
In [4]: m.topic_input._name
Out[4]: '/chatter'
In [5]: m(topics.new_topic)
Out[5]: prev_topic: /chatter
In [6]: m.topic_input._name
Out[6]: '/new_topic'
In [7]: kill(m)

Relay

relay(input_topic, output_topic, unreliable=False)

  • Create a new relay node that relays input_topic to output_topic. You can optionally specify unreliable=True to enable UDP transports, or use the more convenient udprelay(). Example:

    In [1]: r = relay(topics.chatter, topics.chatter_relay)
    In [2]: topics.chatter_relay[1]
    Out[2]: data: hello world 1285198595.22
    In [3]: r.topic_output[1]
    Out[3]: data: hello world 1285198635.22
    In [4]: kill(r)

udprelay(input_topic, output_topic)

  • Create a new unreliable relay node that relays input_topic to output_topic.

    This is equivalent to calling relay() with unreliable=True.

relay_obj.kill(), kill(relay_obj)

  • Stop a relay node.

Example

  • In [1]: r = udprelay(topics.chatter, topics.chatter_relay)
    In [2]: topics.chatter_relay[1]
    Out[2]: data: hello world 1285198722.72
    In [3]: kill(r)

throttle

Throttles are useful for limiting the rate at which high bandwidth topics are published. This is useful for either limiting bandwidth across a network link (e.g. wireless) or for limiting the rate at which data is fed to an algorithm.

throttle(input_topic, output_topic, msgs_per_sec)

  • Create a new throttle node that throttles input_topic to output_topic at the specific msgs_per_sec rate (i.e. throttle "messages").

throttlebw(input_topic, output_topic, bytes_per_sec, window=1)

  • Create a new throttle node that throttles input_topic to output_topic at the specific bytes_per_sec bandwidth (i.e. throttle "bytes"). You can optionally specify the window (in seconds) over which to sampel.

throttle_obj.kill(), kill(throttle_obj)

  • Stop a throttle node.

Example

In [1]: t = throttle(topics.chatter, topics.chatter_1hz, 1)
In [2]: topics.chatter_1hz[1]
Out[2]: data: hello world 1285200089.85
In [3]: kill(t)

Wiki: rosh/Overview/Topic Tools (last edited 2010-10-22 01:53:11 by KenConley)