Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jsk_tools] Add audible warnings node #1607

Open
wants to merge 52 commits into
base: master
Choose a base branch
from

Conversation

iory
Copy link
Member

@iory iory commented Oct 29, 2018

What is this?

This is a general node that subscribes to /diagnostics_agg to speak the error content.
Robots using diagnostics can use this node.

Target Action

  • /robotsound (sound_play/SoundRequestAction)

    Target action name.

    If it is a different server name, please remap it like <remap from="/robotsound" to="/sound_play" />.

Subscribing Topics

  • /diagnostics_agg (diagnostic_msgs/DiagnosticArray)

    Aggregated diagnostics.

Parameter

  • ~speak_rate (Float, default: 1.0)

    Rate of speak loop.

  • ~speak_interval (Float, default: 120.0)

    The same error will not be spoken until this number of seconds has passed.

  • ~volume (Float, default: 1.0)

    Volume of speaking.

  • ~language (String, default: "")

    Language parameters for arg2 in sound_play/SoundRequestAction.

  • ~wait_speak (Bool, default: True)

    If True, wait until finish saying one error.

  • ~seconds_to_start_speaking (Float, default: 0.0)

    It is the time to wait for the node to speak after it has started.

    This is useful for ignoring errors that occur when the robot starts.

  • ~speak_warn (Bool, default: True)

    If True, speak warning level diagnostics.

  • ~speak_error (Bool, default: True)

    If True, speak error level diagnostics.

  • ~speak_stale (Bool, default: True)

    If True, speak stale level diagnostics.

  • ~speak_when_runstopped (Bool, default: True)

    If True, speak an error even if runstop is True.

  • ~run_stop_topic (String, default: None)

    Subscribe this topic if this value is specified.

  • ~run_stop_condition (String, default: m.data == True)

    Returning bool value condition using the given Python expression.
    The Python expression can access any of the Python builtins plus:
    topic (the topic of the message), m (the message) and t (time of message).

    For example, ~run_stop_topic is robot_state (fetch_driver_msgs/RobotState) and if you want to check whether a runstop is a pressed, you can do the following.

    run_stop_condition: "m.runstopped is True"
  • ~blacklist (Yaml, required)

    User must always specify name. You can specify message as an option.

    These values are matched using python regular expressions.

    It is something like below:

    <!-- speak warning -->
    <node name="audible_warning"
          pkg="jsk_tools" type="audible_warning.py"
          output="screen" >
      <remap from="/robotsound" to="/sound_play" />
      <rosparam>
        run_stop_topic: robot_state
        run_stop_condition: "m.runstopped is True"
        seconds_to_start_speaking: 30
        blacklist:
          - "/CPU/CPU Usage/my_machine CPU Usage"
          - "/SoundPlay/sound_play: Node State"
          - "/Other/jsk_joy_node: Joystick Driver Status"
          - "/Other/Combined Gyro"
          - "/Other/l515_head l515_head_realsense2_camera_color: Frequency Status"
          - "/Other/l515_head l515_head_realsense2_camera_confidence: Frequency Status"
          - "/Other/l515_head l515_head_realsense2_camera_depth: Frequency Status"
          - "/Other/l515_head l515_head_realsense2_camera_infra: Frequency Status"
          - "/Other/ukf_se: Filter diagnostic updater"
          - "/Peripherals/PS3 Controller"
          - "/Sensors/IMU/IMU 1 Gyro"
          - "/Sensors/IMU/IMU 2 Gyro"
        run_stop_blacklist:
          - "\\w*_(mcb|breaker)"
          - "/Motor Control Boards/.*"
          - "/Breakers/.*"
      </rosparam>
    </node>
    
  • ~run_stop_blacklist (Yaml, optional)

    This is valid when run_stop is True. Blacklist at run_stop.

Usage

Listen warnings from diagnostics.

roslaunch jsk_tools sample_audible_warning.launch

@iory iory changed the title [WIP[jsk_tools] Add speak warnings node [WIP] [jsk_tools] Add speak warnings node Oct 29, 2018
@k-okada
Copy link
Member

k-okada commented Nov 1, 2018

@k-okada
Copy link
Member

k-okada commented Apr 25, 2019

waiting for @iory 's feedback

@708yamaguchi
Copy link
Member

who is using this

I think robots using /diagnostics can use this.

how can we integrate with existing warning codes?
https://github.com/jsk-ros-pkg/jsk_robot/blob/master/jsk_fetch_robot/jsk_fetch_startup/scripts/warning.py ? https://github.com/jsk-ros-pkg/jsk_robot/tree/master/jsk_pr2_robot/jsk_pr2_startup/jsk_pr2_warning

Most of the existing code is robot-specific.
On the other hand, the functions of this node are applicable to all robots in common.
For example, rostopic types of robot driver or battery vary from robot to robot, but /diagnostics type is common.

The only code whose function overlaps with the function of this node is jsk_fetch_startup/warning.py.
https://github.com/jsk-ros-pkg/jsk_robot/blob/master/jsk_fetch_robot/jsk_fetch_startup/scripts/warning.py

I think the following function is in jsk_fetch_startup/warning.py but not in this node.

  • Option to speak DiagnosticStatus.ERROR
  • Speck throttle function. For example, robots speak error once in 10 minites.

In addition, It would be nice to have the function to stop the speak function only immediately after program startup.
This is because diagnostics status is not stable when programs startup.

For example

  • some topics has not come
  • CPU load is high and CPU load warn is output
    ... etc

@708yamaguchi
Copy link
Member

I created PR for fetch to use audible_warning.py.
jsk-ros-pkg/jsk_robot#1480

@iory
Copy link
Member Author

iory commented May 17, 2022

@708yamaguchi
Thank you for your review!
I modified the code and added a sample and docs.
Please check it.

@iory
Copy link
Member Author

iory commented May 24, 2022

@k-okada
Tests tend to fail these days because the data collection server tests rely on sleep and have a luck factor.
The data collection server test solves with #1728

  Skipping "catkin_tools_prebuild/package.xml": the root tag is neither 'testsuite' nor 'testsuites'
  Full test results for 'jsk_data/test_results/jsk_data/rosunit-test_data_collection_server.xml'
  -------------------------------------------------
  <?xml version="1.0" encoding="utf-8"?>
  <testsuite errors="0" failures="1" name="unittest.suite.TestSuite" tests="3" time="11.371"><testcase classname="__main__.TestDataCollectionServer" name="test_all" time="4.9011"><failure type="AssertionError">0 not greater than 0
    File "/usr/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
      yield
    File "/usr/lib/python3.8/unittest/case.py", line 676, in run
      self._callTestMethod(testMethod)
    File "/usr/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
      method()
    File "/github/home/ros/ws_jsk_common/src/jsk_common/jsk_data/tests/test_data_collection_server.py", line 93, in test_all
      self.check(save_dir, target='image')
    File "/github/home/ros/ws_jsk_common/src/jsk_common/jsk_data/tests/test_data_collection_server.py", line 35, in check
      self.assertGreater(len(sub_dirs), 0)
    File "/usr/lib/python3.8/unittest/case.py", line 1310, in assertGreater
      self.fail(self._formatMessage(msg, standardMsg))
    File "/usr/lib/python3.8/unittest/case.py", line 753, in fail
      raise self.failureException(msg)
  </failure></testcase><testcase classname="__main__.TestDataCollectionServer" name="test_request" time="3.3947" /><testcase classname="__main__.TestDataCollectionServer" name="test_timer" time="3.0749" /><system-out>&lt;![CDATA[
  
  ]]&gt;</system-out><system-err>&lt;![CDATA[
  /github/home/ros/ws_jsk_common/src/jsk_common/jsk_data/tests/test_data_collection_server.py:45: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
    data = yaml.load(f)

iory added 25 commits July 13, 2022 20:54
@iory iory force-pushed the audible-warning branch from 4e6e771 to e303c9a Compare July 13, 2022 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants