Open iory opened 2 years ago
since https://github.com/jsk-ros-pkg/jsk_robot/pull/1570 has been closed and currently we do not have usage for this node. So may be we can leave this PR and re-start discussion / review until we found another use cases.
OK. We will wait until someone needs this node.
What is this?
rostopic echo
has a filter function, but it cannot publish a topic.topic_tools/transform
can 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_type
param 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,
~input
topic isstd_msgs/String
and if you want to check whether a sentence is ahello
, you can do the following.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/wrench
and only those with a force norm greater than 10 are published as/right_endeffector/force_norm
.Use case
https://github.com/jsk-ros-pkg/jsk_robot/pull/1570