jsk-ros-pkg / jsk_common

common programs for jsk-ros-pkg
42 stars 81 forks source link

[jsk_topic_tools] Add filtered relay node which can filter a topic and transform it. #1757

Open iory opened 2 years ago

iory commented 2 years ago

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

Publishing Topic

Parameters

filter: m.data == 'hello'

Note that, use escape sequence when using the following symbols <(&lt;), >(&gt;), &(&amp;), '(&apos;) and "(&quot;) in launch file.

Usage

$ rosrun jsk_topic_tools filtered_relay.py ~input:=/right_endeffector/wrench \
    ~output:=/right_endeffector/force_norm \
    _filter:='numpy.linalg.norm([m.wrench.force.x, m.wrench.force.y, m.wrench.force.z]) > 10.0' \
    _output_type:=geometry_msgs/WrenchStamped _import:="[geometry_msgs, numpy]"

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.

roslaunch jsk_topic_tools sample_filtered_relay.launch

Use case

https://github.com/jsk-ros-pkg/jsk_robot/pull/1570

k-okada commented 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.

iory commented 2 years ago

OK. We will wait until someone needs this node.