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_robot_startup] Systemd service for speaking at shutdown #1628

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

Conversation

nakane11
Copy link
Member

@nakane11 nakane11 commented Sep 29, 2022

What is this?

start_sound.service and stop_sound.service are installed to tell you when the robot starts and stops. If aplay is not available, beep command is used.
Synthesized Japanese voice is played by default(VOICEVOX:四国めたん). To play different sound, put your wave file in /usr/share/sound/jsk_robot_startup and update path written in /usr/local/bin/jsk_robot_startup/playsound.sh.

Installation(first time)

To install scripts, run the following command with device name as an argument.
You can get your device name by executing aplay -L.
The files are overwritten after the second time.

Examples

fetch15

rosrun jsk_robot_startup install_systemd.sh sysdefault:CARD=AUDIO

fetch1075

rosrun jsk_robot_startup install_systemd.sh sysdefault:CARD=ArrayUAC10

laptop

rosrun jsk_robot_startup install_systemd.sh default

I confirmed that it works in fetch15, fetch1075 and my laptop using /sbin/shutdown -h now and reboot.
This feature is necessary to immediately tell people that the robot shuts down(including non-users).
boot_sound.py differs in that it cannot work without soundplay.

syslog

Sep 29 10:46:38 fetch1075 systemd[1]: Starting Play sound at shutdown...
Sep 29 10:46:38 fetch1075 stop_sound.sh[22749]: /usr/local/bin/jsk_robot_startup/stop_sound.sh
Sep 29 10:46:38 fetch1075 stop_sound.sh[22749]: sysdefault:CARD=ArrayUAC10
Sep 29 10:46:38 fetch1075 stop_sound.sh[22749]: Shutdown sound: Playing WAVE '/usr/share/sounds/jsk_robot_startup/stop_sound.wav' : Signed 16 bit Little Endian, Rate 24000 Hz, Mono
Sep 29 10:47:16 fetch1075 systemd[1]: Started Play sound at startup.
Sep 29 10:47:16 fetch1075 start_sound.sh[1106]: /usr/local/bin/jsk_robot_startup/start_sound.sh
Sep 29 10:47:16 fetch1075 start_sound.sh[1106]: sysdefault:CARD=ArrayUAC10
Sep 29 10:47:16 fetch1075 start_sound.sh[1106]: Boot sound: Playing WAVE '/usr/share/sounds/jsk_robot_startup/start_sound.wav' : Signed 16 bit Little Endian, Rate 24000 Hz, Mono

@@ -1,6 +1,17 @@
jsk_robot_startup
===

## SetUp (Running following commands in the first time)

### Install systemd services
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some name to this systemd services and describe it with more details?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added more description
cb03944

@sktometometo
Copy link
Contributor

sktometometo commented Jun 29, 2023

I think start_sound and stop_sound are confusing name. They sounds like just start playing some sounds and stop it. These services are more than that.

How about startup_sound and shutdown_sound instead? Since the sound files say "Starting up" ("起動します") and "Shuting down" (シャットダウンします).

It would be better if they can describe its behavior without making its name too complicated. (hooked at startup and shutdown)

# Created by VOICEVOX:四国めたん
cd $jsk_robot_startup/data
if [ ! -d /usr/share/sounds/jsk_robot_startup ]; then
sudo mkdir -p /usr/share/sounds/jsk_robot_startup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the directory to /usr/local/share/sounds/jsk_robot_startup?

https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s09.html says

Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr. [28]

# Copy scripts
cd $jsk_robot_startup/systemd
if [ ! -d /usr/local/bin/jsk_robot_startup ]; then
sudo mkdir -p /usr/local/bin/jsk_robot_startup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this directory to /usr/local/src (maybe /usr/local/share/) ?
We should not copy these file under the bin directory if we do not deal with these file as binary executable.

You can get DEVICE_NAME by executing `aplay -L`(e.g. sysdefault:CARD=AUDIO).
```bash
rosrun jsk_robot_startup install_systemd.sh DEVICE_NAME
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add how to uninstall these files installed under /usr/local.

@sktometometo
Copy link
Contributor

Please see https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html for requirements and guidelines for file and directory placement under UNIX-like operating systems.

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.

2 participants