jsk-ros-pkg / jsk_common

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

[jsk_topic_tools] Eval at every timer callback #1758

Closed iory closed 1 year ago

iory commented 2 years ago

What is this?

Changed boolean node to evaluate condition each time a topic is published. For example, a condition that checks whether a certain topic has arrived within one second look like this.

  <node name="shutdown_selector"
        pkg="jsk_topic_tools" type="boolean_node.py"
        output="screen"
        clear_params="true"
        respawn="true" >
    <remap from="~input1" to="$(arg battery_state_topic)" />
    <remap from="~input2" to="$(arg shutdown_unchecked_topic)" />
    <remap from="~output/and" to="/execute_shutdown" />
    <rosparam>
      number_of_input: 2
      input1_condition: "m.is_charging is False"
      input2_condition: "(rospy.Time.now() - t).to_sec() &lt; 1.0"
    </rosparam>
  </node>

Use case

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