[jsk_topic_tools] Add filtered relay node which can filter a topic and transform it. #1757
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this?
rostopic echohas a filter function, but it cannot publish a topic.topic_tools/transformcan format a topic and publish it, but it does not have the ability to filter.Transforming while filtering a topic is simple and powerful.
This node provides a filter and publish (i.e. relay) functions.
Subscribing Topic
~input(rospy/AnyMsg)Input message.
Publishing Topic
~output(~output_type)Output topic. You can specify
~output_typeparam to publish topic.Parameters
~output_type(String, required)Message type of output_topic like
std_msgs/Float32. This is the input for the get_message_class function.~filter(String, default:None)Condition of messages that match a specified Python expression.
The Python expression can access any of the Python builtins plus:
topic(the topic of the message),m(the message) andt(time of message).For example,
~inputtopic isstd_msgs/Stringand if you want to check whether a sentence is ahello, you can do the following.filter: m.data == 'hello'Note that, use escape sequence when using the following symbols
<(<),>(>),&(&),'(')and"(")in launch file.~transform(String, default:m)Python expression that transform the input messages, which are given in the variable m. The default expression is
m, which results in forwarding input (which can be a topic field) into output_topic.~import(List[String], default:[])List of Python modules to import and use in the expression.
Usage
Example
The following example subscribe to
/right_endeffector/wrenchand only those with a force norm greater than 10 are published as/right_endeffector/force_norm.Use case
jsk-ros-pkg/jsk_robot#1570