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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
17501ed
[jsk_tools] Add speak warnings node
iory Oct 29, 2018
d8186b9
Add warn_stale option
iory May 12, 2022
ff5c957
Add is_leaf and filter function to jsk_tools'library
iory May 15, 2022
149ce56
Refactor audible_warning
iory May 15, 2022
c6efacd
Add prefix to speaking
iory May 15, 2022
7f39bb0
Refactor AudibleWarning node
iory May 15, 2022
d761034
[jsk_tools/audible_warning] Use priority queue instead of history
iory May 16, 2022
4a9527e
[jsk_tools/audible_warning] Enable run_stop to suppress audible warning
iory May 16, 2022
359a1c9
[jsk_tools/audible_warning] Add seconds_to_start_speaking option for …
iory May 16, 2022
9070dee
[jsk_tools/audible_warning] Enable language specification
iory May 16, 2022
50de35a
[jsk_tools/audible_warning] Fixed namespace of diagnostics
iory May 16, 2022
2da7916
[jsk_tools/audible_warning] Fixed typo language to arg2 and set defau…
iory May 16, 2022
22f7c88
[jsk_tools/audible_warning] Wait until seconds_to_start_speaking the …
iory May 17, 2022
766c0f8
[jsk_tools/audible_warning] Output error name
iory May 17, 2022
637cfc5
[jsk_tools/audible_warning] Check status is leaf node
iory May 17, 2022
f276a5a
[jsk_tools/audible_warning] Enable regex for blacklist
iory May 17, 2022
1a7fc4b
[jsk_tools/audible_warning] Add run_stop blacklist
iory May 17, 2022
6493393
[jsk_tools/audible_warning] Enable blacklist message option
iory May 17, 2022
2ebb2eb
[jsk_tools/audible_warning] Add blacklist messsage option
iory May 17, 2022
38de358
[jsk_tools/audible_warning] Add sample
iory May 17, 2022
860ea9c
[jsk_tools/audible_warning] Add test
iory May 17, 2022
3cb756a
[jsk_tools/diagnostics_utils] Import zip_longest for python2
iory May 17, 2022
12ad343
[jsk_tools/audible_warning] Use LooseVersion for python2
iory May 17, 2022
6d600e4
[jsk_tools/audible-warning] Set volume if it has volume property
iory May 17, 2022
6c68124
[jsk_tools/audible-warning] Fixed test name
iory May 17, 2022
810deb5
[jsk_tools/audible_warning] Split sample diagnostics_analyzer
iory May 23, 2022
f39e0a0
[audible_warning] Add diagnostics_level_to_str
iory May 28, 2022
e3cbd47
[audible_warning] Add dynamic reconfigure parameters
iory May 28, 2022
9c327ba
[audible_warning/sample] Fixed audible_warning node name
iory May 28, 2022
f4673f8
[audible_warning] Use dynamic reconfigure params
iory May 28, 2022
74e0b7d
[audible_warning] Add inflection_utils for camel_to_snake case
iory Jun 3, 2022
5347067
[audible_warning] Add ignore after runstop time
iory May 28, 2022
bd18b93
[audible_warning] Ignore if self.run_stop_(disabled|enabled)_time is …
iory Jun 3, 2022
06a7f46
[audible_warning] Add docs for dynamic reconfigure's parameters
iory Jun 3, 2022
8260dde
[audible_warning] Move audible_warning.py to node_scripts.
iory Jun 6, 2022
5eabeb2
[audible_warning] Fixed lint test target path
iory Jun 6, 2022
1378784
[audible_warning] Fixed lint
iory Jun 6, 2022
d9bc4b6
[audible_warning] Convert multiple space to one
iory Jun 7, 2022
c3e7f5a
[audible_warning] Convert colon symbol to english text
iory Jun 7, 2022
e79d99d
[audible_warning] Add publishing text
iory Jun 7, 2022
6ffae76
[audible_warning] Add AudibleWarningClient for reconfigure
iory Jun 8, 2022
f08d0be
[audible_warning] Make speak_when_runstopped dynamic params
iory Jun 8, 2022
66b5a6d
[audible_warning] Don't add heap at first
iory Jun 8, 2022
f172e76
[audible_warning] Deserialize image
iory Jun 8, 2022
e2b0144
[audible_warning] Fixed typo by adding ()
iory Jun 8, 2022
ac61f4c
[audible_warning] Add loginfo to display runstop state
iory Jun 8, 2022
3f1c59e
[audible_warning] Add pseudo runstop publisher
iory Jun 8, 2022
7e7dcd0
[audible_warning] Add prefix + error name to original text
iory Jun 14, 2022
d698419
[jsk_tools/audible_warning] Modified default speak rate to speed up.
iory Jul 6, 2022
9430db8
[jsk_tools/audible_warning] Add space to published original text.
iory Jul 6, 2022
e303c9a
[jsk_tools/audible_warning] Set wait_speak_duration_time to wait acti…
iory Jul 6, 2022
951d096
Merge branch 'master' into audible-warning
iory Aug 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions doc/jsk_tools/scripts/audible_warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
audible\_warning.py
=======================

## 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 / 100.0`)

Rate of speak loop. If `~wait_speak` is `True`, wait until a robot finish speaking.

* `~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.

* `~wait_speak_duration_time` (`Float`, default: `30.0`)

Waiting time in `robotsound` action.

* `~enable` (`Bool`, default: `True`)

If `True`, speak diagnositcs. If `False`, this node don't speak.

* `~speak_ok` (`Bool`, default: `False`)

If `True`, speak ok level diagnostics.

* `~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.

```bash
run_stop_condition: "m.runstopped is True"
```

* `~ignore_time_after_runstop_is_enabled` (`Float`, default: `0.0`)

Time to ignore diagnostics after runstop is enabled.

* `~ignore_time_after_runstop_is_disabled` (`Float`, default: `0.0`)

Time to ignore diagnostics after runstop is disabled.

- `~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.

```bash
roslaunch jsk_tools sample_audible_warning.launch
```

![audible_warning](./images/audible_warning.jpg)
Binary file added doc/jsk_tools/scripts/images/audible_warning.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions jsk_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
cmake_minimum_required(VERSION 2.8.3)
project(jsk_tools)

find_package(catkin REQUIRED)
find_package(catkin REQUIRED
COMPONENTS
dynamic_reconfigure)
catkin_python_setup()
set(ROS_BUILD_TYPE RelWithDebInfo)

generate_dynamic_reconfigure_options(
cfg/AudibleWarning.cfg
)

catkin_package(
CATKIN_DEPENDS #
CATKIN_DEPENDS dynamic_reconfigure #
LIBRARIES #
INCLUDE_DIRS #
DEPENDS #
Expand All @@ -27,6 +34,7 @@ endforeach(exec)

if (CATKIN_ENABLE_TESTING)
find_package(roslint REQUIRED)
roslint_python(node_scripts/audible_warning.py)
roslint_python(src/jsk_tools/cltool.py)
roslint_python(src/test_topic_published.py)
roslint_python(src/test_rosparam_set.py)
Expand All @@ -49,6 +57,7 @@ if (CATKIN_ENABLE_TESTING)
# https://github.com/jsk-ros-pkg/jsk_common/pull/1293#issuecomment-164158260
jsk_tools_add_rostest(test/test_rosparam_set.test)
endif()
jsk_tools_add_rostest(test/test_audible_warning.test)
jsk_tools_add_rostest(test/test_stdout.test)
jsk_tools_add_rostest(test/test_rostopic_host_sanity.test)
jsk_tools_add_rostest(test/test_sanity_diagnostics.test)
Expand All @@ -74,7 +83,7 @@ install(DIRECTORY test
USE_SOURCE_PERMISSIONS
PATTERN "*.test" EXCLUDE
)
install(DIRECTORY src dot-files cmake launch sample
install(DIRECTORY src dot-files cmake launch sample node_scripts
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
USE_SOURCE_PERMISSIONS
)
Expand Down
26 changes: 26 additions & 0 deletions jsk_tools/cfg/AudibleWarning.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#! /usr/bin/env python


from dynamic_reconfigure.parameter_generator_catkin import *

PACKAGE = 'jsk_tools'

gen = ParameterGenerator()
speak_group = gen.add_group("speak flag")
speak_group.add("enable", bool_t, 0, "Flag of speak", True)
speak_group.add("speak_ok", bool_t, 0, "Speak ok level diagnostics", False)
speak_group.add("speak_stale", bool_t, 0, "Speak stale level diagnostics", True)
speak_group.add("speak_warn", bool_t, 0, "Speak warn level diagnostics", True)
speak_group.add("speak_error", bool_t, 0, "Speak error level diagnostics", True)
speak_group.add("speak_when_runstopped", bool_t, 0, "Speak when runstop is enabled", True)

gen.add("volume", double_t, 0, "Volume of sound.", 1.0, 0.0, 1.0)
gen.add("speak_interval", double_t, 0, "Volume of sound.", 120.0, 0.0, 3600.0)
gen.add("ignore_time_after_runstop_is_enabled", double_t, 0,
"Time to ignore diagnostics after runstop is enabled.",
0.0, 0.0, 3600.0)
gen.add("ignore_time_after_runstop_is_disabled", double_t, 0,
"Time to ignore diagnostics after runstop is disabled.",
0.0, 0.0, 3600.0)

exit(gen.generate(PACKAGE, PACKAGE, "AudibleWarning"))
Loading